{"id":4695,"date":"2019-11-28T23:48:42","date_gmt":"2019-11-28T20:48:42","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4695"},"modified":"2024-03-12T23:08:05","modified_gmt":"2024-03-12T20:08:05","slug":"install-wordpress-with-nginx-and-mysql-8-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-wordpress-with-nginx-and-mysql-8-on-centos-8\/","title":{"rendered":"Install WordPress with Nginx and MySQL 8 on CentOS 8"},"content":{"rendered":"\n
Want to create a free website or build your personal blog? Well then WordPress<\/a> is what you are looking for. With CentOS 8 having been released, follow through this guide to learn how to install WordPress with Nginx and MySQL 8 on CentOS 8.<\/p>\n\n\n\n Are you using WordPress and looking for a professional WordPress website builder? Look no further since Elementor can help you create beautiful pages<\/a>.<\/p>\n\n\n\n In order to setup WordPress on CentOS 8 with Nginx and MySQL 8, there are a number of prerequisites that must be met;<\/p>\n\n\n\n System packages can be updated and upgraded on CentOS 8 using the commands below;<\/p>\n\n\n\n Next, ensure that you have LEMP stack installed. We have made a guide on how to install LEMP stack on CentOS 8 in our other tutorials. Follow the link below;<\/p>\n\n\n\n Install LEMP Stack on CentOS 8<\/a><\/p>\n\n\n\n There are other PHP extensions that are required to run WordPress on CentOS 8 that were not installed on the LEMP guide above.<\/p>\n\n\n\n Once you have your LEMP stack setup, proceed to create MySQL database and the database user for your WordPress blog.<\/p>\n\n\n\n Let us first the Database version installed.<\/p>\n\n\n\n Be sure to replace the name of the database, the database user and the password used accordingly.<\/strong><\/p>\n\n\n\n Login to MySQL as root.<\/p>\n\n\n\n Create a WordPress database.<\/p>\n\n\n\n Create a WordPress database user and grant all privileges on the database.<\/p>\n\n\n\n Reload the database privileges tables and exit the database.<\/p>\n\n\n\n WordPress 5.3 is the latest version of the writing of this guide. To install the latest version, download WordPress archive from the WordPress downloads page<\/a>. You can simply use the wget<\/strong> command.<\/p>\n\n\n\n Create your web root directory. Replace the names accordingly.<\/p>\n\n\n\n Next, extract WordPress archive contents to the default Web root directory.<\/p>\n\n\n\n Verify that the WordPress files are in place.<\/p>\n\n\n\n WordPress comes with a sample configuration, Next, edit the configuration file and set the database connection details,<\/p>\n\n\n\n Replace the DB_NAME, DB_USER, DB_PASSWORD<\/strong> with the values you set while creating the MySQL database for WordPress.<\/p>\n\n\n\n Next, generate authentication unique keys and salts. You can simply generate the keys and salts from WordPress Secret-Key service as follows;<\/p>\n\n\n\n Within the wp-config.php<\/strong>, replace the following lines with the above.<\/p>\n\n\n\n Your configuration should look like;<\/p>\n\n\n\n Create an Nginx server block for your blog. You can make it the default ( Next, set the user and group ownership of your site Nginx configuration to nginx<\/strong> user.<\/p>\n\n\n\n If SELinux is running, execute the following commands to allow Nginx connect to DB, send mail and access WordPress configuration files.<\/p>\n\n\n\n Disable the default Nginx site;<\/p>\n\n\n\n Check the syntax;<\/p>\n\n\n\n Restart Nginx, if the syntax is ok.<\/p>\n\n\n\n Login to your WordPress and finalize your setup.<\/p>\n\n\n\n Access the your blog using the domain name or IP address; Go through the WordPress settings and configure them accordingly. See sample screenshot below;<\/p>\n\n\n Once done with settings, click Install WordPress<\/strong> to finalize the installation of WordPress on your CentOS 8 server. Be sure to copy the password and save it.<\/strong><\/p>\n\n\n Once the installation is done, login to your WordPress with the user credentials you set up.<\/p>\n\n\n\n There you go. You have successfully installed WordPress.<\/p>\n\n\n\n Install LEMP Stack on Debian 10 Buster<\/a><\/p>\n\n\n\n Install LEMP Stack with MySQL 8 on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n How To Setup LEMP Stack (Nginx, MariaDB, PHP 7.2) on Ubuntu 18.04<\/a><\/p>\n\n\n\nInstalling WordPress with Nginx and MySQL 8 on CentOS<\/h2>\n\n\n\n
Prerequisites<\/h3>\n\n\n\n
Update System Packages<\/h4>\n\n\n\n
dnf update<\/code><\/pre>\n\n\n\n
dnf upgrade<\/code><\/pre>\n\n\n\n
Install LEMP Stack on CentOS 8<\/h4>\n\n\n\n
Install Required PHP Extensions<\/h4>\n\n\n\n
dnf install php-cli php-json php-opcache php-xml php-gd php-curl<\/code><\/pre>\n\n\n\n
Create WordPress MySQL Database<\/h3>\n\n\n\n
mysql -V<\/code><\/pre>\n\n\n\n
mysql Ver 8.0.17 for Linux on x86_64 (Source distribution)<\/code><\/pre>\n\n\n\n
mysql -u root -p<\/code><\/pre>\n\n\n\n
create database wordpressdb;<\/code><\/pre>\n\n\n\n
create user wpadmin@localhost identified by 'StrongP@33#';<\/code><\/pre>\n\n\n\n
grant all on wordpressdb.* to wpadmin@localhost;<\/code><\/pre>\n\n\n\n
flush privileges;<\/code><\/pre>\n\n\n\n
quit<\/code><\/pre>\n\n\n\n
Install WordPress 5.x on CentOS 8<\/h3>\n\n\n\n
dnf install wget -y<\/code><\/pre>\n\n\n\n
wget https:\/\/wordpress.org\/latest.tar.gz<\/code><\/pre>\n\n\n\n
mkdir \/usr\/share\/nginx\/wp.kifarunix-demo.com<\/code><\/pre>\n\n\n\n
dnf install tar<\/code><\/pre>\n\n\n\n
tar xzf latest.tar.gz -C \/usr\/share\/nginx\/wp.kifarunix-demo.com\/ --strip-components=1<\/code><\/pre>\n\n\n\n
ls \/usr\/share\/nginx\/wp.kifarunix-demo.com\/<\/code><\/pre>\n\n\n\n
index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php\nlicense.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php\nreadme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php<\/code><\/pre>\n\n\n\n
Configure WordPress on CentOS 8<\/h3>\n\n\n\n
wp-config-sample.php<\/code>. Rename the sample configuration file.<\/p>\n\n\n\n
cp \/usr\/share\/nginx\/wp.kifarunix-demo.com\/wp-config{-sample,}.php<\/code><\/pre>\n\n\n\n
vi \/usr\/share\/nginx\/wp.kifarunix-demo.com\/wp-config.php<\/code><\/pre>\n\n\n\n
...\n\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\n\/** The name of the database for WordPress *\/\ndefine( 'DB_NAME', 'wordpressdb<\/strong>' );\n\n\/** MySQL database username *\/\ndefine( 'DB_USER', 'wpadmin<\/strong>' );\n\n\/** MySQL database password *\/\ndefine( 'DB_PASSWORD', 'StrongP@33#<\/strong>' );\n\n\/** MySQL hostname *\/\ndefine( 'DB_HOST', 'localhost' );\n\n\/** Database Charset to use in creating database tables. *\/\ndefine( 'DB_CHARSET', 'utf8' );\n...<\/code><\/pre>\n\n\n\n
curl -s https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/<\/code><\/pre>\n\n\n\n
define('AUTH_KEY', 'B|#MIfD#LtT8].r0$gj[|&kn:?1r9=@,6fHeP(#u{Kg<q#E}4yuo$goGmF*qxv{}');\ndefine('SECURE_AUTH_KEY', '<@v!aDzv+I65qI!om67Bc4QA=Wfb|HLr0XhZT;6nVS+`t{&8PI}y}kJ6U[#Hm-x_');\ndefine('LOGGED_IN_KEY', 'JF*T}IXf=8tqx>+}Ao9N#z}UX8_Ms_o<-E6SJ#^z? ^{8$&H 8H+<a+1$[{$&p+');\ndefine('NONCE_KEY', 'ah6{N4;Ms+CZfeU87+@Z_PO>W`?$^+2Jcvo=hV`e}v}u5+;hPyqw<2b;qyHkXOs$');\ndefine('AUTH_SALT', '][WrFF`:-.#+}dEJQ.;Q%sl( RiY7:m(-[.sDd3dh|o8S+q>?ak[g6ltHo^V5|]5');\ndefine('SECURE_AUTH_SALT', ')o|KHA^,~yH7S9-!vSS@vD[Al;ep$<$a$*emlV+h)l?T+Gc.a!LWZC {DZ buO[B');\ndefine('LOGGED_IN_SALT', '$-W+\/bVu[vkBeWrtu:R-6&cf{]N%z,PBomOP>R=lqCOEt%v]Y>}b]wGp(\/yza=ux');\ndefine('NONCE_SALT', ' VV(UM||}r]G:4#XT;T9:*$@>[`v(m.N383u8pEJ-w*2>h#mh5v`Kc9@}5c:Tc$]');<\/code><\/pre>\n\n\n\n
...\n * @since 2.6.0\n *\/\ndefine( 'AUTH_KEY', 'put your unique phrase here' );\ndefine( 'SECURE_AUTH_KEY', 'put your unique phrase here' );\ndefine( 'LOGGED_IN_KEY', 'put your unique phrase here' );\ndefine( 'NONCE_KEY', 'put your unique phrase here' );\ndefine( 'AUTH_SALT', 'put your unique phrase here' );\ndefine( 'SECURE_AUTH_SALT', 'put your unique phrase here' );\ndefine( 'LOGGED_IN_SALT', 'put your unique phrase here' );\ndefine( 'NONCE_SALT', 'put your unique phrase here' );\n\n\/**#@-*\/\n...<\/code><\/pre>\n\n\n\n
...\n * @since 2.6.0\n *\/\n\/**\n * define( 'AUTH_KEY', 'put your unique phrase here' );\n * define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );\n * define( 'LOGGED_IN_KEY', 'put your unique phrase here' );\n * define( 'NONCE_KEY', 'put your unique phrase here' );\n * define( 'AUTH_SALT', 'put your unique phrase here' );\n * define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );\n * define( 'LOGGED_IN_SALT', 'put your unique phrase here' );\n * define( 'NONCE_SALT', 'put your unique phrase here' );\n *\/\ndefine('AUTH_KEY', 'B|#MIfD#LtT8].r0$gj[|&kn:?1r9=@,6fHeP(#u{Kg<q#E}4yuo$goGmF*qxv{}');\ndefine('SECURE_AUTH_KEY', '<@v!aDzv+I65qI!om67Bc4QA=Wfb|HLr0XhZT;6nVS+`t{&8PI}y}kJ6U[#Hm-x_');\ndefine('LOGGED_IN_KEY', 'JF*T}IXf=8tqx>+}Ao9N#z}UX8_Ms_o<-E6SJ#^z? ^{8$&H 8H+<a+1$[{$&p+');\ndefine('NONCE_KEY', 'ah6{N4;Ms+CZfeU87+@Z_PO>W`?$^+2Jcvo=hV`e}v}u5+;hPyqw<2b;qyHkXOs$');\ndefine('AUTH_SALT', '][WrFF`:-.#+}dEJQ.;Q%sl( RiY7:m(-[.sDd3dh|o8S+q>?ak[g6ltHo^V5|]5');\ndefine('SECURE_AUTH_SALT', ')o|KHA^,~yH7S9-!vSS@vD[Al;ep$<$a$*emlV+h)l?T+Gc.a!LWZC {DZ buO[B');\ndefine('LOGGED_IN_SALT', '$-W+\/bVu[vkBeWrtu:R-6&cf{]N%z,PBomOP>R=lqCOEt%v]Y>}b]wGp(\/yza=ux');\ndefine('NONCE_SALT', ' VV(UM||}r]G:4#XT;T9:*$@>[`v(m.N383u8pEJ-w*2>h#mh5v`Kc9@}5c:Tc$]');\n\/**#@-*\/\n...<\/code><\/pre>\n\n\n\n
Configure Nginx<\/h3>\n\n\n\n
default_server<\/code><\/strong>) block if you are hosting just one block.<\/p>\n\n\n\n
vi \/etc\/nginx\/conf.d\/wp.kifarunix-demo.com.conf<\/code><\/pre>\n\n\n\n
server {\n listen 80 default_server;\n server_name wp.kifarunix-demo.com;\n root \/usr\/share\/nginx\/wp.kifarunix-demo.com;\n \n access_log \/var\/log\/nginx\/access_wp.kifarunix-demo.com.log;\n error_log \/var\/log\/nginx\/error_wp.kifarunix-demo.com.log;\n\n index index.php;\n\n location \/ {\n try_files $uri $uri\/ \/index.php?$args;\n }\n location ~ \\.php$ {\n fastcgi_pass unix:\/run\/php-fpm\/www.sock;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n include fastcgi_params;\n fastcgi_index index.php;\n }\n error_page 404 \/404.html;\n location = \/40x.html {\n }\n\n error_page 500 502 503 504 \/50x.html;\n location = \/50x.html {\n }\n}<\/code><\/pre>\n\n\n\n
chown -R nginx:nginx \/usr\/share\/nginx\/wp.kifarunix-demo.com\/<\/code><\/pre>\n\n\n\n
setsebool -P httpd_can_network_connect_db=1<\/code><\/pre>\n\n\n\n
setsebool -P httpd_can_sendmail=1<\/code><\/pre>\n\n\n\n
chcon -Rt httpd_sys_content_t \/usr\/share\/nginx\/wp.kifarunix-demo.com\/<\/code><\/pre>\n\n\n\n
sed -i 's\/80 default_server;\/80;\/' \/etc\/nginx\/nginx.conf<\/code><\/pre>\n\n\n\n
nginx -t<\/code><\/pre>\n\n\n\n
nginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/code><\/pre>\n\n\n\n
systemctl restart nginx<\/code><\/pre>\n\n\n\n
Finalize WordPress Setup<\/h3>\n\n\n\n
http:\/\/domain_name_or_IP<\/code><\/strong>.<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n
<\/figure><\/div>\n\n\n
<\/figure>\n\n\n\n
Other Related Articles<\/h4>\n\n\n\n