Installing Wordpress

Peter Boy Версія F37,F38 Last review: 2023-07-15
Wordpress is a common blog system that can also be used for simple websites. Fedora includes an RPM package, so the installation is very simplified. This article focuses on Fedora-specific implementation details.

Wordpress is a widely used application and there is a corresponding amount of information on the Internet. The Wordpress project itself provides extensive upstream documentation.

For the sake of completeness: Even though Wordpress is widely used, you should carefully consider whether you really need a dynamic CMS that generates every page with every request anew.

  • If your pages remain largely unchanged once they have been created, various static site generators are probably more practical and less time-consuming to maintain.

  • Be prepared for the fact that the ongoing operation of Wordpress requires considerable effort. Wordpress is known for recurring security issues and requires ongoing attention and maintenance.

    At minimum, Wordpress should be installed in a container. Fedora Server offers several options for this, including some with little additional management effort.

The Fedora Wordpress RPM installs a closely upstream Wordpress while integrating as smoothly as possible into the Fedora runtime environment.

Another good first overview provides the Fedora Magazine article How to install WordPress on Fedora (2017).

Prerequisites

  • We assume a correctly installed Fedora Server Edition release 38 or 39. For details see Fedora Server Installation Guide.

  • Wordpress stores most of the content in a database. Accordingly, it requires access to a working database system and doesn’t even startup without. Currently, it no longer enables to use PostgreSQL, the Fedora Server Edition preferred and specifically supported database system. It just supports MariaDB or MySQL, which are included in Fedora as well.

    So you have to install either MariaDB or MySQL following Installing MySQL/MariaDB. In terms of Wordpress, both systems work equally smoothly. Following Fedoras preferrence for truely OSS software we use MariaDB here.

    Before you start installation, create the required storage. The easiest and quickest way is to use Cockpit (select the storage tab and then the appropriate Volume Group in the upper right corner).

  • Furthermore, Wordpress needs a web server to deliver the pages. Fedora Server Edition and the Fedora WordPress package support httpd, the Fedora version of the Apache Web server. Of course, other Web servers are also possible here. You will then have to do the adaptation to Wordpress yourself.

    If not already done install the Fedora Web Server package. If your server will just server the Wordpress site, you may omit the section "Setup a Web site".

Installing Wordpress

  1. Install the WordPress Package. It automatically installs PHP as a dependency, too.

    […]# dnf install  wordpress
  2. Add a database and a database user for Wordpress to the MariaDB DB.

    […]# mysql -u root
    MariaDB [(none)]> show databases;
    MariaDB [(none)]> CREATE DATABASE wordpress ;
    MariaDB [(none)]> CREATE USER 'wordpress'   IDENTIFIED BY 'wp-test-proj';
    MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.*  TO 'wordpress';
    MariaDB [(none)]> quit;
    […]#
  3. Check the database connectivity via TCP/IP

    […]$ mysql -u wordpress wordpress  -p
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 18
    Server version: 10.5.20-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.‘
    
    MariaDB [wordpress]> quit
    […]$
  4. Configure Wordpress to access the database defined above

    Edit the Wordpress configuration file which is in Fedora stored at /etc/wordpress (to achieve full Fedora integration).

    […]# vim /etc/wordpress/wp-config.php
    define( 'DB_NAME', 'xxxxx' );
    define( 'DB_USER', 'xxxx' );
    define( 'DB_PASSWORD', 'xxxxxxxx' );
    define( 'DB_HOST', 'xxxx' );
  5. Enabling public access

    For security reasons, the default configuration restricts access to the local system, which is usually not why you install Wordpress. You have to edit the cpnfiguration file.

    […]# vim /etc/httpd/conf.d/wordpress.conf
    
    Alias /wordpress /usr/share/wordpress
    
    # Access is only allowed via local access
    # Change this once configured
    
    <Directory /usr/share/wordpress>
      AllowOverride Options
      #Require local                       # <== mod
      Require all granted                  # <== add
    </Directory>
  6. Protect your site during configuration and development

    Usually, it takes some time to configure the site and especially to develop the content. During this period you may want to restrict access to developers and peers only.

    Modify the configuration file further and append at the end:

    […]# vim /etc/httpd/conf.d/wordpress.conf
    
    Alias /wordpress /usr/share/wordpress
    
    # Access is only allowed via local access
    # Change this once configured
    ...
    ...
      </FilesMatch>
    </Directory>
    
    ## Append the following lines to temporarily
    ## protect access to the wordpress page
    <Location /wordpress>
      AuthType Basic
      AuthName "Access for developers only"
      AuthUserFile auth.d/validusers
      Require valid-user
    </Location>

    Provide authentication information

    […]# mkdir /etc/httpd/auth.d
    […]# htpasswd -c /etc/httpd/auth.d/validusers {USER}
    New password:
    Re-type new password:
  7. Finally start the Web Server

    […]# systemctl enable httpd
    […]# systemctl start httpd
    […]# systemctl status httpd

Check out and configure your site

  1. On your desktop open a Broser and navigate to the base address of the site you just configured:

    http://example.com

    Note: Currently no SSL access is defined, only http protocol is available.

    The Fedora default page is displayed.

    Fedora default page
  2. Your wordpress installation is available at

    http://example.com/wordpress

    If you implemented the access restriction as proposed, you get the default Apache login screen. Otherwise and after authentication you see the basic Wordpress graphical configuration page.

    Fedora default page

    Complete the various items as appropriate.

Final fine tuning

After completing the site design and content and launching the site, you may want to adjust various parameters to your liking. Among others

  • Customize the base address

    Specifically you want to modify the base address of your Wordpress site, from wordpress to e.g. mycuteblog. Edit the Wordpress Apache configuration file:

    […]# vim /etc/httpd/conf.d/wordpress.conf
    ## Alias /wordpress /usr/share/wordpress  # <== Mod
    Alias /mycuteblog  /usr/share/wordpress   # <== Add
    
    […]# systemctl restart httpd
  • Alternatively you may want to access the Wordpress pages at your servers base address, example.com in this guide. Again, modify the Wordpress Apache configuration file.

    […]# vim /etc/httpd/conf.d/wordpress.conf
    ## Alias /wordpress /usr/share/wordpress  # <== Mod
    ## Access wordpress via base address instead # <== Add
    DocumentRoot /usr/share/wordpress            # <== Add
    
    […]# systemctl restart httpd