Our first step, is fairly simple. Once you’ve connected to your server over SSH, use the following Yum command to install everything you need:
yum -y install httpd php mysql mysql-server php-mysql
This will take a few minutes to download (total package size is 16Mb)
Once its done Yum will say “Complete!” and you will be returned to shell.
Next, you need to set a MySQL root password. Without this, your MySQL server is open to attack, and it WILL happen! Use the following command (WITH QUOTES) to set your root password:
mysqladmin -u root password 'ENTER-PASSWORD-HERE'
Next we want to do additional security checks on MySQL by removing any other users that managed to get created, as well as removing the MySQL test database as that wont be needed!
mysql -u root -p mysql> DROP DATABASE test; mysql> DELETE FROM mysql.user WHERE user = ''; mysql> FLUSH PRIVILEGES;
Finally, we are going to set Apache & MySQL to run on startup. This is useful if your server has a power outage or needs to be rebooted as it will automatically restart Apache & MySQL for you.
/sbin/chkconfig httpd on /sbin/chkconfig --add mysqld /sbin/chkconfig mysqld on /sbin/service httpd start /sbin/service mysqld start
To check everything worked, browse to the web servers directory (on CentOS its /var/www/html) and create a new file using NANO text editor called phpinfo.php (enter “nano phpinfo.php” to open the text editor). Enter the following code into that file to check PHP is working:
<php echo phpinfo(); ?>