NOTE: This guide is outdated and uses CentOS 6 which is EOL and unsupported. It's highly recommended to use CentOS 8 Stream or even better, AlmaLinux 8 or RockyLinux 8 which are continuations of CentOS.

This brief guide will show you how to successfully install a LAMP stack (Linux, Apache, MySQL, PhpMyAdmin) on CentOS 6 with MySQL 5.5 and PHP 5.6. First update all of your current system packages and install some prerequisites.

yum update -y
yum install -y zip unzip wget nano

Install and start Apache.

yum install -y httpd
service httpd start

Now go to your web browser and navigate to http://your_server_ip, if all if well, it will connect with an apache test page. If it times out, you may need to add proper firewall rules to allow port 80 access, try using the command below.

iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
service iptables save

Now we can install the MySQL server and PHP. To install the newest versions we will be using the webtatic RPM.

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

Now lets install both and remove the old MySQL libs:

yum remove mysql-libs* -y
yum install -y mysql55w-server
yum install -y php56w php56w-mbstring php56w-mysql php56w-sqlite php56w-gd php56w-xml php56w-cli


Now start MySQL and run the secure installation, with this you can set a root password and change a few options.

service mysqld start
/usr/bin/mysql_secure_installation


You should get the following output:

Enter current password for root (enter for none): **Press enter here then enter in your desired root password and press enter again**
Remove anonymous users? [Y/n] y
Disable root lo gin remotely? [Y/n] y
Remove test database and access to it? [Y/n] yReload privilege tables now? [Y/n]

Now we need to edit the httpd.conf to change "AllowOverride" option for our public web directory. This is optional but may help with scripts that use an .htaccess file. We will use nano to edit the file.

nano /etc/httpd/conf/httpd.conf

Now press CTRL + W to search the file, search for "AllowOverride", when it finds the first result, press CTRL + W again and search "AllowOverride" one more time. This will bring you to the /var/www/html section. Now change "AllowOverride None" to "AllowOverride All"

Now restart Apache to finalize the changes.

service httpd restart

Lets go ahead and make both run at boot.

chkconfig httpd on
chkconfig mysqld on

Lets setup PhpMyAdmin now. This can be done easily with a few commands.

wget https://files.phpmyadmin.net/phpMyAdmin/4.5.2/phpMyAdmin-4.5.2-english.zip
unzip php*
rm -rf phpMyAdmin-4.5.2-english.zip
mv php* phpmyadmin
mv phpmyadmin /var/www/html/phpmyadmin
mv /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php

We also recommend disabling SELinux as it may cause permissions related issues with Apache. Run the following command:

setenforce 0

Then edit the SELinux configuration file and change "SELINUX=permissive" to "SELINUX=disabled" and save the changes.

nano /etc/selinux/config

All done!

?האם התשובה שקיבלתם הייתה מועילה 17 משתמשים שמצאו מאמר זה מועיל (687 הצבעות)