1080*80 ad

Install WordPress on Fedora 29/28 with Apache

How to Install WordPress on Fedora with Apache: A Complete Guide

Powering over 40% of the web, WordPress is the world’s most popular content management system (CMS). Its flexibility makes it an excellent choice for everything from personal blogs to complex e-commerce sites. For developers and system administrators who prefer a robust, open-source environment, deploying WordPress on a Fedora server provides ultimate control and performance.

This comprehensive guide will walk you through every step of installing WordPress on a Fedora system using the classic and powerful LAMP stack (Linux, Apache, MariaDB, and PHP).

Prerequisites

Before we begin, ensure you have a running instance of Fedora and access to a user account with sudo or root privileges.

The first and most crucial step is to ensure your system is fully up-to-date. This minimizes potential conflicts and security vulnerabilities. Open your terminal and run:

sudo dnf update -y

Step 1: Install and Configure the Apache Web Server

Apache (or httpd as it’s known in Fedora’s repositories) will serve your WordPress site’s files to visitors.

First, install the Apache package:

sudo dnf install httpd -y

Once the installation is complete, you need to start the Apache service and enable it to launch on boot:

sudo systemctl start httpd
sudo systemctl enable httpd

To allow web traffic to reach your server, you must configure your firewall to permit HTTP and HTTPS connections:

sudo firewall-cmd --permanent --add-service={http,https}
sudo firewall-cmd --reload

You can verify that Apache is running by navigating to your server’s IP address in a web browser. You should see the default Fedora test page.

Step 2: Install and Secure the MariaDB Database

WordPress uses a database to store all of your site’s content, from blog posts to user settings. MariaDB is a highly reliable, open-source drop-in replacement for MySQL.

Install the MariaDB server and client packages:

sudo dnf install mariadb-server -y

Next, start and enable the MariaDB service:

sudo systemctl start mariadb
sudo systemctl enable mariadb

With the database server running, it is critical to run the included security script. This will help you set a root password, remove anonymous users, and disable remote root login, significantly hardening your database.

sudo mysql_secure_installation

Follow the on-screen prompts to secure your installation. It is highly recommended to answer “Y” (yes) to all questions.

Step 3: Install PHP and Required Extensions

PHP is the server-side scripting language that WordPress is built on. You need to install PHP along with several extensions that WordPress relies on to function correctly.

Install PHP and the necessary extensions with a single command:

sudo dnf install php php-mysqlnd php-gd php-xml php-mbstring php-json -y
  • php-mysqlnd: Allows PHP to communicate with the MariaDB database.
  • php-gd: Enables image processing for thumbnails and media management.
  • php-xml, php-mbstring, php-json: Common extensions required for core WordPress functionality and plugins.

After installation, you must restart the Apache web server for it to recognize and load the new PHP module:

sudo systemctl restart httpd

Step 4: Create a Dedicated WordPress Database and User

For security and management purposes, WordPress should have its own dedicated database and user account, rather than using the database root user.

Log into the MariaDB command line as the root user:

sudo mysql -u root -p

Enter the root password you set during the mysql_secure_installation step.

Now, run the following SQL commands. Be sure to replace wordpress_db, wp_user, and strong_password with your own secure values.

  1. Create the database:

    CREATE DATABASE wordpress_db;
    
  2. Create a new user and assign a password:

    CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'strong_password';
    
  3. Grant the new user full privileges on the WordPress database:

    GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
    
  4. Flush privileges to apply the changes and exit:
    sql
    FLUSH PRIVILEGES;
    EXIT;

Keep these database credentials handy, as you will need them in the next step.

Step 5: Download and Configure WordPress

Now it’s time to download the WordPress core files and configure them to connect to your new database.

Navigate to the Apache web root directory, download the latest version of WordPress, and extract it.

cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz

This will extract the files into a directory named wordpress. For a cleaner setup, move the contents of this directory into the main web root:

sudo mv wordpress/* /var/www/html/

Next, create the main WordPress configuration file from the provided sample file:

sudo cp wp-config-sample.php wp-config.php

Now, edit the new wp-config.php file using a text editor like nano:

sudo nano wp-config.php

Find the following lines and replace the placeholder values with the database credentials you created in Step 4:

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

/** Database username */
define( 'DB_USER', 'wp_user' );

/** Database password */
define( 'DB_PASSWORD', 'strong_password' );

Save and close the file.

Step 6: Set Correct File Permissions and SELinux Context

Proper permissions are essential for both security and functionality, allowing WordPress to manage files without compromising your server.

First, set the ownership of the WordPress files to the Apache user:

sudo chown -R apache:apache /var/www/html/

Fedora uses SELinux (Security-Enhanced Linux) for advanced access control. You must set the correct SELinux context to allow Apache to write to the WordPress directory, which is necessary for uploading media and installing plugins.

sudo chcon -t httpd_sys_rw_content_t /var/www/html/ -R

Step 7: Finalize the Installation via Web Browser

You have now completed all the command-line setup. The final step is the famous WordPress 5-minute installer.

Open your web browser and navigate to your server’s IP address or domain name (http://your_server_ip).

You will be greeted with the WordPress installation screen. Select your language and proceed. On the next screen, you will need to provide the following information:

  • Site Title: The name of your website.
  • Username: Your desired administrator username (avoid using “admin”).
  • Password: A strong, unique password for your admin account.
  • Your Email: For notifications and password recovery.

Click “Install WordPress,” and in a few moments, your installation will be complete. You can now log in to your new WordPress dashboard and begin building your site.

Source: https://kifarunix.com/install-wordpress-5-0-with-apache-on-fedora-29-fedora-28/

900*80 ad

      1080*80 ad