• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

Building a LAMP Stack on CentOS 6

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
9
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Step 1: Downloading/installing Apache 2.4
  2. Step 2: Downloading/installing MySQL
    1. Step 3: Downloading/installing PHP
  3. Step 4: Starting/stopping the LAMP stack
  4. Conclusion
  5. Want to contribute?


Compiling your own LAMP stack allows you to use the latest versions of Apache, MySQL, and PHP. Using the CentOS 6 package manager, you receive Apache 2.2, MySQL 5.1, and PHP 5.3. The package manager only installs security updates from the CentOS team.

As a system administrator, you know that keeping software updated is key. And with your webserver facing the internet, you need to make sure the web server software is updated to prevent vulnerabilities.

This article teaches you how to compile your own LAMP stack. Each of the commands will be explained using the following format.

# Commands will be listed here

An explanation of the commands will be stated here.

Step 1: Downloading/installing Apache 2.4

For this article, we will be using a preset mirror; but if you’d like, you may use another mirror from the Apache mirror page with a call from your VPS.

curl -q -s apache.org/dyn/closer.cgi > /tmp/closer
sed -e 151b -e '$!d' /tmp/closer

The curl command sends an HTTP request to the URL, and retrieves its contents. We redirect the output to /tmp/closer, and then the sed command cuts it down to something you can read.

You will see a mirror link contained within the href="" section. Just replace any links specified in this article with that mirror.

Download the source to Apache 2.4.

cd /usr/src && wget http://apache.mirrors.ionfish.org/httpd/httpd-2.4.17.tar.gz && tar xvf httpd-2.4.17.tar.gz

The first part of this command will change our current directory to /usr/src, then the wget section will download the source. The last part of this command unzips the source.

Since Apache requires APR and APR-util, do the following:

wget http://apache.mirrors.ionfish.org/apr/apr-1.5.2.tar.gz && tar xvf apr-1.5.2.tar.gz && mv apr-1.5.2 httpd-2.4.17/srclib/apr
wget http://apache.mirrors.ionfish.org/apr/apr-util-1.5.4.tar.gz && tar xvf apr-util-1.5.4.tar.gz && mv apr-util-1.5.4 httpd-2.4.17/srclib/apr-util

These commands will download the sources for APR and APR-util, and unzip them. Then, we move the source into Apache’s build directory so that Apache will build properly.

As we need a proper C compiler, we’ll need to install one using the package manager.

yum groupinstall 'Development Tools' -y
yum install gcc-c++ -y
yum install pcre-devel -y
yum install bison bison-devel -y
yum install ncurses-devel -y
yum install perl-devel -y

As I’ve mentioned above, we still need to obtain Apache’s prerequisites, so we’ll be installing them using the package manager.

Great job! Now, it’s time to configure and build Apache.

cd httpd-2.4.17 && ./configure

The cd httpd-2.4.17 part changes our current working directory to httpd-2.4.17/. When we run ./configure, we’re configuring our system to build Apache.

Allow the system to configure the source for installation, it shouldn’t take too long. Once complete, execute:

make && make install
cp support/apachectl /usr/sbin
chmod 755 /usr/sbin/apachectl

The make section of these commands will build the software. When we run make install, we effectively install Apache onto our system. Now, we need to copy it to the secure bin directory (cp signifies copy). Finally, we’ll give it permissions to execute with chmod 755.

Congratulations, you’ve successfully installed Apache 2.4!

Step 2: Downloading/installing MySQL

Now, let’s install MySQL, a database used by many web applications. Because MySQL already provides the latest version in the form of an RPM, it’s easier to use their pre-built installation file then configuring it. We will use the official MySQL repository.

cd /usr/src && wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm && rpm -i mysql57-community-release-el6-7.noarch.rpm
yum install mysql-community-server -y

The first command is where we download the RPM file to enable the MySQL repository on our system. Then, rpm -i installs the RPM file. Finally, we’ll install MySQL from the official MySQL repository.

Step 3: Downloading/installing PHP

PHP has some dependencies that we need to install, so let’s get to that first.

yum install -y libxml2-devel libcurl-devel libmcrypt libmcrypt-devel

We’re using the package manager once more – but this time, we’re installing some components to allow PHP applications to run properly.

Download the source for PHP, which is done by executing the following commands:

wget http://docs.php.net/distributions/php-5.6.15.tar.gz && tar xvf php-5.6.15.tar.gz
cd php-5.6.15
./configure --with-pear=/usr/lib/pear --enable-libxml --with-pdo-mysql --with-mysqli --with-mysql --enable-mbstring --with-mcrypt --with-apxs2=/usr/local/apache2/bin/apxs --enable-maintainer-zts --with-curl=/lib
make && make install

The first part, wget, is where we download the source to PHP 5.6.15. Then, we change our working directory to php-5.6.15. Finally, we configure PHP with the features required to run various web applications, such as e-commerce websites.

Do note, if you receive a message that contains “/path/to/perl”, you’ll need to edit the file /usr/local/apache2/bin/apxs.

nano /usr/local/apache2/bin/apxs

Change the first line to:

#!/usr/bin/perl -w

Step 4: Starting/stopping the LAMP stack

As we’ve built Apache from scratch, it does not include a pre-built service. We will need to setup the init script ourselves.

cd /usr/src && wget https://gist.githubusercontent.com/anonymous/62b0b788f86e7773e901/raw/6bcc88f9354f7139916272ac7a4eb998b1f26fdd/httpd-init
mv httpd-init /etc/init.d/httpd
chmod 755 /etc/init.d/httpd

The first part, where we cd, changes our working directory to the directory where we build/compile software. Then, with &&, we execute anything after it as well, which in this case, downloads the service file for Apache. Finally, we give permission for it to be executed with the chmod command.

Done, and done!

Now, let’s start Apache + MySQL + PHP:

service httpd start
service mysqld start

With the service commands, we can manage the status of services. In this case, we’ve started the services httpd and mysqld.

PHP is started with Apache, it doesn’t get started through a service.

Conclusion

In this article, we covered how to setup a LAMP stack from scratch using updated versions of Apache/PHP/MySQL. Although it requires more administration to manage, this technique is useful when we want a newer stack than what the operating system vendor offers.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install RainLoop Webmail on CentOS 7

Next Post

How To Use Mosh on CentOS for Remote Server Administration

Next Post

How To Use Mosh on CentOS for Remote Server Administration

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet