{"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<p>Want to create a free website or build your personal blog? Well then <a aria-label=\"WordPress (opens in a new tab)\" href=\"https:\/\/wordpress.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">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<p>Are you using WordPress and looking for a professional WordPress website builder? Look no further since <a href=\"https:\/\/trk.elementor.com\/8uczdzzsxgza-webcreatorsred\" target=\"_blank\" rel=\"noreferrer noopener\">Elementor can help you create beautiful pages<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing WordPress with Nginx and MySQL 8 on CentOS<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p>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<h4 class=\"wp-block-heading\">Update System Packages<\/h4>\n\n\n\n<p>System packages can be updated and upgraded on CentOS 8 using the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf upgrade<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install LEMP Stack on CentOS 8<\/h4>\n\n\n\n<p>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<p><a rel=\"noreferrer noopener\" aria-label=\"Install LEMP Stack on CentOS 8 (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-lemp-stack-on-centos-8\/\" target=\"_blank\">Install LEMP Stack on CentOS 8<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Install Required PHP Extensions<\/h4>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>dnf install php-cli php-json php-opcache php-xml php-gd php-curl<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create WordPress MySQL Database<\/h3>\n\n\n\n<p>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<p>Let us first the Database version installed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution)<\/code><\/pre>\n\n\n\n<p><strong>Be sure to replace the name of the database, the database user and the password used accordingly.<\/strong><\/p>\n\n\n\n<p>Login to MySQL as root.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<p>Create a WordPress database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>create database wordpressdb;<\/code><\/pre>\n\n\n\n<p>Create a WordPress database user and grant all privileges on the database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>create user wpadmin@localhost identified by 'StrongP@33#';<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>grant all on wordpressdb.* to wpadmin@localhost;<\/code><\/pre>\n\n\n\n<p>Reload the database privileges tables and exit the database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>flush privileges;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>quit<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install WordPress 5.x on CentOS 8<\/h3>\n\n\n\n<p>WordPress 5.3 is the latest version of the writing of this guide. To install the latest version, download WordPress archive from the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/wordpress.org\/download\/\" target=\"_blank\">WordPress downloads page<\/a>. You can simply use the&nbsp;<strong>wget<\/strong>&nbsp;command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install wget -y<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/wordpress.org\/latest.tar.gz<\/code><\/pre>\n\n\n\n<p>Create your web root directory. Replace the names accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir \/usr\/share\/nginx\/wp.kifarunix-demo.com<\/code><\/pre>\n\n\n\n<p>Next, extract WordPress archive contents to the default Web root directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install tar<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar xzf latest.tar.gz -C \/usr\/share\/nginx\/wp.kifarunix-demo.com\/ --strip-components=1<\/code><\/pre>\n\n\n\n<p>Verify that the WordPress files are in place.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls \/usr\/share\/nginx\/wp.kifarunix-demo.com\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>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<h3 class=\"wp-block-heading\">Configure WordPress on CentOS 8<\/h3>\n\n\n\n<p>WordPress comes with a sample configuration, <code>wp-config-sample.php<\/code>. Rename the sample configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cp \/usr\/share\/nginx\/wp.kifarunix-demo.com\/wp-config{-sample,}.php<\/code><\/pre>\n\n\n\n<p>Next, edit the configuration file and set the database connection details,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vi \/usr\/share\/nginx\/wp.kifarunix-demo.com\/wp-config.php<\/code><\/pre>\n\n\n\n<p>Replace the&nbsp;<strong>DB_NAME, DB_USER, DB_PASSWORD<\/strong>&nbsp;with the values you set while creating the MySQL database for WordPress.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>...\n\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\n\/** The name of the database for WordPress *\/\ndefine( 'DB_NAME', '<strong>wordpressdb<\/strong>' );\n\n\/** MySQL database username *\/\ndefine( 'DB_USER', '<strong>wpadmin<\/strong>' );\n\n\/** MySQL database password *\/\ndefine( 'DB_PASSWORD', '<strong>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<p>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<pre class=\"wp-block-preformatted\"><code>curl -s https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>define('AUTH_KEY',         'B|#MIfD#LtT8].r0$gj&#91;|&amp;kn:?1r9=@,6fHeP(#u{Kg&lt;q#E}4yuo$goGmF*qxv{}');\ndefine('SECURE_AUTH_KEY',  '&lt;@v!aDzv+I65qI!om67Bc4QA=Wfb|HLr0XhZT;6nVS+`t{&amp;8PI}y}kJ6U&#91;#Hm-x_');\ndefine('LOGGED_IN_KEY',    'JF*T}IXf=8tqx&gt;+}Ao9N#z}UX8_Ms_o&lt;-E6SJ#^z?  ^{8$&amp;H 8H+&lt;a+1$&#91;{$&amp;p+');\ndefine('NONCE_KEY',        'ah6{N4;Ms+CZfeU87+@Z_PO&gt;W`?$^+2Jcvo=hV`e}v}u5+;hPyqw&lt;2b;qyHkXOs$');\ndefine('AUTH_SALT',        ']&#91;WrFF`:-.#+}dEJQ.;Q%sl( RiY7:m(-&#91;.sDd3dh|o8S+q&gt;?ak&#91;g6ltHo^V5|]5');\ndefine('SECURE_AUTH_SALT', ')o|KHA^,~yH7S9-!vSS@vD&#91;Al;ep$&lt;$a$*emlV+h)l?T+Gc.a!LWZC {DZ buO&#91;B');\ndefine('LOGGED_IN_SALT',   '$-W+\/bVu&#91;vkBeWrtu:R-6&amp;cf{]N%z,PBomOP&gt;R=lqCOEt%v]Y&gt;}b]wGp(\/yza=ux');\ndefine('NONCE_SALT',       ' VV(UM||}r]G:4#XT;T9:*$@&gt;&#91;`v(m.N383u8pEJ-w*2&gt;h#mh5v`Kc9@}5c:Tc$]');<\/code><\/pre>\n\n\n\n<p>Within the&nbsp;<strong>wp-config.php<\/strong>, replace the following lines with the above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>...\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<p>Your configuration should look like;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\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&#91;|&amp;kn:?1r9=@,6fHeP(#u{Kg&lt;q#E}4yuo$goGmF*qxv{}');\ndefine('SECURE_AUTH_KEY',  '&lt;@v!aDzv+I65qI!om67Bc4QA=Wfb|HLr0XhZT;6nVS+`t{&amp;8PI}y}kJ6U&#91;#Hm-x_');\ndefine('LOGGED_IN_KEY',    'JF*T}IXf=8tqx&gt;+}Ao9N#z}UX8_Ms_o&lt;-E6SJ#^z?  ^{8$&amp;H 8H+&lt;a+1$&#91;{$&amp;p+');\ndefine('NONCE_KEY',        'ah6{N4;Ms+CZfeU87+@Z_PO&gt;W`?$^+2Jcvo=hV`e}v}u5+;hPyqw&lt;2b;qyHkXOs$');\ndefine('AUTH_SALT',        ']&#91;WrFF`:-.#+}dEJQ.;Q%sl( RiY7:m(-&#91;.sDd3dh|o8S+q&gt;?ak&#91;g6ltHo^V5|]5');\ndefine('SECURE_AUTH_SALT', ')o|KHA^,~yH7S9-!vSS@vD&#91;Al;ep$&lt;$a$*emlV+h)l?T+Gc.a!LWZC {DZ buO&#91;B');\ndefine('LOGGED_IN_SALT',   '$-W+\/bVu&#91;vkBeWrtu:R-6&amp;cf{]N%z,PBomOP&gt;R=lqCOEt%v]Y&gt;}b]wGp(\/yza=ux');\ndefine('NONCE_SALT',       ' VV(UM||}r]G:4#XT;T9:*$@&gt;&#91;`v(m.N383u8pEJ-w*2&gt;h#mh5v`Kc9@}5c:Tc$]');\n\/**#@-*\/\n...<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure Nginx<\/h3>\n\n\n\n<p>Create an Nginx server block for your blog. You can make it the default (<strong><code>default_server<\/code><\/strong>) block if you are hosting just one block.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vi \/etc\/nginx\/conf.d\/wp.kifarunix-demo.com.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>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<p>Next, set the user and group ownership of your site Nginx configuration to&nbsp;<strong>nginx<\/strong>&nbsp;user.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown -R nginx:nginx \/usr\/share\/nginx\/wp.kifarunix-demo.com\/<\/code><\/pre>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>setsebool -P httpd_can_network_connect_db=1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>setsebool -P httpd_can_sendmail=1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chcon -Rt httpd_sys_content_t \/usr\/share\/nginx\/wp.kifarunix-demo.com\/<\/code><\/pre>\n\n\n\n<p>Disable the default Nginx site;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sed -i 's\/80 default_server;\/80;\/' \/etc\/nginx\/nginx.conf<\/code><\/pre>\n\n\n\n<p>Check the syntax;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>nginx -t<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>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<p>Restart Nginx, if the syntax is ok.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart nginx<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Finalize WordPress Setup<\/h3>\n\n\n\n<p>Login to your WordPress and finalize your setup.<\/p>\n\n\n\n<p>Access the your blog using the domain name or IP address; <strong><code>http:\/\/domain_name_or_IP<\/code><\/strong>.<\/p>\n\n\n\n<p>Go through the WordPress settings and configure them accordingly. See sample screenshot below;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"677\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/11\/wordpress-setup.png\" alt=\"Install WordPress with Nginx and MySQL 8 on CentOS 8\" class=\"wp-image-4702\" title=\"\"><\/figure><\/div>\n\n\n<p>Once done with settings, click <strong>Install WordPress<\/strong> to finalize the installation of WordPress on your CentOS 8 server. <strong>Be sure to copy the password and save it.<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"322\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/11\/install-success.png\" alt=\"\" class=\"wp-image-4703\" title=\"\"><\/figure><\/div>\n\n\n<p>Once the installation is done, login to your WordPress with the user credentials you set up.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1147\" height=\"685\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/11\/wordpress.png\" alt=\"\" class=\"wp-image-4704\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/11\/wordpress.png?v=1574973497 1147w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/11\/wordpress-768x459.png?v=1574973497 768w\" sizes=\"(max-width: 1147px) 100vw, 1147px\" \/><\/figure>\n\n\n\n<p>There you go. You have successfully installed WordPress.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Other Related Articles<\/h4>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-lemp-stack-on-debian-10-buster\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install LEMP Stack on Debian 10 Buster<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-lemp-stack-with-mysql-8-on-fedora-30-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install LEMP Stack with MySQL 8 on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-setup-lemp-stack-nginx-mariadb-php-7-2-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How To Setup LEMP Stack (Nginx, MariaDB, PHP 7.2) on Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-wordpress-5-with-nginx-on-debian-10-buster\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install WordPress 5 with Nginx on Debian 10 Buster<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Want to create a free website or build your personal blog? Well then WordPress is what you are looking for. With CentOS 8 having been<\/p>\n","protected":false},"author":1,"featured_media":12459,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,292],"tags":[1142,5236,999,229,1047,1206],"class_list":["post-4695","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-wordpress","tag-centos-8","tag-install-wordpress-on-centos-8","tag-mysql-8","tag-nginx","tag-wordpress","tag-wordpress-5-3","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4695"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=4695"}],"version-history":[{"count":8,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4695\/revisions"}],"predecessor-version":[{"id":21245,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4695\/revisions\/21245"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/12459"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}