
For this example we will used NGINX as reverse proxy for testing our PHP-FPM service. NGINX is a web server with excelent performance and low memory footprint also it can be used as a reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols as well as load balancer.
-s = login shell (no login shell for this case because www-data was not created for login purpose)įor security reasons we will change the owner, group and perms for /var/NGINX. Useradd -system -m -d /var/www -s /usr/sbin/nologin -g www-data www-dataĪbove command create the system group and system user www-data where: If the user and group under the php-fpm process will be run does not exists then you must created them before start php-fpm service. sapi/fpm/rvice /usr/lib/systemd/system/rvice # echo "zend_extension=opcache.so" > /etc/php/conf.d/20-opcache.ini Creating PHP-FPM init service # cp -v. OPcache improves PHP performance by storing precompiled script bytecode in shared memory serving request in fastest way. Only specific IPs can connect to php-fpm service, look for listen.allowed_clients directive and set its value to listen.allowed_clients = 127.0.0.1,192.168.0.106,192.168.0.107,192.168.0.108 Enable OpCache To allow php-fpm listen on every interface you must look for the listen directive and set its value. Creating PHP-FPM configuration file # cp -pv /etc/php/ /etc/php/nf Edit /etc/php/nf # cp -v php.ini-production /etc/php/php.iniĪdjust the ini directives according your needs. As we’re compiling for PROD server we type the following command. ini files versions: development and production. Where -f = FPM support, s = systemd integration Install # cd php-5.6.12 & make install Creating configuration file # mkdir -p /etc/php/conf.d /usr/lib/php/modules /usr/share/pearĬreate PCRE symbolic link to avoid: “configure: error: Could not find libpcre.(a|so) in /usr” # ln -s /usr/lib64/libpcre.so.1.2.0 /usr/lib/libpcre.so systemd also is a suite of system management daemons, libraries, and utilities designed as a central management and configuration for GNU/Linux operating system.įirst create necessary DIR that will be used during compilation process. Systemd is replacement for SysV initialization. PHP-FPM (FastCGI Process Manager) is an alternative FastCGI implementation for PHP, bundled with the official PHP distribution since version 5.3.3. If you compile PHP with fpm support you must edit php-build.sh and set the user and group under the fpm process will be run # wget & \Ĭhmod a+x php-build.sh Build PHP with FPM support and systemd integration You can modify php-build.sh according your needs.
Enable the most used extensions as: curl, openssl, intl, mysql, pcre, … and it allows to install PHP in custom DIR, it offers options to compile PHP with Apache (prefork or worker) or fpm support. Php-build.sh script is helper for PHP compilation process.
#Centos 7 install mysql for php 5.6 download#
Libcurl-devel libicu-devel gd-devel readline-devel libmcrypt-devel systemd-devel Download php-build.sh script from Github mcrypt is available in EPEL repo then you need to type # yum -y install epel-releaseĪfter # yum -y install libxml2-devel openssl openssl-devel pcre-devel sqlite-devel bzip2-devel \ We will compile PHP with XML, SSL, PCRE, SQLite, bzip2, curl, GD, mcrypt … support. In the previous step we download a php-5.6.12.tar.xz file so we can unpackage it using tar tool # tar xJvf php-5.6.12.tar.xzį = file Installing GNU Compiler Collection and essential tools # yum -y install gcc gcc-c++ make automake autoconf bison flex libtool libstdc++-devel Installing dependencies
Another simple solution is typing in your console from your server # wget Unpacking PHP packages Go to site Downloads section and select the PHP-6.X.X version that you want to compile (5.6.12 at time of writing this tutorial), select your nearest mirror and downloat it then upload to your server using rsycn or scp.
You have some knowlegde about compilation process. You are familiar with console and shell commands. You have some knowledges about GNU/Linux operating system. – Low learning curve and more Why compile from sourceĬompiling from source is a good option if you want to:Īfter finishing this tutorial you will be able to compile PHP by yourself and get some knowledge about interaction between NGINX and PHP-FPM service. – Database drivers: MySQL, PostgreSQL, SQLite, Firebird, MSSQL, SQL Server … If you are new in the PHP world and you are looking a programming language for your project you will find. Today heavy load web sites such as: Facebook and Wikipedia are powered by PHP. PHP is a general purpose scripting language that it’s mainly used for web development.