How to Install LAMP Stack on Fedora 27

A "LAMP" stack is a group of free softwares that is typically installed together to enable a server to host dynamic websites and web application. This term is actually an acronym which represents the Linux operating system, with the Apache web server, MySQL, and PHP. Here, the site data is stored in a MySQL database, and dynamic content is processed by PHP.

Fedora 27 is our latest free, leading-edge operating system with greatest GNOME desktop environment. In this article, I'll explain on how to install a LAMP stack with WordPress on a Fedora 27.

Install Apache

All the latest version of Apache, Mysql and PHP is present in the server repository itself.  So we can use the simple dnf command to install all packages without any third party repository. You can just install the Apache by running this command below:

#dnf install httpd

Make sure to enable and start the service.

# systemctl enable httpd.service
 Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/httpd.service.
 # systemctl start httpd.service
 # systemctl status httpd.service
 ● httpd.service - The Apache HTTP Server
 Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
 Active: active (running) since Wed 2017-11-29 04:20:06 UTC; 6s ago
 Docs: man:httpd.service(8)
 Main PID: 9498 (httpd)
 Status: "Processing requests..."
 Tasks: 213 (limit: 4915)
 CGroup: /system.slice/httpd.service
 ├─9498 /usr/sbin/httpd -DFOREGROUND
 ├─9499 /usr/sbin/httpd -DFOREGROUND
 ├─9500 /usr/sbin/httpd -DFOREGROUND
 ├─9501 /usr/sbin/httpd -DFOREGROUND
 └─9502 /usr/sbin/httpd -DFOREGROUND

Now we can confirm the Apache version installed and test it's working by accessing the server IP in the browser, just like this >>http://Server IP or hostname/

# httpd -V
 Server version: Apache/2.4.29 (Fedora)
 Server built: Oct 25 2017 12:34:45
 Server's Module Magic Number: 20120211:68
 Server loaded: APR 1.6.3, APR-UTIL 1.6.1
 Compiled using: APR 1.6.2, APR-UTIL 1.6.0
 Architecture: 64-bit
 Server MPM: event
 threaded: yes (fixed thread count)
 forked: yes (variable process count)

Install MariaDB

Secondly, we need to install our Database server. You can install the latest version of it by running the following command:

# dnf install mariadb-server
 # mysql -V
 mysql Ver 15.1 Distrib 10.2.9-MariaDB, for Linux (x86_64) using readline 5.1

Start/enable MariaDB service and check its status.

# systemctl start mariadb.service
# systemctl enable mariadb.service
 Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/mariadb.service.
# systemctl status mariadb.service
 ● mariadb.service - MariaDB 10.2 database server
 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
 Active: active (running) since Wed 2017-11-29 04:26:32 UTC; 15s ago
 Main PID: 12371 (mysqld)
 Status: "Taking your SQL requests now..."
 Tasks: 43 (limit: 4915)
 CGroup: /system.slice/mariadb.service
 └─12371 /usr/libexec/mysqld --basedir=/usr

Next, you will need to secure your database server. You can run the following command to secure MariaDB database and set root password:

# mysql_secure_installation

Install PHP

To install latest PHP and some of its important modules use the following command from the terminal:

# dnf install php php-common
# dnf install php php-common php-mysqlnd php-gd php-imap php-xml php-cli php-opcache php-mbstring
# systemctl restart httpd

You need to restart Apache to make these changes effective. Now you can create a php info page under the domain document root to confirm its version.

# cd /var/www/html
#echo "<?php phpinfo(); ?>" >> info.php

You can browse the URL >>http://ServerIP/info.php to confirm it's working.

PHP installation information

We've successfully completed with the installation of LAMP stack on Fedora 27. Now, it's time to set up our WordPress blog. Let's install WordPress with the steps below:

Install WordPress

You can download the latest WordPress download from their Official Website and extract it to the document root /var/www/html to install it.

# dnf install wget
# wget
# tar -xvf latest.tar.gz -C /var/www/html/

Create MariaDB/MySQL Database for WordPress

We’ll need to create a database and user for our WordPress installation, to do so, run the following command:

mysql -u root -p
 Enter password:
 MariaDB [(none)]> CREATE USER wpuser@localhost IDENTIFIED BY "password";
 Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE wp_database;
 Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> GRANT ALL ON wp_database.* TO wpuser@localhost;
 Query OK, 0 rows affected (0.00 sec)

 Query OK, 0 rows affected (0.00 sec)

We've connected to the MySQL shell and created a database named "wp_database" with a user "wpuser" for the WordPress installation.

Now, you need to create the wp-config.php from the template wp-config-sample.php file and modify the MySQL settings with the one we created to start with our installation.

#cd /var/www/html/wordpress/
#cp wp-config-sample.php wp-config.php

I've modified the file settings with my created database details.

// ** MySQL settings - You can get this info from your web host ** //
 /** The name of the database for WordPress */
 define('DB_NAME', 'wp_database');

/** MySQL database username */
 define('DB_USER', 'wpuser');

/** MySQL database password */
 define('DB_PASSWORD', 'password');

/** MySQL hostname */
 define('DB_HOST', 'localhost');

Now you can browse the following URL >> http://Server IP or hostname/wordpress/ to complete our installation.

WordPress Configuration

You can set your Admin credentials and Site title to complete the installation stage.

WordPress Installation

Now you can access your admin area browsing the URL >>http://Server IP/wordpress/wp-login.php with the credentials created.

Wordpress Dashboard

That's all! you have installed WordPress Successfully on your Fedora 27 server. Now you can go ahead and customize your WordPress Blog as per your requirements.

Wrapping up

WordPress is an opensource software, which you can use to create your beautiful website, blog, or app.  And there are thousands of plugins and themes available for this to transform your website into the one in your imagination. I hope this article will help you to build your own WordPress Blog in your latest Fedora 27.

Saheetha Shameer 12:05 am


Your email address will not be published. Required fields are marked *