Installing Apache, MySQL, and PHP on CentOS 6 in the Cloud Server
The LAMP is an acronym which stands for Linux, Apache, MySQL, and PHP. This type of software stack is very popular and it is the leading open-source solution to set up the web servers. We have planned to make use of the CentOS of Linux on a HostingRaja CLoud. In this article, we are going to explain how to install the other components and you need to assume that you have set up a CentOS HOstingRaja Cloud from scratch and have logged in as root. Non-root users are required to use the sudo command.
Steps to Install Apache, MySQL, and PHP on CentOS 6:
1) Install Apache
To install and start Apache, open the SSH terminal and include the below mentioned commands:
yum -y install httpd
service httpd start
You need to check whether Apache is installed and running in a right manner with:
service httpd status
Note: You will not be able to see if Apache is running properly by visiting the IP address of the HostingRaja Cloud from your browser, as the firewall will block your visit as a default.
You need to open port 80 to access your web server:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
2) Installing MySQL
For installing and starting up of MySQL, you need to open the SSH terminal and include the below mentioned commands:
yum -y install mysql-server
service mysqld start
On the production servers, you need to secure MySQL with the below mentioned command:
The command prompt will request for the current MySQL root password and leave it blank by pressing the ENTER button.
And later, answer the command prompt as mentioned below:
Set root password? [Y/n] Y
New password: abcd
Re-enter new password: abcd
Remove anonymous user? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
For installing PHP on your HostingRaja Cloud, you need to open the SSH terminal and include the below mentioned command:
yum -y install php php-mysql
Depending on the web applications that you intend to run, you may require installing few PHP modules on your server. To check the available modules you need to type the following command:
yum search php-
To know more about the modules that you require, including the below-mentioned command. You need to replace NameOfTheModule with the name of the module that you select from the screen.
yum info NameOfTheModule
Most probably, you will require two modules: php-mcrypt and php-mbstring. Install them with the below mentioned commands:
yum -y install php-mcrypt.x86_64
yum -y install php-mbstring.x86_64
You will be able to install other modules in a similar manner.
To get the stack functioning, you need to set the Apache and MySQL to run automatically when the cloud boots as PHP will run automatically with the help of Apache.
chkconfig httpd on
chkconfig mysqld on
Restart the Apache web server to apply all the changes into effect
service httpd restart
Finally, you have installed a LAMP stack onto your HostingRaja Cloud.