{"id":1053,"date":"2020-06-07T23:46:37","date_gmt":"2020-06-07T20:46:37","guid":{"rendered":"http:\/\/www.plugged.in\/?p=1053"},"modified":"2021-07-03T19:20:36","modified_gmt":"2021-07-03T16:20:36","slug":"php-7-on-centos-7-with-php-fpm-2","status":"publish","type":"post","link":"https:\/\/www.veriteknik.net.tr\/en\/php-7-on-centos-7-with-php-fpm-2\/","title":{"rendered":"PHP 7 on CentOS 7 with PHP-FPM"},"content":{"rendered":"<p>Most of the yum repositories don&#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. I decided to put all required packages to the compilation, so most probably you wouldn&#8217;t need additional packages, just a quick tip, if you need additional packages you can install via pecl or pear tools.<\/p>\n<h3>Which PHP configure options should I use before compiling?<\/h3>\n<p>If you ever need to get the list of modules installed in your current PHP, type the following command via console:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">php -m<\/pre>\n<p>So, take a list of your current configuration and check the configure list below in order to have a compatible compilation to your existing older version of PHP.<\/p>\n<p>Advice: First of all, you should consider removing PHP packages from your server before compiling PHP, but be aware your codes will be visible till you install the compiled version to your server, consider shutting down your apache server for a while.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">yum erase php*<\/pre>\n<p>Before downloading the code, install &#8220;Development Tools&#8221; by typing:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">yum groupinstall \"Development Tools\"<\/pre>\n<p>and install other related header files:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">yum install wget httpd-devel libtool-ltdl-devel libxml2-devel \\\nbzip2-devel net-snmp-devel openssl-devel pcre-devel \\\ncurl-devel gd-devel mysql-devel libxslt-devel \\\npostgresql-devel gmp-devel systemd-devel<\/pre>\n<p>Download &amp; install libmcrypt<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">cd \/usr\/src\nwget http:\/\/downloads.sourceforge.net\/project\\\n\/mcrypt\/Libmcrypt\/2.5.8\/libmcrypt-2.5.8.tar.gz\ntar zxvf libmcrypt-2.5.8.tar.gz \ncd libmcrypt-2.5.8\n.\/configure -libdir=\/usr\/lib64\nmake\nmake install<\/pre>\n<p>\u00a0<\/p>\n<p>Download &amp; extract PHP 7.0.4 release:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">wget http:\/\/php.net\/get\/php-7.0.4.tar.gz\/from\/this\/mirror\nmv mirror \/usr\/src\/php-7.0.4.tar.gz\ncd \/usr\/src\/\ntar zxvf \/usr\/src\/php-7.0.4.tar.gz \ncd php-7.0.4\n.\/configure \\\n --with-apxs2 \\\n --with-curl=\/usr\/local\/lib \\\n --with-config-file-path=\/etc \\\n --with-config-file-scan-dir=\/etc\/php.d \\\n --with-pic \\\n --with-gd \\\n --with-gettext \\\n --with-jpeg-dir=\/usr\/local\/lib \\\n --with-freetype-dir=\/usr\/local\/lib \\\n --enable-sockets \\\n --with-kerberos \\\n --with-openssl \\\n --with-mhash \\\n --with-mcrypt=\/usr\/local\/lib \\\n --with-mysqli=\/usr\/bin\/mysql_config \\\n --with-pdo-mysql=\/usr \\\n --with-pdo-pgsql=\/usr \\\n --with-pcre-regex=\/usr \\\n --with-pear \\\n --with-gmp \\\n --with-pgsql \\\n --with-png-dir=\/usr\/local\/lib \\\n --with-xsl \\\n --with-zlib \\\n --with-zlib-dir=\/usr\/local\/lib \\\n --with-iconv \\\n --with-libxml-dir=\/usr \\\n --enable-bcmath \\\n --enable-calendar \\\n --enable-exif \\\n --enable-ftp \\\n --enable-gd-native-ttf \\\n --enable-soap \\\n --enable-sockets \\\n --enable-mbstring \\\n --enable-zip \\\n --enable-wddx \\\n --enable-shmop \\\n --with-libdir=lib64 \\\n --disable-debug \\\n --with-bz2 \\\n --enable-gd-native-ttf \\\n --enable-xml \\\n --with-snmp=\/usr \\\n --enable-json \\\n --with-fpm-user=apache\\\n --with-fpm-group=apache\\\n --enable-fpm \\\n --with-fpm-systemd\n<\/pre>\n<p>Make &amp; Install by typing:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">make\nmake install\ncp php.ini-production \/etc\/php.ini\n<\/pre>\n<p>Run the following to enable systemd service for PHP:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">cat &lt;&lt;&lt; '\n[Unit]\nDescription=The PHP FastCGI Process Manager - VeriTeknik\nAfter=syslog.target network.target\n\n[Service]\nType=notify\nPIDFile=\/var\/run\/php-fpm.pid\nExecStart=\/usr\/local\/sbin\/php-fpm --nodaemonize \\\n--fpm-config \/etc\/php-fpm.conf\nExecReload=\/bin\/kill -USR2 $MAINPID\n\n[Install]\nWantedBy=multi-user.target\n' &gt; \/usr\/lib\/systemd\/system\/php-fpm.service\nsystemctl enable php-fpm\n<\/pre>\n<p>Get rid of obsolete settings:<\/p>\n<pre class=\"brush: shell; gutter: true; first-line: 1\">sed -i 's#;date.timezone =.*# \u00a0date.timezone = \"Europe\/Istanbul\"#' \/etc\/php.ini\nsed -i 's#upload_max_filesize =.*#upload_max_filesize = 200M#' \/etc\/php.ini\nsed -i 's#post_max_size =.*#post_max_size = 200M#' \/etc\/php.ini\ncat &lt;&lt;&lt; ' include=\/etc\/php-fpm.d\/*.conf [global] pid = \\ \n\/run\/php-fpm\/php-fpm.pid error_log = \/var\/log\/php-fpm\/error.log \\\ndaemonize = no ' &gt; \/etc\/php-fpm.conf\nmkdir \/etc\/php-fpm.d\n<\/pre>\n<p>\u00a0<\/p>\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<\/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; '\n[www]\nlisten = 127.0.0.1:9001\n \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\n\nslowlog = \/var\/log\/php-fpm\/www-slow.log\n \ncatch_workers_output = yes\n \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\/php-fpm.d\/plugged.conf\n\nmkdir \/run\/php-fpm\/\nmkdir \/var\/log\/php-fpm\/\ntouch \/var\/log\/php-fpm\/error.log\nmkdir {\/home\/plugged\/logs\/,\/home\/plugged\/session}\nchown -R plugged:plugged \/home\/plugged\nsystemctl start php-fpm\nsed -i 's\/DirectoryIndex index.html.*\/  DirectoryIndex index.html index.html.var index.php\/' \/etc\/httpd\/conf\/httpd.conf<\/pre>\n<p>please let us know if you find any mistake<\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of the yum repositories don&#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. I decided to put all required packages to the compilation, so most probably you wouldn&#8217;t need additional packages, just a quick tip, if you need [&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,1443,1446,1448,1447,939,671,937,897,643,1444,936,856,644,859,337,1142,854,669,1246],"class_list":["post-1053","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 repositories don&#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. I decided to put all required packages to the compilation, so most probably you wouldn&#8217;t need additional packages, just a quick tip, if you need&hellip;","_links":{"self":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/1053","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=1053"}],"version-history":[{"count":5,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/1053\/revisions"}],"predecessor-version":[{"id":8008,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/1053\/revisions\/8008"}],"wp:attachment":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/media?parent=1053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/categories?post=1053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/tags?post=1053"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/yst_prominent_words?post=1053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}