How to install LAMP Server on Fedora 27

Hello everyone, welcome to Fedora Tutorial. Today we are going to learn how to install LAMP Server on Fedora 27 Server edition. LAMP (Linux Apache MySQL and PHP) is a powerful software combination that will turn your Fedora 27 into a powerful web server. You can then build or run many web applications on top of Fedora 27. If you are running Fedora 26, you can read our post How to install LAMP Server on Fedora 26. It’s pretty similar to that tutorial. You may browse some other tutorial of Fedora 27.

Before we install LAMP Server on Fedora 27, please make sure you have the following items 

  • root access to the server
  • Active internet connection
  • Basic understanding of the Linux command line

Steps to Install LAMP Server on Fedora 27

Step 1. Install Fedora 27 Server

I assume you have a running Fedora 27 Server edition, or Workstation edition prior to the LAMP installation. Please read the Fedora 27 Server Installation Guide first. 

Step 2. Install Apache Web Server

Log in to Fedora 27 Server via SSH and then paste this command to install Apache. Please note that all of the commands are executed by root user, or normal user with sudo privileges.

su
dnf install httpd

Output:

[root@localhost ~]# dnf install httpd
Last metadata expiration check: 0:58:42 ago on Wed 18 Oct 2017 11:58:41 AM WIB.
Dependencies resolved.
======================================================================================================================
 Package                         Arch                Version                       Repository                    Size
======================================================================================================================
Installing:
 httpd                           x86_64              2.4.28-1.fc27                 updates-testing              1.3 M
Installing dependencies:
 apr                             x86_64              1.6.2-3.fc27                  fedora                       121 k
 apr-util                        x86_64              1.6.0-1.fc27                  fedora                       102 k
 fedora-logos-httpd              noarch              26.0.1-3.fc27                 fedora                        33 k
 httpd-filesystem                noarch              2.4.28-1.fc27                 updates-testing               29 k
 httpd-tools                     x86_64              2.4.28-1.fc27                 updates-testing               93 k
 mod_http2                       x86_64              1.10.10-2.fc27                fedora                       151 k

Transaction Summary
======================================================================================================================
Install  7 Packages

Total download size: 1.8 M
Installed size: 4.9 M
Is this ok [y/N]:

Now start and enable Apache 

systemctl enable httpd
systemctl start httpd

Modify Firewall to Allow http and https access to the server

firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent

Now reload firewall configuration

firewall-cmd --reload

Open a web browser and type the Server IP address to test the web server. Make sure you get the following output

install LAMP Server on Fedora 27

At this point, our Apache web server is up and running. Move to the next step.

Step 3. Install and Configure MariaDB

To install MariaDB Server on Fedora 27, use the following command

dnf install mariadb-server

Start and Enable MariaDB Service

systemctl enable mariadb
systemctl start mariadb

Secure MariaDB Installation

Now we need to secure the MariaDB installation. Use the following command instead

mysql_secure_installation

You will be asked to change the current root password (none by default). 

Output example:

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, 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 MariaDB
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 MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] n
 ... skipping.

By default, MariaDB 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 MariaDB
installation should now be secure.

Thanks for using MariaDB!

Configure firewall to allow MariaDB connection

firewall-cmd --add-service=mysql --permanent
firewall-cmd --reload

Done. At this point, MariaDB Server is up and running. 

Step 4. Install PHP

Now, we need to install PHP and some additional modules on Fedora 27. Use the following command 

dnf install php php-mbstring php-pear

Output:

[root@localhost ~]# dnf install php php-mbstring php-pear
Last metadata expiration check: 1:17:57 ago on Wed 18 Oct 2017 11:58:41 AM WIB.
Dependencies resolved.
======================================================================================================================
 Package                       Arch                Version                         Repository                    Size
======================================================================================================================
Installing:
 php                           x86_64              7.1.11~RC1-1.fc27               updates-testing              2.8 M
 php-mbstring                  x86_64              7.1.11~RC1-1.fc27               updates-testing              593 k
 php-pear                      noarch              1:1.10.5-3.fc27                 fedora                       356 k
Installing dependencies:
 libxslt                       x86_64              1.1.29-4.fc27                   fedora                       252 k
 nginx-filesystem              noarch              1:1.12.1-1.fc27                 fedora                        20 k
 php-cli                       x86_64              7.1.11~RC1-1.fc27               updates-testing              4.2 M
 php-common                    x86_64              7.1.11~RC1-1.fc27               updates-testing              1.0 M
 php-fpm                       x86_64              7.1.11~RC1-1.fc27               updates-testing              1.5 M
 php-json                      x86_64              7.1.11~RC1-1.fc27               updates-testing               72 k
 php-process                   x86_64              7.1.11~RC1-1.fc27               updates-testing               91 k
 php-xml                       x86_64              7.1.11~RC1-1.fc27               updates-testing              225 k

Transaction Summary
======================================================================================================================
Install  11 Packages

Total download size: 11 M
Installed size: 41 M
Is this ok [y/N]:

That’s it. Now we have PHP installed. 

Conclusion

Installing LAMP Server on Fedora 27 is pretty easy. In few minutes, we can have a powerful web server running on our Fedora 27 Server. 

Thanks for reading this How to install LAMP Server on Fedora 27. Please consider share this post if you think its useful. Cheers

7 Comments

  1. Very nice tutorial, well explained with example results. The apache web server loads exactly as planned, but when I tried loading a test.php file with the basic

  2. The problem your seeing is with the change for how Apache works with PHP in Fedora 27.

    You can read about the changes here: https://blog.remirepo.net/post/2017/11/17/Fedora-27-changes-in-http-and-php

    And while that explains it, the blog post leaves out a step or two – those can be read here: https://www.server-world.info/en/note?os=Fedora_26&p=httpd&f=13

    There may be more than that though. I’m in the middle of trying to get WordPress running on a Fedora 27 server and I’m having trouble that I can’t figure out. It may be related to FPM but I’m not really sure.

2 Trackbacks / Pingbacks

  1. Complete Guide to install Nextcloud on Fedora 27 Server
  2. How to install LAMP Server on Fedora 28 | Manjaro dot site

Leave a Reply

Your email address will not be published.


*