LAMP stands for linux apache mysql and php
First make sure you update your cent os machine
yum update -y
Once it is done
Installing the dependencies packages
we will install all the dependencies needed for the php as it is a long command you can simply copy and paste the command below in your terminal
yum -y install nano zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
Installing Apache and MySQL
Apache is a web server application used mainly in unix like linux platform.
MySQL is the database management free open source popular around the world due to its high stability ease of use and portable used in differnet platform of OS.
Execute the command below to install these.
yum -y install httpd mysql mysql-server
Once successfull done we will start the services as given below
chkconfig httpd on
chkconfig mysqld on
service httpd start
service mysqld start
We need to setup the root password for mysql
mysql_secure_instrallation or /usr/bin/mysql_secure_installation
Because we do not have a password for the root account so you press Enter to skip.
Enter current password for root (enter for none):
Select Yes to set the password for the MySQL root account.
Set root password? [Y/n] y
Enter and confirm your password, remove the anonymous user, select Yes
Remove anonymous users? [Y/n] y
Allow remote login to MySQL as root account, select No.
Disallow root login remotely? [Y/n] n
Delete the test database, select Yes
Remove test database and access to it? [Y/n] y
Reload privilege tables, select Yes
Reload privilege tables now? [Y/n] y
To Turn off SELinux
SELinux is a security feature advanced for Linux operating system, when installing the system you need to turn off this feature to get the process done smoothly, after successful you can turn on back if you want.
vi /etc/selinux/config
Change the file content :
SELINUX=disabled
ESC and :wq to write and change the file name
Configuring the Firewall
We do not want to turn off the firewall because it’s quite important, so you need to add rules to allow port 80 for HTTP and port 443 for HTTPS.
In the Centos OS, you can configure firewall by editing files iptables
vi /etc/sysconfig/iptables
Press Enter to create a new line after the line of port 22, copy the following two commands and right click on the window to the Paste command.
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT
ESC and :wq to write and change the file name and quit.
Starting the iptables
chkconfig iptables on
Install PHP and its packages
yum -y install php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-soap
Once done restart the apache
service httpd restart