Product SiteDocumentation Site

3. NginX and PHP

Install NginX and PHP:
yum install nginx php php-fpm php-common php-pear php-pdo php-pgsql php-pecl-apc php-gd php-mbstring php-mcrypt php-xml nc
Enable NginX at boot:
systemctl enable nginx.service


nginx.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig nginx on
Start NginX
systemctl start nginx.service
edit /etc/php-fpm.d/www.conf file and change the user and group value from apache to nginx
user = nginx
group = nginx
change ownership of /var/lib/php/session/ directory
chown root:nginx /var/lib/php/session/
Change /etc/php.ini, set and enable next values:
date.timezone = "Europe/Brussels"
Enable php-fpm at boot:
systemctl enable php-fpm.service


php-fpm.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig php-fpm on
Start php-fpm
systemctl start php-fpm.service
edit /etc/nginx/conf.d/default.conf and make the following changes
# The default server
server {
    listen       80;
    server_name  _;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;

    # proxy the PHP scripts to Apache listening on
    #location ~ \.php$ {
    #    proxy_pass;

    # pass the PHP scripts to FastCGI server listening on
    # uncomment next lines
    location ~ \.php$ {
    #       root           html;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    # uncomment next lines
    location ~ /\.ht {
        deny  all;
Restart NginX
systemctl restart nginx.service