We are going to demonstrate how to install WordPress 5 with Nginx on Fedora 30/Fedora 29.
Are you using WordPress and looking for a professional WordPress website builder platform? Look no further since Elementor can help you create beautiful pages.
Installing WordPress 5 with Nginx on Fedora
Prerequisites
Update your system packages.
dnf update
dnf upgrade
Install LEMP Stack on Fedora 30/Fedora 29
Installation of LEMP stack on Fedora 30/Fedora 29 has been covered in our previous guide. See the link below.
Install LEMP Stack with MySQL 8 on Fedora 30/Fedora 29
Install Required PHP Extensions
Assuming you followed the guide above on setting up LEMP stack, you need to run the command below to install other required PHP modules.
dnf install php-cli php-json php-opcache php-xml php-gd php-curl
Configure MySQL
WordPress requires a database on which it can store the configurations and the data. Hence, login to MySQL as root user and create WordPress user and database as shown below.
Login to MySQL
mysql -u root -p
Next, create WordPress Database
create database wordpressdemo;
Create WordPress database user. Note that in MySQL 8, you cannot create user with GRANT.
create user wpdemo@localhost identified by 'StrongP@33#';
Grant all privileges to WordPress user on WordPress database
grant all privileges on wordpressdemo.* to wpdemo@localhost;
Reload Privileges tables
flush privileges;
Enable MySQL 8 native passwords by editing the /etc/my.conf and uncommenting the line, default-authentication-plugin=mysql_native_password.
vim /etc/my.conf
default-authentication-plugin=mysql_native_password
Restart MySQL
systemctl restart mysqld
Install WordPress 5 on Fedora 30/Fedora 29
WordPress can be installed directly from Fedora 30/29 repos. However, the available version may not up-to-date. You can check it by running the command below;
dnf provides wordpress
Last metadata expiration check: 0:19:41 ago on Mon 24 Jun 2019 06:32:18 PM EAT.
wordpress-5.2.1-1.fc30.noarch : Blog tool and publishing platform
Repo : updates
Matched from:
Provide : wordpress = 5.2.1-1.fc30
As you can see, the available version is 5.2.1 while the latest version 5.2.2. Therefore, to install the latest version, download WordPress archive from the downloads page. You can simply use the wget command.
wget https://wordpress.org/latest.tar.gz
Next, extract WordPress archive contents
tar xzf latest.tar.gz -C /tmp
Copy the extracted WordPress contents to Nginx Web Server root directory.
rsync -avP /tmp/wordpress/ /usr/share/nginx/html/kifarunix-demo.com
Configure WordPress
Open WordPress configuration file and set the database connection details. Rename the sample configuration file and edit it as follows.
cp /usr/share/nginx/html/kifarunix-demo.com/wp-config-sample.php /usr/share/nginx/html/kifarunix-demo.com/wp-config.php
vim /usr/share/nginx/html/kifarunix-demo.com/wp-config.php
Replace the DB_NAME, DB_USER, DB_PASSWORD with your values.
...
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' );
/** MySQL database username */
define( 'DB_USER', 'wpuser' );
/** MySQL database password */
define( 'DB_PASSWORD', 'StrongP@33#' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
...
After that, you need to define how WordPress will write to filesystem. Hence, put the line below just after the database configurations.
define('FS_METHOD', 'direct');
Next, generate authentication unique keys and salts. You can simply generate the keys and salts from WordPress Secret-Key service as follows;
curl -s https://api.wordpress.org/secret-key/1.1/salt/
define('AUTH_KEY', 'B|#MIfD#LtT8].r0$gj[|&kn:?1r9=@,6fHeP(#u{Kg<q#E}4yuo$goGmF*qxv{}');
define('SECURE_AUTH_KEY', '<@v!aDzv+I65qI!om67Bc4QA=Wfb|HLr0XhZT;6nVS+`t{&8PI}y}kJ6U[#Hm-x_');
define('LOGGED_IN_KEY', 'JF*T}IXf=8tqx>+}Ao9N#z}UX8_Ms_o<-E6SJ#^z? ^{8$&H 8H+<a+1$[{$&p+');
define('NONCE_KEY', 'ah6{N4;Ms+CZfeU87+@Z_PO>W`?$^+2Jcvo=hV`e}v}u5+;hPyqw<2b;qyHkXOs$');
define('AUTH_SALT', '][WrFF`:-.#+}dEJQ.;Q%sl( RiY7:m(-[.sDd3dh|o8S+q>?ak[g6ltHo^V5|]5');
define('SECURE_AUTH_SALT', ')o|KHA^,~yH7S9-!vSS@vD[Al;ep$<$a$*emlV+h)l?T+Gc.a!LWZC {DZ buO[B');
define('LOGGED_IN_SALT', '$-W+/bVu[vkBeWrtu:R-6&cf{]N%z,PBomOP>R=lqCOEt%v]Y>}b]wGp(/yza=ux');
define('NONCE_SALT', ' VV(UM||}r]G:4#XT;T9:*$@>[`v(m.N383u8pEJ-w*2>h#mh5v`Kc9@}5c:Tc$]');
Within the wp-config.php, replace the following lines with the above.
...
* @since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
/**#@-*/
...
Your configuration should look like;
...
* @since 2.6.0
*/
/**
* define( 'AUTH_KEY', 'put your unique phrase here' );
* define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
* define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
* define( 'NONCE_KEY', 'put your unique phrase here' );
* define( 'AUTH_SALT', 'put your unique phrase here' );
* define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
* define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
* define( 'NONCE_SALT', 'put your unique phrase here' );
*/
define('AUTH_KEY', 'B|#MIfD#LtT8].r0$gj[|&kn:?1r9=@,6fHeP(#u{Kg<q#E}4yuo$goGmF*qxv{}');
define('SECURE_AUTH_KEY', '<@v!aDzv+I65qI!om67Bc4QA=Wfb|HLr0XhZT;6nVS+`t{&8PI}y}kJ6U[#Hm-x_');
define('LOGGED_IN_KEY', 'JF*T}IXf=8tqx>+}Ao9N#z}UX8_Ms_o<-E6SJ#^z? ^{8$&H 8H+<a+1$[{$&p+');
define('NONCE_KEY', 'ah6{N4;Ms+CZfeU87+@Z_PO>W`?$^+2Jcvo=hV`e}v}u5+;hPyqw<2b;qyHkXOs$');
define('AUTH_SALT', '][WrFF`:-.#+}dEJQ.;Q%sl( RiY7:m(-[.sDd3dh|o8S+q>?ak[g6ltHo^V5|]5');
define('SECURE_AUTH_SALT', ')o|KHA^,~yH7S9-!vSS@vD[Al;ep$<$a$*emlV+h)l?T+Gc.a!LWZC {DZ buO[B');
define('LOGGED_IN_SALT', '$-W+/bVu[vkBeWrtu:R-6&cf{]N%z,PBomOP>R=lqCOEt%v]Y>}b]wGp(/yza=ux');
define('NONCE_SALT', ' VV(UM||}r]G:4#XT;T9:*$@>[`v(m.N383u8pEJ-w*2>h#mh5v`Kc9@}5c:Tc$]');
/**#@-*/
...
Configure Nginx
Create your site Nginx server block.
vi /etc/nginx/conf.d/wp.kifarunix-demo.com.conf
server {
listen 80 default_server;
server_name wp.kifarunix-demo.com;
root /usr/share/nginx/html/kifarunix-demo.com;
access_log /var/log/nginx/access_wp.kifarunix-demo.com;
error_log /var/log/nginx/error_wp.kifarunix-demo.com;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_index index.php;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Next, set the ownership of your site Nginx configuration to nginx user.
chown -R nginx:nginx /usr/share/nginx/html/kifarunix-demo.com
If SELinux is running, execute the following commands to allow Nginx connect to DB, send mail and access WordPress configuration files.
setsebool -P httpd_can_network_connect_db=1
setsebool -P httpd_can_sendmail=1
chcon -Rt httpd_sys_content_t /usr/share/nginx/html/kifarunix-demo.com/
Restart Nginx
systemctl restart nginx
Finalize WordPress Setup
Login to your WordPress and finalize your setup.
Next, login to your WordPress.
And there you go.
You have successfully installed wordpress 5 with Nginx and MySQL 8 on Fedora 30/Fedora 29. Enjoy.
You can also check our other articles by following the links below;
How to Install and Use WPScan WordPress Vulnerability Scanner Ubuntu 18.04
Install WordPress 5.0 with Apache on Fedora 29/Fedora 28
How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28/29
How to Install LAMP Stack (Apache,MariaDB, PHP 7.2) on Ubuntu 18.04 LTS
Thank you. I suggest you update this for Fedora 31, where I can’t see /etc/my.conf . What to do ?
for fedora 32/33 the file is /etc/my.cnf (all mariadb files changed extention to .cnf). Thanks for this post where can I find more explanation on what you did on config.php? Never seen this kind of setup before, I’m worried about security.
What if I just simply want to install wordpress from rpm and use that setup? I have nginx running fine on a certain site and the following lines in /etc/nginx/default.d/wordpress.conf seem to indicate that I can just leave the wordpress directory under /user/share
# WordPress
location = /wordpress {
alias /usr/share/wordpress/;
}
location /wordpress/ {
root /usr/share;
index index.php;
But when I go to http://localhost/wordpress/wp-admin/install.php, I get “Forbidden 403 error”
Hi mate,
Well, if installing wordpress from rpm works, then fine.
For the “Forbidden 403 error”, be sure to check the nginx error logs.
Hi mate, what are the logs saying?