This is the second post on Centos 7 setup. In the previous article we hardened ssh and created new users. Today we will install LAMP on Centos 7 and latest PHP 5.6 with all necessary extensions.

1. Install Apache

1
2
sudo yum install httpd
sudo systemctl start httpd.service # start apache

Check that everything works fine, by pointing browser to http://your_server_IP_address/. You should see Apache test page.

2. Enable apache to start on boot

1
sudo systemctl enable httpd.service

3. Install Mariadb (popular MySQL fork)

1
2
3
4
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation # set mysql password and remove test database
sudo systemctl enable mariadb.service

4. Install PHP 5.6

We will get php5.6 from remi repository.

Install EPEL repository

1
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

Install remi repository

1
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Enable remi

1
sudo yum --enablerepo=remi,remi-php56 install php php-common

Install php 5.6, redis and opcache on Centos 7

1
2
3
4
5
6
7
sudo yum --enablerepo=remi,remi-php56 install php-pecl-apcu php-cli php-pear php-pdo php-mysql php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-simplexml php-redis php-opcache php-curl
sudo systemctl restart httpd.service # restart apache
sudo chown -R apache:apache /var/www/html/ # make apache owner of the html folder
sudo /usr/sbin/usermod -a -G apache bob # add bob to apache group, to be able to create and edit files
sudo chmod -R 775 /var/www/ # set 775 permissions to /var/www recursively

Then create file /var/www/html/test.php with <?phpinfo(); ?> and open http://your_server_IP_address/test.php in browser. You should be able to see information about php with all modules installed.

5. Install composer

1
2
3
cd /tmp
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

That’s it LAMP stack is installed! You can now set up Wordpress or Laravel-based website. In the next article we will install NodeJS 4, NPM and PM2 on Centos 7.