Configuring a Centos 7 LAMP Server

Find an article
Nov 10
Published by in · Leave your thoughts
( words)
Warning! There was an error loading some of the images for this post.

Recently I had to deploy a number of new Centos 7 virtual private servers using VMware vSphere. This guide describes how to configure a LAMP setup on a new Centos 7 box.

Network configuration

This part of the guide is more for my own reference, however if you need to manually configure the network settings on your new VPS then here’s how I went about doing it:

  1. Open the network configuration:vi /etc/sysconfig/network-scripts/ifcfg-ens160
  2. Replace the contents of the file with the below. You will likely need to adjust the IPADDR and GATEWAY properties.
    TYPE=Ethernet
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=ens160
    UUID=5e108436-fe9a-4df2-bad4-482f271a26f4
    DEVICE=ens160
    ONBOOT=yes
    IPADDR=192.168.99.112
    PREFIX=24
    GATEWAY=192.168.99.254
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    IPV6_PRIVACY=no
    DNS1=8.8.8.8
    DNS2=8.8.4.4
    NN_CONTROLLED=no
  3. Once saved, reboot the server to load the new network configuration.reboot

LAMP Setup

  1. Install Apache.
    yum update && yum -y install httpd net-tools wget
    firewall-cmd --permanent --zone=public --add-service=http
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --reload
  2. Install MySQL.
    wget http://repo.mysql.com/mysql-community-release-el-5.noarch.rpm
    rpm -vh mysql-community-release-el7-5.noarch.rpm
    yum -y install mysql-server

    Add MySQL to the firewall:

    firewall-cmd --permanent --zone=public --add-service=mysql && firewall-cmd --reload

    Start the MySQL service:

    systemctl start mysqld

    Configure the MySQL server:

    mysql_secure_installation

  3. Install PHP 5.5.
    Start by adding the EPL and remi repositories:

    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

    Enable the PHP 5.5 remi repository by setting [remi] and [remi-php55] to 1:
    vim /etc/yum.repos.d/remi.repo

    Now install PHP via the package manager – this will default to PHP 5.5 after the above change:

    yum install php

    Restart Apache, this will automagically load the new PHP installation:

    systemctl restart httpd.service

Installing Ioncube under SELinux

I also struggled to install Ioncube under the constraints of SELinux. Unwilling to turn off SELinux, here’s how I managed to install ioncube:yum install policycoreutils policycoreutils-devel checkpolicy

I then followed this guide: http://cuteshift.com/57/install-ioncube-loader-while-selinux-enabled/

After following the guide I was then able to install Ioncube using the provided wizard loader, found here: https://www.ioncube.com/loader-wizard/loader-wizard.zip

Leave a Reply

Your email address will not be published.