How to Install LAMP (Linux, Apache, MySQL, PHP) on Fedora



LAMP is the most common configuration used in web server and it stands for Linux, Apache, MySQL, and PHP. This tutorial describes how to install LAMP stack on Fedora. The Linux part of the stack is already done as the virtual private server is up and running Fedora. Here you will see the installation of Apache, PHP and MySQL.

Initial Set Up


Before getting to installation of any LAMP software, just make sure that all of the repositories are up to date:

yum update


Installing Apache


Apache is free software that is distributed by Apache Software Foundation and is supposed to be the most popular open source software that runs over 50% of web servers in the world.

sudo yum install httpd

Once apche is installed, you can start it running on your VPS:

sudo service httpd start

To verify, you can point your browser to the server IP address and check. If it displays the default page of Fedora, then it is correct. The page should look like this:


You can get your IP address using the following command:

ifconfig eth0 | grep inet | awk '{ print $2 }'


Installing MySQL


Let’s start with MySQL installation process. MySQL database management system is used for organizing and retrieving data.

Open your terminal and enter the following commands:

sudo yum install mysql mysql-server

sudo service mysqld start

In case if the system displays any messages, press enter. You will be asked to set a root password while the program is installing. In case if you missed the chance, you can set it later from within the MySQL shell.

Next step is to run the secure install script to clean up.

sudo /usr/bin/mysql_secure_installation

While the secure install scrip is running, the system will ask for your MySQL root password. In that case, just hit enter as MySQL root password has not been set.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

When system prompts for setting the root password, type ‘Y’ and enter your new MySQL root password. Below you can see a snapshot of the output screen, while the script is running.

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] y                                             
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success! 

By default, MySQL comes with a database named 'test' that anyone can access.  This is also intended only for testing, and should be removed before moving into a production environment.

Remove test database and access to it? [Y/n] y 

- Dropping test database... 
... Success! 

- Removing privileges on test database... 
... Success!

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] y 
... Success! 

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL installation should now be secure.

Thanks for using MySQL!

MySQL is installed.

Installing PHP


PHP is a programming language for building dynamic web pages.

For the installation of PHP, open the terminal and type in the following command:

sudo yum install php php-mysql

In order to add various useful PHP libraries and modules onto your server, follow the steps mentioned below:

Get the list of libraries available by typing the command:

yum search php-

You will get the output similar to this:

php-fpdf-doc.noarch : Documentation for php-fpdf

php-libvirt-doc.noarch : Document of php-libvirt

php-pear-Auth-radius.noarch : RADIUS support for php-pear-Auth

php-pear-Auth-samba.noarch : Samba support for php-pear-Auth

ice-php-devel.i686 : PHP tools for developping Ice applications

ice-php-devel.x86_64 : PHP tools for developping Ice applications

perl-PHP-Serialization.noarch : Converts between PHP's serialize() output and
                              : the equivalent Perl structure

php-IDNA_Convert.noarch : Provides conversion of internationalized strings to

                        : UTF8

php-Kohana.noarch : The Swift PHP Framework

php-LightweightPicasaAPI.noarch : A lightweight API for Picasa in PHP

php-PHPMailer.noarch : PHP email transport class with a lot of features

php-Smarty.noarch : Template/Presentation Framework for PHP

php-ZendFramework.noarch : Leading open-source PHP framework

php-ZendFramework-Auth-Adapter-Ldap.noarch : Zend Framework LDAP

                                       : Authentication Adapter

php-ZendFramework-Cache-Backend-Apc.noarch : Zend Framework APC cache backend

You can view more details about the module by typing the command:

yum info name_of_the_module

Now, install the module using:

sudo yum install name_of_the_module

If you need to install multiple libraries, you can do that by separating each module with a space.

Set the processes to run automatically while the server boots:

sudo chkconfig httpd on
sudo chkconfig mysqld on


Verify and Access the Page on your Server


Now that the LAMP stack is completely installed on your system, you may have to verify it by creating a simple php info page.

For that, you need to create a new blank file and paste the following code.

sudo nano /var/www/html/info.php

After saving the file, go ahead and restart apache in order to bring in all your changes.

sudo service httpd restart

Visit your php info page by going to your IP address. It should look similar to this:



Now you are officially done with the installation of LAMP stack on Fedora.


support2 has written 111 articles

Leave a Reply