Install LAMP on Fedora and Run in 15 minutes – Apache, MySQL, PHP, and phpMyAdmin

Linux Tuxedo

Below are steps to install the LAMP stack on a Fedora Linux server – Apache HTTP Server, MySQL (database software) and PHP (or Perl or Python) in about 15 minutes.

Things to know

  • Commands below are executed as root (or prefixed with sudo).
  • The steps have been tested on Fedora 14, Fedora 15, and Fedora 16 successfully.
  • Instead of localhost for the steps below, you may have to substitute your server’s IP address (e.g.
  • If you are using another Linux distribution (e.g. Ubuntu, OpenSUSE), the install command executions and file locations may differ, but setup will be similar.
  • If you already have the packages installed, your package manager will tell you and you can skip the installation step.
  • Install commands below will install the latest stable releases.

Getting Ready with a Clean Slate (Optional)

If you want to start with a clean install, you can remove existing installations of the components of the LAMP stack first.

# yum erase httpd mysql mysql-server php php-mysql phpmyadmin

Be careful if you do execute this command and find some components are already installed and yum asks you if you want to uninstall them. For example, some KDE distributions install MySQL with KDE packages like Akonadi, so you can leave MySQL there.

Install all Apache Web Server, MySQL, PHP, and phpMyAdmin

With this command, you can install all the packages at once.

# yum install httpd mysql mysql-server php php-mysql phpmyadmin

Apache – Starting and Configuring Apache (HTTPD)

Configure Apache to start automatically (Optional):

# /sbin/chkconfig httpd on

To start the server process immediately:

# /etc/rc.d/init.d/httpd start

Check Apache is running

Open up a browser on your server and go to the web address:


You should see a web page saying that Apache is running assuming your default Apache site (/var/www/html/) is empty.

 Get Started on a Website

If you want to get started with a website in Apache, you can find the root of the web server at /var/www/html/ and configuration files at /etc/httpd/

Other notes

Instructions on how to use iptables or system-config-firewall-tui to ensure port 80 is accessible from remote computers.

MySQL – Starting and Configuring MySQL

Start MySQL first if it isn’t already started. If you skip this step, a common error encountered is Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock” or /tmp/mysql.sock.

# /etc/rc.d/init.d/mysqld start

Some Fedora installations may already have MySQL running for KDE packages like Kontact, Kmail, and Akonadi, so MySQL may already be started.

Check MySQL is running

# mysqladmin version status

Set mysql root password

Go into the mysql command line to set the root password.

mysql -u root

Set the password of the root user in mysql at the mysql prompt. Do not forget to end your mysql command with a semicolon:

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);

If it is successful, this message appears:

Query OK, 0 rows affected (0.00 sec)

Exit the mysql prompt

mysql> quit

PHP – Check PHP works with Apache and MySQL

Create the following file in the Apache default site.

# echo “<?php phpinfo(); ?>” > /var/www/html/index.php

Go the address below. You should see a page describing PHP’s configuration and status:


To see the MySQL section, go to:


If the steps above succeeded, you can delete your test file with:

# rm -f /var/www/html/index.php

Configure server start up (Optional)

To start MySQL and Apache every time the server starts up, execute the following:

# chkconfig –levels 235 httpd on

# chkconfig –levels 235 mysqld on

phpMyAdmin – Configure Apache and phpMyAdmin

If you want to allow phpmyadmin connection from other locations other than localhost, then modify the following file. This setting is not recommended if you want to restrict who can access phpMyAdmin, but is common for server installations.

nano /etc/httpd/conf.d/phpMyAdmin.conf

Comment out these lines in the file:

<Directory /usr/share/phpMyAdmin/> 
order deny,allow 
deny from all 
allow from 
allow from ::1 

So the lines looks like:

#<Directory /usr/share/phpMyAdmin/> 
# order deny,allow 
# deny from all 
# allow from 
# allow from ::1 

Restart Apache:

# /etc/rc.d/init.d/httpd restart

Check everything is working!

Now you are all set Apache, MySQL, and PHP are setup and you have phpmyadmin to help you administer the MySQL server. Access phpmyadmin at http://localhost/phpmyadmin. Use your MySQL root credentials you configured during the MySQL set up to log in. If you can log into the phpmyadmin application, everything works – Congratulations!

Helpful links for installing LAMP

Random thought:

Turn on the LAMP in your life.


By Justin Tung

Servant of the public as a communications and IT jack of all trades. Always willingly to fundraise and volunteer for the greater good.


    1. Hello.
      You can make a folder in desktop where you put your web files:

      mkdir /var/www/html/php
      chmod 775 /var/www/html/php
      ln -s /var/www/html/php /home/{your user name}/Desktop
      chown {your user name} /var/www/html/php

      Then you can put your php files in the created folder and next you will view there at:
      PS: Sorry if I’ve made mistakes, I’m a student and my english isn’t very good.


      1. Hi Louis, thank you x 2 for your comments!
        Good to hear the tutorial works with other versions of Fedora and nice tip about organizing your PHP files for quick access with the symbolic links.


Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: