{"id":867,"date":"2016-08-30T16:59:21","date_gmt":"2016-08-30T11:29:21","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=867"},"modified":"2016-08-30T17:08:23","modified_gmt":"2016-08-30T11:38:23","slug":"install-nginx-php-fpm-mariadb-on-centos-7","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-fpm-mariadb-on-centos-7\/","title":{"rendered":"Install Nginx, PHP-fpm, Mariadb on Centos 7"},"content":{"rendered":"<p>In this post, we are going post to explain installing nginx, PHP-fpm, mariadb on Centos 7. As a bouns, gonna add information on how to install wordpress on the host.<\/p>\n<h3><strong>Installation:<\/strong><\/h3>\n<h5>Mariadb Installation:<\/h5>\n<p>Let&#8217;s start with adding mariadb repository. Create a\u00a0<b>MariaDB.repo\u00a0<\/b>on \/etc\/yum.repos.d directory with the below content.<\/p>\n<p><code>vi \/etc\/yum.repos.d\/MariaDB.repo<\/code><\/p>\n<blockquote>\n<div># MariaDB 10.1 CentOS repository list &#8211; created 2016-08-25 16:09 UTC<\/div>\n<div># <a href=\"http:\/\/downloads.mariadb.org\/mariadb\/repositories\/\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/downloads.mariadb.org\/mariadb\/repositories\/&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNGoBuEkIBFg6nHmMc3xI6p1MHvZnw\" rel=\"noopener\">http:\/\/downloads.mariadb.org\/mariadb\/repositories\/<\/a><\/div>\n<div>[mariadb]<\/div>\n<div>name = MariaDB<\/div>\n<div>baseurl = <a href=\"http:\/\/yum.mariadb.org\/10.1\/centos7-amd64\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/yum.mariadb.org\/10.1\/centos7-amd64&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNGYtRzu7DzbEpYbMGi3PucgNmPg8Q\" rel=\"noopener\">http:\/\/yum.mariadb.org\/10.1\/centos7-amd64<\/a><\/div>\n<div>gpgkey=<a href=\"https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNHeNV1r61KurjvGp5-Y87VrpgYveQ\" rel=\"noopener\">https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB<\/a><\/div>\n<div>gpgcheck=1<\/div>\n<\/blockquote>\n<div>Install the mariadb server and enable the service on startup.<\/div>\n<div>\n<p>&nbsp;<\/p>\n<div><code>yum install MariaDB-server MariaDB-client<\/code><\/div>\n<div><code>systemctl enable mariadb<\/code><\/div>\n<div><code>systemctl start mariadb<\/code><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h5>Nginx Installation:<\/h5>\n<p>Create a nginx repo on\u00a0<em>\/etc\/yum.repos.d\/nginx.repo<\/em><\/p>\n<p><code>vi \/etc\/yum.repos.d\/nginx.<wbr \/>repo<\/code><\/p>\n<blockquote>\n<div>[nginx]<\/div>\n<div>name=nginx repo<\/div>\n<div>baseurl=<a href=\"http:\/\/nginx.org\/packages\/centos\/$releasever\/$basearch\/\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/nginx.org\/packages\/centos\/$releasever\/$basearch\/&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNHZj6g9rps450H6RkI6PEvVwNLWtg\" rel=\"noopener\">http:\/\/nginx.org\/packages\/centos\/$releasever\/$basearch\/<\/a><\/div>\n<div>gpgcheck=0<\/div>\n<div>enabled=1<\/div>\n<\/blockquote>\n<div>\n<p>Install nginx and enable to system startup.<\/p>\n<div><code>yum install nginx<\/code><\/div>\n<div><code>systemctl enable nginx<\/code><\/div>\n<div><code>systemctl start nginx<\/code><\/div>\n<\/div>\n<div><\/div>\n<h5>Install php-fpm and Dependencies:<\/h5>\n<p>Let&#8217;s install php-fpm and other php dependencies to run a php application on the host.<\/p>\n<p><code>yum install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php-xmlrpc php-mbstring php-snmp php-soap<\/code><\/p>\n<p>As a part of security, make <em>expose_php\u00a0<\/em>to off on php.ini.<\/p>\n<p><code>vi \/etc\/php.ini<\/code><\/p>\n<blockquote><p>expose_php = Off<\/p><\/blockquote>\n<h5>Website on Nginx:<\/h5>\n<p>We had done all the dependency installation. Now, its time to create a website on nginx. Starts with User creation.<\/p>\n<p><code>useradd wordpress\u00a0-d \/var\/www\/wordpress<\/code><\/p>\n<p>Uncomment the line\u00a0<em>listen = <a href=\"http:\/\/127.0.0.1:9000\/\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/127.0.0.1:9000&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNEsdMrVKmEbXx7JZ6UBSpYYPy-mAw\">127.0.0.1:9000<\/a>\u00a0<\/em>on\u00a0<b>\/etc\/php-fpm.d\/www.conf<\/b><\/p>\n<p><code>vim\u00a0\/etc\/php-fpm.d\/www.conf<\/code><\/p>\n<blockquote><p>listen = 127.0.0.1:9000<\/p><\/blockquote>\n<p>Uncomment\/add the following line on<b> \/etc\/nginx\/conf.d\/default.conf<\/b><\/p>\n<p><code>vi \/etc\/nginx\/conf.d\/default.conf<\/code><\/p>\n<blockquote>\n<div>location ~ \\.php$ {<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 root \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/var\/www\/wordpress\/html;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fastcgi_pass \u00a0 <a href=\"http:\/\/127.0.0.1:9000\/\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/127.0.0.1:9000&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNEsdMrVKmEbXx7JZ6UBSpYYPy-mAw\">127.0.0.1:9000<\/a>;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fastcgi_index \u00a0index.php;<\/div>\n<div>\u00a0 \u00a0 # \u00a0 \u00a0fastcgi_param \u00a0SCRIPT_FILENAME \u00a0\/scripts$fastcgi_script_name;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fastcgi_param \u00a0SCRIPT_FILENAME \u00a0 $document_root$fastcgi_script_name;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 include \u00a0 \u00a0 \u00a0 \u00a0fastcgi_params;<\/div>\n<div>\u00a0 \u00a0 }<\/div>\n<\/blockquote>\n<div>Create a new folder\u00a0<b>\/var\/www\/wordpress\/html\u00a0<\/b>and change the ownership to <em>wordpress<\/em>(in our case)<\/div>\n<div><code>mkdir -p \/var\/www\/wordpress\/html<\/code><\/div>\n<div><code>chown -R wordpress.wordpress\u00a0\/var\/www\/wordpress\/html<\/code><\/div>\n<div><\/div>\n<div>Add the following line on <b>\/etc\/nginx\/nginx.conf<\/b> inside &#8216;<em>http<\/em>&#8216; section<\/div>\n<div><code>vi \/etc\/nginx\/nginx.conf<\/code><\/div>\n<blockquote>\n<div>include \/etc\/nginx\/sites-enabled\/*.conf;<\/div>\n<\/blockquote>\n<div>Create a new file &#8216;<strong>domain<\/strong><b>.conf<\/b>&#8216; on the directory<b> \/etc\/nginx\/sites-enabled\/ <\/b>with the below content.<\/div>\n<div><code>vi \/etc\/nginx\/sites-enabled\/domain.conf<\/code><\/div>\n<blockquote>\n<div>\n<div>server {<\/div>\n<div>\u00a0 listen \u00a0 \u00a0 \u00a0 80;<\/div>\n<div>\u00a0 server_name sites.tldwww.sites.tld;<\/div>\n<div>\u00a0 location \/ {<\/div>\n<div>\u00a0 \u00a0 root \u00a0 \/var\/www\/wordpress\/html;<\/div>\n<div>\u00a0 \u00a0 index \u00a0index.php index.html index.htm;<\/div>\n<div>\u00a0 \u00a0 try_files $uri $uri\/ =404;<\/div>\n<div>\u00a0 \u00a0 }<\/div>\n<div><\/div>\n<div>\u00a0 error_page \u00a0 500 502 503 504 \u00a0\/50x.html;<\/div>\n<div>\u00a0 location = \/50x.html {<\/div>\n<div>\u00a0 \u00a0 root \u00a0 \/var\/www\/wordpress\/html;<\/div>\n<div>\u00a0 }<\/div>\n<div>\u00a0 location ~ \\.php$ {<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 root \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/var\/www\/wordpress\/html;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fastcgi_pass \u00a0 <a href=\"http:\/\/127.0.0.1:9000\/\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/127.0.0.1:9000&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNEsdMrVKmEbXx7JZ6UBSpYYPy-mAw\">127.0.0.1:9000<\/a>;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fastcgi_index \u00a0index.php;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fastcgi_param \u00a0SCRIPT_FILENAME \u00a0 $document_root$fastcgi_script_name;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 include \u00a0 \u00a0 \u00a0 \u00a0fastcgi_params;<\/div>\n<div>\u00a0 \u00a0 }<\/div>\n<div>}<\/div>\n<\/div>\n<\/blockquote>\n<div>\n<div>Restart the nginx and php-fpm service.<\/div>\n<div>\n<div><code>systemctl restart nginx<\/code><\/div>\n<div><code>systemctl restart php-fpm<\/code><\/div>\n<\/div>\n<\/div>\n<div><\/div>\n<div>All Done \ud83d\ude42 Now, its time to install wordpress on the host.<\/div>\n<div><\/div>\n<h5>WordPress installation:<\/h5>\n<p>Download wordpress latest version to domain documentroot<\/p>\n<p><code>cd \/var\/www\/wordpress\/html<\/code><\/p>\n<p><code>wget <a href=\"http:\/\/wordpress.com\/latest.tar.gz\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/wordpress.com\/latest.tar.gz&amp;source=gmail&amp;ust=1472521866756000&amp;usg=AFQjCNGGQObnSUaBk19ayES_h_Iq16Hetw\" rel=\"noopener\">http:\/\/wordpress.com\/latest.<wbr \/>tar.gz<\/a><\/code><\/p>\n<div><code>tar -xzf latest.tar.gz<\/code><\/div>\n<div><code>cp -pr wordpress\/* .<\/code><\/div>\n<div><\/div>\n<div>Create a new database, new user and provided access to user. Access mysql prompt &#8216;<em>mysql&#8217; \u00a0<\/em>and run the following command.<\/div>\n<div>\n<p>&nbsp;<\/p>\n<div><code>create database wordpress;<\/code><\/div>\n<div><code>grant all privileges on wordpress.* to wordpress@localhost identified by &lt;password&gt;;<\/code><\/div>\n<div><code>flush privileges;<\/code><\/div>\n<\/div>\n<div><\/div>\n<div>Access the\u00a0<strong>domain.tld\u00a0<\/strong>in browser and complete the installation.<\/div>\n<div><\/div>\n<div>Comment your queries in this post incase if you face any issues.<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we are going post to explain installing nginx, PHP-fpm, mariadb on Centos 7. As a bouns, gonna [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-867","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-dZ","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=867"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/867\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}