LAMP and Fedora 18

I have read a plethora of articles online suggesting what is the right way to install LAMP (Apache Mysql and PHP) on Fedora. Most of them are completing each other and they introduce some details that other won’t. So i thought, what the heck, i have a blog and i have lamp on my fedora. So why shouldn’t i write my own guide? And this is the outcome. This is not a guide for your lamp to host a working public site. It is just something to show you, how you can set a testing server on your pc, so you test your php or any other web development code you want. Commands in bash can be executed either with sudo or with the root account without making any difference. I also use absolute paths of the commands i use in bash, since, in case you use sudo, “/sbin” might not be in your $PATH.

This is my uname -a

Linux localhost.localdomain 3.8.1-201.fc18.x86_64 #1 SMP Thu Feb 28 19:23:08 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

and i ve tested the results of this guide on this and this alone, system. However, since i am using only yum to install packages, i think it is safe to presume that this guide will work the 32bit folks as well for the previous versions of fedora. Hell it might even work for CentOS and other Red Hat minions… I also assume, that you have not installed apache or mysql previously on your system. So

Installing Apache

We install apache with yum:

yum install httpd

we make it start on boot time

/sbin/chkconfig httpd on

and we start it for this session with

/sbin/service httpd start

Now, if everything went well, you can open your browser, and when you go to http://localhost/ you will see something like this:

Test Page for the Apache HTTP Server on Fedora - Mozilla Firefox_003

If not, then something went terribly wrong, and you ll have to ask someone else (not me!) about what happened. The last step would be to open the firewall port for your apache server. If you are doing this for a public site, you should already have your own scheme on this, but if you re just playing around trying to learn in a virtualbox behind a NAT like me, then just type


and tick “http” and “https” if you are going to need it like this:

Firewall Configuration_004

Now you are ready to install mysql :)

Installing Mysql

Using yum again you can install mysql with

yum install mysql mysql-server

make it start at boot time with

/sbin/chkconfig mysqld on

and start it for this session with

/sbin/service mysqld start

Now you should check whether mysql daemon actually runs and then making some security minor adjustments, which are optional but i tend to do every time i install lamp. So, you can check whether mysql daemon runs with

/sbin/service mysqld status

which will probably return something like this:

Redirecting to /bin/systemctl status mysqld.service
mysqld.service - MySQL database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Sun 2013-03-03 15:16:14 EET; 8s ago
Process: 8486 ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 8416 ExecStartPre=/usr/libexec/mysqld-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 8485 (mysqld_safe)
CGroup: name=systemd:/system/mysqld.service
├─8485 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─8643 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/ --s...

If you can see the “active (running)” little thingy, mysql daemon is running, but still we got work to do. Check your mysql installation with

mysqladmin version status

which should return something like this

mysqladmin Ver 8.42 Distrib 5.5.30, for Linux on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Server version 5.5.30
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 1 min 35 sec

Threads: 1 Questions: 2 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.021
Uptime: 95 Threads: 1 Questions: 2 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.021

and if it does, move on to securing your mysql installation running


This is not something that can actually make you safe with a public site, it is just a minor layer of safety that the mysql developers cared to provide for Linux users alone. (Okay maybe Mac users as well, but they don’t count). If you just installed mysql and you haven’t set a password before, just press enter to the first prompt (it actually says it) and after assigning a root password for your mysql database, answer yes to all the prompts.
When you are over, you can use the mysql client to check whether it connects to the database or not with

mysql -h localhost -u root -p

If “mysql>” appears in place of the bash prompt, ready to accept your mysql commands then we can safely presume that almost everything went ok. And i say almost, cause mysql had major bug attacks around December of 2012, so no one can guarantee that even if you do everything right, the damn thing will work. Type “quit” and say bye as well, just to be as polite as mysql is.

Installing php

You can install php the easy way with yum, doing

yum install php php-mysql php-common

and then restart the apache server with

/sbin/service httpd restart

Just so as to check if apache recognizes php, type in bash:

echo "<?php phpinfo(); ?>" > /var/www/html/index.php

and then reload your localhost which you opened to check if apache works (yes i mean go to “http://localhost&#8221; from your browser). You should see something like this:

phpinfo() - Mozilla Firefox_005

If this is the case then you now officialy have LAMP. Your server works, with php and mysql client can connect to your mysql database. If that is all you wanted, stop reading and start playing. Seriously, go away!
But since i have some spare time, and a huge ego, i will go on about what i do to my installation and what you can do provided you want something more than a mere working LAMP. Let’s just do some polishing.


Some php modules

Provided you want to do some more advanced php coding or, in my case, play with drupal, you should also install some php modules like these:

yum install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

They are all optional, and you can have a working LAMP without these, but some of them like pecl, memcache and gd are mandatory if you want to give drupal a shot.


One of the most important tools you will come across in your web dev journey is phpmyadmin. It allows you, to visualize your mysql database and administrate it with point-and-clicks. It is so powerful, that some people (claiming to be web developers) don’t bother learning MySQL. You can install it, again through yum with

yum install phpmyadmin

and restart apache with

/sbin/service httpd restart

Then using your browser, go to “http://localhost/phpmyadmin&#8221; where you will probably get an authentication window like this:

Authentication Required_007

enter “root” and the root’s password, (which you have set with mysql_secure_installation, remember?) and you will log in to something like this:

localhost - localhost | phpMyAdmin 3.5.6 - Mozilla Firefox_008

and that’s PhpMyAdmin. Good luck with it…


Fedora come with “system-config-httpd” in their repos. A little graphical administration tool, that allows you to manage some tasks, without the typing fuss. It’s not much, but before Fedora, i hadn’t see something like this, so i think it was worth mentioning. You can install it with

yum install system-config-httpd

and if you type


you ‘ll get a tiny window with these tabs:

HTTP Server Configuration_009HTTP Server Configuration_010HTTP Server Configuration_011

If you find it useful keep it, otherwise purge it… Hm, sorry, i meant remove it…

Perl and Python

You can install either one or both, so as to they can work with apache with:

yum install perl mod_perl perl-DBD-mysql


yum install MySQL-python


/sbin/service httpd restart

And that’s all folks. If you liked it, please share it, so i can make money through advertisements in the future and become rich enough so as to buy all the gold on earth and send it to the sun surface, so capitalism can fall. If not, i don’t really care…

Tagged , , , , , , ,

One thought on “LAMP and Fedora 18

  1. Imran Ahmad says:

    Great guide dear

Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: