First Install Apache
1. yum install httpd httpd-devel
2. /etc/init.d/httpd start
Second Install MySQL
1. yum install mysql mysql-server mysql-devel
If you attempt to type mysql in command prompt, you will be getting this error.
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
This is because you are not running the mysqld daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically created upon running the first instance of mysql.
First start the mysql daemon, then type mysql:
1. /etc/init.d/mysqld start
Changing MySQL Root Password
By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(‘newpassword’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;
Once done, check by logging in:
mysql -u root -p
Enter Password: <your new password>
To Create A New MySQL User
To create a new mysql user ‘guest’ with ‘all privileges’ on the database ‘demo’:
mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO ‘guest’@'localhost’ IDENTIFIED BY ‘guest’ WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD(‘guest’) WHERE user=’guest’;
That’s it! MySQL is ready! Don’t forget to remember the root password as we might be using it with phpmyadmin.
Third Install PHP5 Scripting Language
Installing PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.
1. yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
Don’t forget to install php-gd (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions.
Restart Apache to load php.
1. /etc/init.d/httpd restart
To Test If PHP Is Working Or Not:
Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.