{"id":1076,"date":"2019-09-18T23:57:42","date_gmt":"2019-09-18T20:57:42","guid":{"rendered":"http:\/\/www.plugged.in\/?p=1076"},"modified":"2019-09-18T23:57:42","modified_gmt":"2019-09-18T20:57:42","slug":"php-7-on-centos-7-with-php-fpm","status":"publish","type":"post","link":"https:\/\/www.veriteknik.net.tr\/en\/php-7-on-centos-7-with-php-fpm\/","title":{"rendered":"PHP 7 on CentOS 7 with PHP-FPM"},"content":{"rendered":"<p>Most of the yum repos doesn&#8217;t include PHP7.0.X on current releases for the time being. So if you need PHP7.0.X, you need to compile and build it for your self or you need to add additional repos to yum, which will be much more easier and much more flexible to update later. So, on a clean installed server proceed with the installation of Epel and Remi repos, in case you don&#8217;t have wget, also install it:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">yum install epel-release\nyum install net-tools, bind-utils # optional life savers \nrpm -Uvh http:\/\/mirror.veriteknik.net.tr\/remi\/enterprise\/remi-release-7.rpm\nyum install php70-php-fpm php70-php-cli php70-php-gd php70-php-json \\\nphp70-php-mbstring php70-php-mcrypt php70-php-mysqlnd php70-php-xml\nyum install nginx<\/pre>\n<p>&nbsp;<br \/>\nPlease note that if you need additional PHP packages, you can search them with the following command:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">yum list php70-*\n#Available Packages\n#php70-php-opcache.x86_64\n#.\n#.\n#php70-php-pecl-crypto.x86_64\n#php70-php-pecl-geoip.x86_64 \n#php70-php-pecl-imagick.x86_64\n#php70-php-pecl-memcache.x86_64\n#php70-php-pecl-xdebug.x86_64\n#php70-php-pgsql.x86_64\n#php70-php-soap.x86_64\n#php70-php-xmlrpc.x86_64\n#..\n# and to install a package you desire, type the name:\nyum install php70-php-pgsql\n<\/pre>\n<p>Run the following to enable systemd service for PHP-FPM:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">systemctl enable php70-php-fpm\nsystemctl enable nginx<\/pre>\n<p>Disable SELINUX, set to disabled:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">vi \/etc\/selinux\/config\n# This file controls the state of SELinux on the system.\n# SELINUX= can take one of these three values:\n# enforcing - SELinux security policy is enforced.\n# permissive - SELinux prints warnings instead of enforcing.\n# disabled - No SELinux policy is loaded.\n<strong>SELINUX=disabled<\/strong>\n# SELINUXTYPE= can take one of three two values:\n# targeted - Targeted processes are protected,\n# minimum - Modification of targeted policy. Only selected processes are protected.\n# mls - Multi Level Security protection.\nSELINUXTYPE=targeted<\/pre>\n<p>type SHIFT+ZZ to save and exit, and for the time beign type setenforce 0 to disable SELINUX temproray.<br \/>\nNext step is to get rid of obsolete settings:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">sed -i 's#;date.timezone =.*# &nbsp;date.timezone = \\ \n\"Europe\/Istanbul\"#' \/etc\/opt\/remi\/php70\/php.ini\nsed -i 's#upload_max_filesize =.*#upload_max_filesize = \\\n200M#' \/etc\/opt\/remi\/php70\/php.ini\nsed -i 's#post_max_size =.*#post_max_size = \\\n200M#' \/etc\/opt\/remi\/php70\/php.ini\n\n<\/pre>\n<p>You need to create the appropriate user account the fpm process will run on, as a sample we use <strong>plugged<\/strong> as a user:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">useradd plugged\nchmod 755 \/home\/plugged\nmkdir \/home\/plugged\/{logs,public_html,session}\ntouch \/home\/plugged\/logs\/{mphp_error.log,php-fpm-slow.log}\nchown -R vtt:vtt \/home\/plugged\/public_html\/<\/pre>\n<p>create the php-fpm process config for the specific site:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">cat &lt;&lt;&lt; '[plugged] \nlisten = 127.0.0.1:9001\nlisten.allowed_clients = 127.0.0.1 \nlisten.owner = plugged \nlisten.group = plugged \nuser = plugged \ngroup = plugged \npm = dynamic \npm.max_children = 50 \npm.start_servers = 5 \npm.min_spare_servers = 5 \npm.max_spare_servers = 35 \nslowlog = \/home\/plugged\/logs\/php-fpm-slow.log \ncatch_workers_output = yes \nphp_admin_value[error_log] = \/home\/plugged\/logs\/mphp_error.log \nphp_admin_flag[log_errors] = on \nphp_value[session.save_handler] = files \nphp_value[session.save_path] = \/home\/plugged\/session ' \\\n&gt; \/etc\/opt\/remi\/php70\/php-fpm.d\/plugged.conf\n<\/pre>\n<p>Turn on PHP-FPM by typing:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">systemctl start php70-php-fpm.service\n<\/pre>\n<p>If it fails to start, you can check the logs by typing<br \/>\nsystemctl status php70-php-fpm.service<\/p>\n<p>Also please check the service is running by typing netstat so if the port is open, you should see that:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">netstat -tulpn | grep php-fpm\n#tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      908\/php-fpm: master \n#tcp        0      0 127.0.0.1:9001          0.0.0.0:*               LISTEN      908\/php-fpm: master \n<\/pre>\n<p>please let us know if you find any mistake<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of the yum repos doesn&#8217;t include PHP7.0.X on current releases for the time being. So if you need PHP7.0.X, you need to compile and build it for your self or you need to add additional repos to yum, which will be much more easier and much more flexible to update later. So, on a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[370,416],"tags":[366,414,415,375,417,418,419,420,421,422],"yst_prominent_words":[858,864,671,861,851,853,856,644,852,859,862,860,857,863,854,669,855],"class_list":["post-1076","post","type-post","status-publish","format-standard","hentry","category-linux","category-php-programming","tag-centos","tag-freetds","tag-mssql","tag-php","tag-php-5-6","tag-php-5-6-3","tag-php-fpm","tag-service","tag-systemctl","tag-systemd"],"jetpack_featured_media_url":"","uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"ckaraca","author_link":"https:\/\/www.veriteknik.net.tr\/en\/author\/ckaraca\/"},"uagb_comment_info":0,"uagb_excerpt":"Most of the yum repos doesn&#8217;t include PHP7.0.X on current releases for the time being. So if you need PHP7.0.X, you need to compile and build it for your self or you need to add additional repos to yum, which will be much more easier and much more flexible to update later. So, on a&hellip;","_links":{"self":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/1076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/comments?post=1076"}],"version-history":[{"count":1,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/1076\/revisions"}],"predecessor-version":[{"id":7516,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/1076\/revisions\/7516"}],"wp:attachment":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/media?parent=1076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/categories?post=1076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/tags?post=1076"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/yst_prominent_words?post=1076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}