The LAMP stack is commonly used for web servers. LAMP stands for Linux, Apache, MySQL and PHP (as well as Python and Perl). The following steps will show you how-to install Linux, Apache, MySQL and PHP on CentOS 6. I’ll be using a 512 MB VPS from Digital Ocean. It’s only $5 per month and CentOS 6 is pre-installed!
This tutorial will only show you how-to install Apache, MySQL and PHP.
To install Apache, type and enter the following command:
sudo yum install httpd
Now let’s make sure Apache is installed:
rpm -qa | grep httpd
You should see something like this:
Now, we can start Apache:
sudo service httpd start
To install MySQL, type and enter the following command:
sudo yum install mysql-server
Start MySQL like so:
sudo service mysqld start
To set the root password for MySQL, type and enter the following command:
The prompt will ask you for your current password, which should be nothing, before setting up the new password.
Next, the prompt will ask you four (4) questions. Read each question carefully and enter Y for yes or n for No for each question.
MySQL is now installed!
We should also make sure that Apache and MySQL is started upon boot:
sudo chkconfig httpd on
sudo chkconfig mysqld on
To install PHP, type and enter the following command:
sudo yum install php php-mysql
You can type the following to see if PHP is installed and what version:
We can also create a file to check PHP’s configuration settings and available predefined variables.
sudo vi /var/www/html/phpinfo.php
Note: If the path to the public folder is different, make sure you change the path to the file in the command.
In the file add:
Save and exit the file. You can type :wq! to do this.
Next, restart Apache:
sudo service httpd restart
Now, to see the results, you can go to:
Where is the IP address of the VPS. Or:
Where yourdomain.com is the hostname (or domain, depending on how you setup the VPS) of the VPS.
Once you are done, let’s remove the phpinfo.php file:
sudo rm /var/www/html/phpinfo.php