Wednesday, December 21, 2016

How to install Apache, MySQL, and PHP 5.6 on CentOS 6 (LAMP)

If you find it tiresome like me to install LAMP on CentOS 6 but with PHP 5.6 then this step-by-step guide will walk you through to get up and running within 15 minutes.

Install MySQL
  • Update the system first.
sudo yum update
  • Download and add the repository then update again. 
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
  • Start MySQL
sudo yum install mysql-server
sudo systemctl start mysqld
  •  Make MySQL secure
sudo mysql_secure_installation
Install Apache

  •  Use the following commands to install and start Apache
sudo yum -y install httpd
sudo /etc/init.d/httpd start
  • Turn on external access of http (Port 80) and https (Port 443)
sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT 
sudo service iptables save
Install PHP 5.6

  • Add EPEL and REMI repo 
rpm -Uvh remi-release-6*.rpm epel-release-latest-6.noarch.rpm
  • Now you need to enable the repo. Go to /etc/yum.repos.d and open remi.repo in text editor (i.e. vi)
cd /etc/yum.repos.d
vi remi.repo
  • Find the following sections and set enabled=1 
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
# WARNING: If you enable this repository, you must also enable "remi"
  • Finally install the PHP and restart httpd!
sudo yum install php php-gd php-mysql php-mcrypt
sudo /etc/init.d/httpd restart 
At this point, you should have LAMP installed with PHP 5.6 and it's basic components.

No comments:

Post a Comment