2026年11月12日
2026年11月12日
Install WordPress on Rocky Linux 10: Apache, PHP-FPM, MariaDB, SELinux
This article is a localized edition of the Japanese original. Read the Japanese original
Rocky Linux is a distribution compatible with Red Hat Enterprise Linux (RHEL). This article walks through installing Apache, PHP and MariaDB on a Rocky Linux 10 server and getting WordPress running, in a form you can copy and run.
The steps were checked on Rocky Linux 10.2 as of November 2026. The versions installed from the standard repository (AppStream) are listed below, and they meet the WordPress.org recommended requirements (PHP 8.3 or greater, MariaDB 10.11 or greater or MySQL 8.0 or greater).
| Software | Version installed by default (as of November 2026) |
|---|---|
| Apache (httpd) | 2.4.63 |
| PHP | 8.3 (8.4 is also provided as separate packages) |
| MariaDB | 10.11 (11.8 is also provided as separate packages) |
Check before you start
- You can connect over SSH as root or as a user who can use sudo
- A domain name pointed at the server (
example.combelow). You can also test with just the IP address - The x86_64 edition of Rocky Linux 10 requires a CPU that supports x86-64-v3. It may not install on older CPUs or some virtual environments. On a running system, you can check with the following command.
/lib64/ld-linux-x86-64.so.2 --help | grep x86-64-v
If you see x86-64-v3 (supported, searched), the CPU is supported.
Step 1: Update packages and install the software
First bring the system up to date, then install the web server, PHP and the database in one go.
sudo dnf -y upgrade
sudo dnf -y install httpd mod_ssl \
php php-mysqlnd php-gd php-xml php-mbstring php-intl php-opcache php-pecl-zip \
mariadb-server policycoreutils-python-utils tar wget
Installing php also installs PHP-FPM (php-fpm). Apache on Rocky Linux is configured to run PHP through PHP-FPM rather than as a module (/etc/httpd/conf.d/php.conf). policycoreutils-python-utils provides the semanage command used later for SELinux.
If you want PHP 8.4, there are separate packages whose names start with php8.4. It is safer to build on the default 8.3 first and switch after confirming your plugins support it.
Step 2: Start the services
Start Apache, PHP-FPM and MariaDB and make them start automatically after a reboot. PHP-FPM does not start together with Apache, so enable it separately.
sudo systemctl enable --now httpd php-fpm mariadb
sudo systemctl status httpd php-fpm mariadb --no-pager
If all three show active (running), you are done with this step.
On servers running firewalld, open HTTP and HTTPS.
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload
On a VPS, also open ports 80 and 443 in the packet filter or security group in your provider's control panel.
Step 3: Initial MariaDB setup and creating the database
First run the initial setup script to remove anonymous users and the test database.
sudo mariadb-secure-installation
With MariaDB 10.11, the OS root user can connect without a password using sudo mariadb (unix_socket authentication). A common way to answer the prompts is to leave the root authentication method as is, and answer "Y" to removing anonymous users, disallowing remote root login and removing the test database.
Next, create the database and user for WordPress. Replace the password with a strong one of your own.
sudo mariadb
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your-strong-password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
The privileges are limited to the wordpress database. Do not grant server-wide privileges (*.*).
Step 4: Put WordPress in place
This example downloads the latest Japanese-language package and extracts it to /var/www/wordpress.
cd /tmp
wget https://ja.wordpress.org/latest-ja.tar.gz
tar -xzf latest-ja.tar.gz
sudo mv wordpress /var/www/wordpress
For the English version, use https://wordpress.org/latest.tar.gz.
Next, create the configuration file.
cd /var/www/wordpress
sudo cp wp-config-sample.php wp-config.php
sudo vi wp-config.php
In wp-config.php, change the following lines to match what you created in Step 3.
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'your-strong-password' );
define( 'DB_HOST', 'localhost' );
In the same file, replace the eight "Authentication unique keys and salts" lines (from AUTH_KEY to NONCE_SALT) with the content shown when you open https://api.wordpress.org/secret-key/1.1/salt/.
Finally, make the Apache user (apache) the owner of the files. This lets WordPress write files when you add or update plugins and themes from the admin screen.
sudo chown -R apache:apache /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress -type f -exec chmod 644 {} \;
sudo chmod 640 /var/www/wordpress/wp-config.php
Step 5: Create an Apache virtual host
Create a new file /etc/httpd/conf.d/wordpress.conf with the content below. AllowOverride All is required so that the .htaccess file WordPress writes from the permalink settings takes effect (mod_rewrite is loaded by default).
sudo vi /etc/httpd/conf.d/wordpress.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/wordpress
<Directory /var/www/wordpress>
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log combined
</VirtualHost>
Check the configuration syntax, then reload Apache.
sudo apachectl configtest
sudo systemctl reload httpd
If you see Syntax OK, everything is fine. For more on writing virtual hosts, see also Apache virtual host configuration.
Step 6: Configure SELinux
SELinux is enabled (Enforcing) by default on Rocky Linux. Do not disable it; allow only what WordPress needs.
# Check the current mode (if Enforcing, the following is needed)
getenforce
# Label the whole WordPress directory as writable by Apache
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/wordpress(/.*)?"
sudo restorecon -Rv /var/www/wordpress
# Allow outbound connections from WordPress (update checks, adding plugins, external APIs)
sudo setsebool -P httpd_can_network_connect on
The first setting makes it possible to update core, plugins and themes from the admin screen and to upload media. If you want to limit writes to wp-content only, use the path "/var/www/wordpress/wp-content(/.*)?" instead. In that case, update core over SSH with WP-CLI or similar rather than from the admin screen.
If SELinux is stopping something from working, check the denial records.
sudo ausearch -m AVC -ts recent
Step 7: Finish the installation in the browser
Open http://example.com/ in a browser and the WordPress installation screen appears. Enter the site title and the administrator's username, password and email address, then click "Install WordPress" to finish.
Once you are in the admin screen, go to "Tools" → "Site Health" and check that there are no warnings about PHP extensions or file write permissions.
What to do after installation
- Switch to HTTPS:
mod_sslwas installed in Step 1. Get a certificate and create a virtual host on port 443. For using Let's Encrypt, see How to install an SSL certificate with Let's Encrypt. - Raise the upload limit: the default
/etc/php.inihasupload_max_filesize = 2Mandpost_max_size = 8M. If you upload large images or themes, change the values and apply them withsudo systemctl restart php-fpm. - Update regularly: update the OS and middleware with
sudo dnf upgrade, and update WordPress core, plugins and themes from the admin screen. - Back up: keep both a database dump and the files in
/var/www/wordpress, including a copy off the server.
Where to look when something goes wrong
| Symptom | What to check |
|---|---|
| PHP code is shown as-is, or a 503 error | Whether PHP-FPM is running, with systemctl status php-fpm |
| "Error establishing a database connection" | The DB name, user and password in wp-config.php, and systemctl status mariadb |
| 404 after changing permalinks | AllowOverride All in the virtual host, and whether .htaccess was created |
| Updates or uploads fail | Whether the files are owned by apache, and the SELinux labels (ls -Z) |
| Update checks or plugin search do not work | Whether getsebool httpd_can_network_connect is on |
Logs are in /var/log/httpd/wordpress_error.log (Apache) and /var/log/php-fpm/www-error.log (PHP-FPM).
Summary
- The standard Rocky Linux 10 packages (Apache 2.4, PHP 8.3, MariaDB 10.11) meet the WordPress recommended requirements (as of November 2026)
- PHP runs through PHP-FPM, so do not forget to enable the
php-fpmservice - Give the database user privileges only on the WordPress database
- Set
AllowOverride Allfor permalinks - Do not disable SELinux; allow only what is needed with
httpd_sys_rw_content_tandhttpd_can_network_connect
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)