We're Hiring!
Take the next step in your career and work on diverse technology projects with cross-functional teams.
Mountain West Farm Bureau Insurance
office workers empowered by business technology solutions

How to Install a LAMP Stack on Cent OS or Red Hat Cloud Servers

Last updated:
No items found.

If you’re running an open source server in the gBlock cloud, you are probably already familiar with a LAMP stack. If you haven’t used one before, LAMP is a web application and deployment stack that is very common and simple to install and use on your virtual machines. This blog will walk you through a LAMP installation so you can get development cranking.

What is LAMP stack?

LAMP Stack logo

LAMP stands for Linux, Apache Web server, MySQL database, and Perl, Python, or PHP, all common tools for administrators and developers. As LAMP has become more and more common, software extensions have been created that facilitate these different tools working together.

As far as how they do work together, a user accessing your Apache web server will call up your applications and files, which are located on attached storage. The web server delivers code that is created in Perl/Python/PHP, which in turn references the MySQL database.


Installing a LAMP Stack on CentOS or Red Hat

OK, ready to get started? First step is to grab the packages and configure your quotas.

1) Add packages with

# yum install wget bzip2 unzip zip nmap openssl fileutils ncftp gcc gcc-c++

Next, if you have not already, enable quotas on your server. In Red Hat, while logged in as root, use a text editor to edit the /etc/fstab file. Add the usrquota and/or grpqouta options to the file systems that require quotas.

Run quotacheck to create a table of quota-enabled file systems with current disk usage. For example,

# quotacheck –cug /home

will create quota files in the /home directory, with –c creating them for each file system, -u specifying user quotas, and –g specifying group quotas.

 You can also type edquota and a user name to launch your default editor and edit the quotas for an individual user directly. This will set disk limits. Do this for each user that requires a quota. The system will display the used blocks, as well as soft, hard, and inodes. Hard block limits are the maximum amount of disk space allotted to that user, while soft limits allow the user to go above that limit for a period of time. Set this grace period by entering

# edquota –t

2) Install MySQL

 # yum install mysql-devel mysql-server  #chkconfig --level 2345 mysqld on  #/etc/init.d/mysqld start

Check that networking is enabled. Run:

 # netstat -tap | grep mysql

It should show a line like this:

 [root@server1 named]# netstat -tap | grep mysql  tcp        0      0 *:mysql              *:*              LISTEN      2470/mysqld

If it does not, edit /etc/my.cnf and comment out the option skip-networking:

 # vi /etc/my.cnf  #skip-networking  #/etc/init.d/mysqld restart

Set a password using one of these methods:

Create additional database users:

 mysql> CREATE USER 'name'@'localhost' IDENTIFIED BY 'some_pass';  mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'  ->     WITH GRANT OPTION;

Alternatively you can run:


3) Install Apache2 with PHP

To get started installing Apache2 with PHP, enter:

 # yum install httpd mod_ssl php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel

Edit httpd.conf:

 # vi /etc/httpd/conf/httpd.conf

Change directory index to include php pages:

 [...]  DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl  [...]

Start Apache:

 # chkconfig httpd on  #/etc/init.d/httpd start

Edit httpd.conf to hide the Apache version number:

# vi /etc/httpd/conf/httpd.conf  ServerSignature off

Edit sysctl.conf to enable SYN cookies protection:

# Enable TCP SYN Cookie Protection net.ipv4.tcp_syncookies = 1

Restart the network server:

# service network restart

Configure Mod_Evasive. Mod_Evasive offers Apache protection against DDoS.

# cd /root # wget http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz # tar zxf mode_evasive-1.10.1.tar.gz # cd mod_evasive # /usr/sbin/apxs -cia mod_evasive20.c  # vi /etc/httpd/conf/httpd.conf  DOSHashTableSize 3097 DOSPageCount 2 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10

Add vsftpd (If necessary). This enables secure FTP access to your web server.

 #yum install vsftpd  #vi /etc/vsftpd/vsftpd.conf

Disable anonymous logins:

# vi /etc/vsftpd/vsftpd.conf

in the 12th line edit

Save vsftpd.conf file and restart the daemon:

# service vsftpd restart

Start VSFTP:

 #chkconfig –levels 235 vsftpd on  #service vsftpd start

With this default configuration, the users' FTP directory will be set to their home directory.

4) Set up PHPMyAdmin

  1. Download from: http://www.phpmyadmin.net/home_page/downloads.php
    Note that phpMyAdmin3.x.x requires PHP 5.2
  2. Extract and rename the directory to phpMyAdmin, place in html directory
  3. Copy config.sample.inc.php to config.inc.php
  4. Open it and change the auth type to http


You should now have all the tools you need for a fully loaded LAMP stack. Happy developing!

Recent Blog Posts

lunavi logo alternate white and yellow
FinOps: The Secret Key to Cloud Cost Control?

The term 'FinOps' is being heard more frequently as organizations seek to optimize their cloud endeavors. As controlling cloud spend is typically at the top of the list for refinement, let's explore how FinOps isn't just a new buzzword in the tech community.

Learn more
lunavi logo alternate white and yellow
Navigating What’s Next with Top Announcements from Microsoft Build

Microsoft announced major developments at its premiere event of the year, Microsoft Build. Author and Lunavi Solution Consultant, Alec Harrison was there in-person to gain first-hand insight on these announcements and what they could mean for not only the future of Lunavi, but for you and your organization!

Learn more
lunavi logo alternate white and yellow
Using Azure AI and Logic Apps to Reverse Engineer SMS Search Engines

There used to be entire companies providing SMS answering services. In 2006, one such company was valued at $6 million. Come along as we build the same system in Azure, almost for free, in 2 hours or less!

Learn more