{"id":486,"date":"2019-09-27T12:18:13","date_gmt":"2019-09-27T10:18:13","guid":{"rendered":"https:\/\/www.gonscak.sk\/?p=486"},"modified":"2019-09-27T12:18:14","modified_gmt":"2019-09-27T10:18:14","slug":"install-wordpress-on-centos-8-stream-with-apache-httpd","status":"publish","type":"post","link":"https:\/\/www.gonscak.sk\/?p=486","title":{"rendered":"Install WordPress on Centos-8-stream with apache (httpd)"},"content":{"rendered":"\n<p>I started on clean centos-8 server, created from netinstall cd. It is minimal instalation. So, lets begun. Check the version, to be installed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf info httpd\nName         : httpd\n Version      : 2.4.37\n Release      : 11.module_el8.0.0+172+85fc1f40<\/pre>\n\n\n\n<p>So, let install it and allow http port on firewalld. And start apache server itself.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf install httpd\nfirewall-cmd --add-service=http --permanent\nfirewall-cmd --reload\nsystemctl start httpd.service\nsystemctl enable httpd.service<\/pre>\n\n\n\n<p>Now, you can point you web browser to IP on this server and you should see the welcome page of apache web server on centos.<\/p>\n\n\n\n<p>Now  create a directory, where we place our content and simple web page to test, if its working.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir -p \/var\/www\/vhosts\/com.example.www\nvim \/var\/www\/vhosts\/com.example.www\/index.html<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;html>\n  &lt;head>\n    &lt;title>Welcome to www.example.com!&lt;\/title>\n  &lt;\/head>\n  &lt;body>\n    &lt;h1>Success!  The www.example.com virtual host is working!&lt;\/h1>\n  &lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<p>And now, create for this page own configuration in httpd:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/etc\/httpd\/conf.d\/com.example.www.conf<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80>\n    ServerAdmin admin@example.com\n    DocumentRoot \"\/var\/www\/vhosts\/com.example.www\"\n    ServerName www.example.com\n\nErrorLog \/var\/log\/httpd\/com.example.www-error_log\nCustomLog \/var\/log\/httpd\/com.example.www-access_log common\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p>And now, gracefully restart your web server and point your browser to you domain: www.example.com (I edit my \/etc\/hosts to point this domain at my internal IP).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apachectl graceful<\/pre>\n\n\n\n<p>If you test page is working, lets begin with more thinks. We must install additional packages (software) for wordpress. Its mysql server and php. As mysql server, I use mariadb. Then create an initial configuration for mysql and create database for wordpress. I set no password for mysql.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf install <code>mariadb-server mariadb<\/code>\n<code>systemctl start mariadb<\/code>\n<code>systemctl enable mariadb<\/code>\n<code>mysql_secure_installation<\/code>\n   Set root password? [Y\/n] n\n   Remove anonymous users? [Y\/n] y\n   Disallow root login remotely? [Y\/n] y\n   Remove test database and access to it? [Y\/n] y\n   Reload privilege tables now? [Y\/n] y\n\nmysql -u root -p\n   <code>CREATE DATABASE wordpress;<\/code>\n   CREATE USER wordpressuser@localhost IDENTIFIED BY 'BESTpassword';\n   GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'BESTpassword';\n   FLUSH PRIVILEGES;\n   exit;<\/pre>\n\n\n\n<p>When we find, which version of php will be standard installed, I decided to use another package sources and install newer php version 7.3<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf info php\n Available Packages\n Name         : php\n Version      : 7.2.11\n\ndnf install http:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm\ndnf update\ndnf install php73\ndnf install php73-php-fpm.x86_64 php73-php-mysqlnd.x86_64\nsystemctl start php73-php-fpm.service\nsystemctl enable php73-php-fpm.service\nln -s \/usr\/bin\/php73 \/usr\/bin\/php\nphp -v\n   PHP 7.3.10 (cli) (built: Sep 24 2019 09:20:18) ( NTS )<\/pre>\n\n\n\n<p>Now, create simple test php page, to view php by apache if its working.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/var\/www\/vhosts\/com.example.www\/foo.php<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n  phpinfo();\n?><\/code><\/pre>\n\n\n\n<p>Restart apache web server and point your browser to php:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart httpd.service\nwww.example.com\/foo.php<\/pre>\n\n\n\n<p>And now you can see informationa page about php on system.<\/p>\n\n\n\n<p>Now we can download wordpress and unpack it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd ~ <\/code>\n<code>wget http:\/\/wordpress.org\/latest.tar.gz<\/code>\n<code>tar xzvf latest.tar.gz<\/code>\nrsync -avP wordpress\/ \/var\/www\/vhosts\/com.example.www\/\nchown -R apache:apache \/var\/www\/vhosts\/<\/pre>\n\n\n\n<p>Now, we edit configuration and add directory variables about default loding index.php. And remove test files &#8211; foo.php, index.html.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rm \/var\/www\/vhosts\/com.example.www\/foo.php\nrm \/var\/www\/vhosts\/com.example.www\/index.html\nvim \/etc\/httpd\/conf.d\/com.example.www.conf<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \/var\/www\/vhosts\/com.example.www>\nDirectoryIndex index.php\n&lt;\/Directory><\/code><\/pre>\n\n\n\n<p>And restart apache web server<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart httpd.service<\/pre>\n\n\n\n<p>Now we can continue with setting our wordpress via web browser and our www.example.com page (click refresh in your web browser). Follow the instructions and fill your variables (database name, user, password&#8230;).<\/p>\n\n\n\n<p>My installation step 2 tells me, that it cannot write config.php in our content directory. So, I can manually creaty config.php, or find out, what happens. Install selinux troubleshoot packages and run command sealert, which tell us what happend.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf install setroubleshoot\nsealert -a \/var\/log\/audit\/audit.log<\/pre>\n\n\n\n<p>I can see this messages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELinux is preventing \/opt\/remi\/php73\/root\/usr\/sbin\/php-fpm from write access on the directory com.example.www.\nIf you want to allow php-fpm to have write access on the com.example.www directory\nThen you need to change the label on 'com.example.www'\nDo\n# semanage fcontext -a -t httpd_sys_rw_content_t 'com.example.www'\n# restorecon -v 'com.example.www'\nAdditional Information:\nSource Context                system_u:system_r:httpd_t:s0\nTarget Context                unconfined_u:object_r:httpd_sys_content_t:s0\nTarget Objects                com.example.www [ dir ]<\/code><\/pre>\n\n\n\n<p>So I do, what it want. I adapt permissions, that apache\/php can write into this diretory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/vhosts\/com.example.www(\/.*)?'\nrestorecon -Rv \/var\/www\/vhosts\/com.example.www\/<\/pre>\n\n\n\n<p>Now I can continue with installation. And everything works fine. Have a nice day.<\/p>\n\n\n\n<ul class=\"wp-block-gallery columns-3 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"887\" src=\"https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp1.png\" alt=\"\" data-id=\"495\" data-link=\"https:\/\/www.gonscak.sk\/?attachment_id=495\" class=\"wp-image-495\" srcset=\"https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp1.png 796w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp1-269x300.png 269w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp1-768x856.png 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"793\" height=\"423\" src=\"https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp2.png\" alt=\"\" data-id=\"496\" data-link=\"https:\/\/www.gonscak.sk\/?attachment_id=496\" class=\"wp-image-496\" srcset=\"https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp2.png 793w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp2-300x160.png 300w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp2-768x410.png 768w\" sizes=\"auto, (max-width: 793px) 100vw, 793px\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"603\" src=\"https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp3-1024x603.png\" alt=\"\" data-id=\"497\" data-link=\"https:\/\/www.gonscak.sk\/?attachment_id=497\" class=\"wp-image-497\" srcset=\"https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp3-1024x603.png 1024w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp3-300x177.png 300w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp3-768x452.png 768w, https:\/\/www.gonscak.sk\/wp-content\/uploads\/2019\/09\/wp3.png 1538w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/li><\/ul>\n ","protected":false},"excerpt":{"rendered":"<p>I started on clean centos-8 server, created from netinstall cd. It is minimal instalation. So, lets begun. Check the version, to be installed: dnf info httpd Name : httpd Version : 2.4.37 Release : 11.module_el8.0.0+172+85fc1f40 So, let install it and allow http port on firewalld. And start apache server itself. dnf install httpd firewall-cmd &#8211;add-service=http &hellip; <a href=\"https:\/\/www.gonscak.sk\/?p=486\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Install WordPress on Centos-8-stream with apache (httpd)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[95,114,109,94,96,111,113,112,115,110],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-apache","tag-audit-log","tag-cento-8","tag-httpd","tag-mariadb","tag-mysql","tag-php","tag-sealert","tag-selinux","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=486"}],"version-history":[{"count":9,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/486\/revisions"}],"predecessor-version":[{"id":498,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/486\/revisions\/498"}],"wp:attachment":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}