WordPress on Fedora with RPM, DNF/YUM

WordPress is packaged for Fedora and can be installed as a regular RPM (with DNF/YUM). The benefits of this method are that you don’t need to mess around with configuration files, filesystem permissions and since everything is pre-packaged to work together, additional configurations are minimal. At the end of this 3 minutes tutorial, you’ll get a running WordPress under an SSL-enabled Apache using MariaDB as its backend.

All commands need to be executed as root.

Database preparation

  1. Install MariaDB server (not necessarily on the same machine that will run WordPress and the web server)
    dnf install mariadb-server
  2. Start and prepare MariaDB server. Initial root password is blank (just hit enter on password prompt), answer the questions removing the test database
    systemctl enable mariadb
    systemctl start mariadb
    mysql_secure_installation
  3. Create a database, items in red were invented for this tutorial and will be used again in step 5
    mysql -u root -p -e "CREATE DATABASE blogdb; GRANT ALL PRIVILEGES ON blogdb.* TO 'bloguser'@'%' IDENTIFIED BY 'bloguserpassword'; FLUSH PRIVILEGES;"

Optional: Copy an entire database from other machine

Adapt and run this scriptlet in the machine that has access to the target/new database. It will SSH into another machine that has access to the old database, dump the database over the SSH pipe and right away import it into the new database. No temporary files will be created.

source_host=source.host.com
source_ssh_user=username

source_db_host=source-db.host.com
source_db_name=source_database_name
source_db_user=source-db-user
source_db_passwd=source-db-passwd

target_db_host=target-db.host.com
target_db_name=target_database_name
target_db_user=target-db-user
target_db_passwd=target-db-passwd

ssh -l $source_ssh_user $source_host \
	"mysqldump -u $source_db_user --password=$source_db_passwd $source_db_name -h $source_db_host --no-tablespaces" \
        | \
	mysql -u $target_db_user -p $target_db_name -h $target_db_host --password=$target_db_passwd

Optional: Change domain of one or many WordPress sites

After copying the entire WordPress database, you might want to change domain names for each site. This SQL script will do the job. Run only 5 first updates if you this is a single-domain installation. Run the rest if you have a multisite WordPress, obviously adapting for your domains.

UPDATE wp_site SET domain = 'new.domain.com' WHERE wp_site.id=1;
UPDATE wp_sitemeta SET meta_value = 'https://new.domain.com' WHERE meta_key='siteurl';

update wp_blogs set domain='new.domain.com' where blog_id=1;
update wp_options set option_value='https://new.domain.com' where option_name='siteurl';
update wp_options set option_value='https://new.domain.com' where option_name='home';

-- Rename domains of other sites, in case of WordPress Multisite

update wp_blogs set domain='another.new.domain.com' where blog_id=2;
update wp_2_options set option_value='https://another.new.domain.com' where option_name='siteurl';
update wp_2_options set option_value='https://another.new.domain.com' where option_name='home';

update wp_blogs set domain='onemore.new.domain.com' where blog_id=3;
update wp_3_options set option_value='https://onemore.new.domain.com' where option_name='siteurl';
update wp_3_options set option_value='https://onemore.new.domain.com' where option_name='home';

WordPress preparation (may be configured on a machine other than the DB above)

  1. Install WordPress, MariaDB client and SSL support for Apache
    dnf install wordpress mariadb mod_ssl
  2. Configure WordPress to use same DB name, DB user and DB password as created on step 3 above
    sed -i 's/database_name_here/blogdb/; s/username_here/bloguser/; s/password_here/bloguserpassword/' /etc/wordpress/wp-config.php
  3. Optional but recommended: remove Fedora WordPress defaults that blocks access to anyone coming from the network
    sed -i 's/Require local/Require all granted/' /etc/httpd/conf.d/wordpress.conf
  4. Enable and activate the web server
    systemctl enable httpd
    systemctl start httpd
  5. Now continue regular WordPress configuration on the browser accessing the secure address https://your-webserver-address.com/wordpress/wp-admin/install.php

WordPress traditional wp-config.php file is located on /etc/wordpress/wp-config.php and you can make additional configurations there.

WordPress is configured in Fedora standard Apache on /etc/httpd/conf.d/wordpress.conf. You do not need to mess around with other standard Apache configuration files.

Install themes and plugins under /usr/share/wordpress/wp-content.

You can easily and safely update WordPress with a system standard command:

dnf update wordpress

Leave a Reply

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