[How-To] Install LAMP Server on Fedora

LAMP (Linux, Apache, MySQL, PHP/Perl) server is a group of open source software used to get Web Servers up and running, Apache as the Web Server, MySQL as the relational database management system and PHP as the object-oriented scripting language. In this quick post we will explain how to install LAMP on Fedora.

Befora anything, make sure that your system is up to date.

# yum update -y

1- Installing Apache Server:

Apache is a free open source software which runs over the most of the world’s web servers, this command will install it.

# yum groupinstall -y web-server

The web-server package will install: httpd, httpd-manual, webalizer, squid , php, mod_perl, mod_python, mod_ssl, … etc

  • Start Apache HTTP server:
# systemctl start httpd.service
  • Autostart Apache HTTP server on boot:
# systemctl enable httpd.service
  • To check that Apache, PHP are working:
# cat /var/www/html/test.php
<?php phpinfo(); ?>

From your brower, open http://localhost/test.php

  • Enable Remote Connection to Apache HTTP Server:

Add the following rule to /etc/sysconfig/iptables file and restarte IPTables

# echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT" >> /etc/sysconfig/iptables
# systemctl restart iptables.service

2- Installing MySQL Database Server:

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases., to install MySQL, open the terminal and type in this command:

# yum groupinstall -y mysql
  • Start MySQL server:
# systemctl start mysqld.service
  • Autostart MySQL server on boot:
# systemctl enable mysqld.service
  • MySQL Secure Installation:
# /usr/bin/mysql_secure_installation

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

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!

Connect to MySQL database

# mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2012, 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

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('your-password') WHERE user='root';
mysql> exit
  • Enable Remote Connection to MySQL Server:

Add the following rule to /etc/sysconfig/iptables file and restarte IPTables

# echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT" >> /etc/sysconfig/iptables
# systemctl restart iptables.service

3- Installing PHPMyAdmin:

PHPMyAdmin is an easy web tool to manage you databases, to install it:

# yum install -y phpMyAdmin

Open your browser on: http://localhost/phpmyadmin

Here, are two simple Bash scripts, one to install LAMP Server and the other to control it:

And we done, now you can host your web application on Fedora.

Tagged: , , , , , , , , ,

Leave a Reply :

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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

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

%d bloggers like this: