Install Nginx/PHP-FPM on Fedora 18/17, CentOS/RHEL 6.4/5.9

I have once written Install nginx, PHP 5.3 and FastCGI on CentOS 5.5, Fedora 13, Red Hat RHEL 5.5/6 guide, but this guide is “updated” version, howto install Nginx with PHP 5.4.13 and PHP-FPM on Fedora 18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9. PHP-FPM is easier to use and configure than FastCGI and some tests says that PHP-FPM is even much more efficient than FastCGI.

Nginx (engine x) is a robust, small and high performance http server, reverse proxy server and also mail proxy server.

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.

Install Nginx, PHP 5.4.13 and PHP-FPM on Fedora 18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

1. Change to root user.

sudo -i
## OR ##
su -

2. Install needed repositories

Fedora 18/17/16/15/14 Remi repository

## Remi Dependency on Fedora 18/17/16
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
 
## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm
 
## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm
 
## Fedora 16 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-16.rpm
 
## Fedora 15 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-15.rpm
 
## Fedora 14 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9 Remi repository

## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
 
## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
 
## CentOS 5 and Red Hat (RHEL) 5 ## 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9 Nginx repository

Create file /etc/yum.repos.d/nginx.repo and add following content to repo file:
CentOS

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

Red Hat (RHEL)

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=0
enabled=1

3. Install Nginx, PHP 5.4.13 and PHP-FPM

Fedora 18/17/16/15/14

yum --enablerepo=remi install nginx php-fpm php-common

CentOS 6.4/5.9 and Red Hat (RHEL) 6.4/5.9

yum --enablerepo=remi,remi-test install nginx php-fpm php-common

4. Install PHP 5.4.13 modules

  • APC (php-pecl-apc) – APC caches and optimizes PHP intermediate code
  • CLI (php-cli) – Command-line interface for PHP
  • PEAR (php-pear) – PHP Extension and Application Repository framework
  • PDO (php-pdo) – A database access abstraction module for PHP applications
  • MySQL (php-mysql) – A module for PHP applications that use MySQL databases
  • PostgreSQL (php-pgsql) – A PostgreSQL database module for PHP
  • MongoDB (php-pecl-mongo) – PHP MongoDB database driver
  • SQLite (php-sqlite) – Extension for the SQLite V2 Embeddable SQL Database Engine
  • Memcache (php-pecl-memcache) – Extension to work with the Memcached caching daemon
  • Memcached (php-pecl-memcached) – Extension to work with the Memcached caching daemon
  • GD (php-gd) – A module for PHP applications for using the gd graphics library
  • XML (php-xml) – A module for PHP applications which use XML
  • MBString (php-mbstring) – A module for PHP applications which need multi-byte string handling
  • MCrypt (php-mcrypt) – Standard PHP module provides mcrypt library support

Select what you need: APC, CLI, PEAR, PDO, MySQL, PostgreSQL, MongoDB, SQLite, Memcache, Memcached, GD, MBString, MCrypt, XML

More info about PHP APC from PHP APC Configuration and Usage Tips and Tricks

Fedora 18/17/16/15/14

yum --enablerepo=remi install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

CentOS 6.4/5.9 and Red Hat (RHEL) 6.4/5.9

yum --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

5. Stop httpd (Apache) server, Start Nginx HTTP server and PHP-FPM (FastCGI Process Manager)

Stop httpd (Apache)

/etc/init.d/httpd stop
## OR ##
service httpd stop

Start Nginx

/etc/init.d/nginx start ## use restart after update
## OR ##
service nginx start ## use restart after update

Start PHP-FPM

/etc/init.d/php-fpm start ## use restart after update
## OR ##
service php-fpm start ## use restart after update

6. Autostart Nginx and PHP-FPM on boot, also prevent httpd (Apache) autostarting on boot

Prevent httpd (Apache) autostarting on boot

chkconfig httpd off

Autostart Nginx on boot

chkconfig --add nginx
chkconfig --levels 235 nginx on

Autostart PHP-FPM on boot

chkconfig --add php-fpm
chkconfig --levels 235 php-fpm on

7. Configure Nginx and PHP-FPM

Create directory layout for your site

I use here testsite.local site, but this could of course be your real site, like www.if-not-true-then-false.com.

## public_html directory and logs directory ##
mkdir -p /srv/www/testsite.local/public_html
mkdir /srv/www/testsite.local/logs
chown -R apache:apache /srv/www/testsite.local

Alternative setup to add logs under /var/log directory.

## public_html directory and logs directory ##
mkdir -p /srv/www/testsite.local/public_html
mkdir -p /var/log/nginx/testsite.local
chown -R apache:apache /srv/www/testsite.local
chown -R nginx:nginx /var/log/nginx

Note: I use apache user and group here, because PHP-FPM runs as apache default (apache choosed to be able to access some dir as httpd). If you use some other user on your php-fpm conf then change this accordingly.

Create and configure virtual host directories under /etc/nginx

mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled

Add following lines to /etc/nginx/nginx.conf file, after “include /etc/nginx/conf.d/*.conf” line (inside http block).

## Load virtual host conf files. ##
include /etc/nginx/sites-enabled/*;

Create testsite.local virtual host file

Add following content to /etc/nginx/sites-available/testsite.local file. This is very basic virtual host config.

server {
    server_name testsite.local;
    access_log /srv/www/testsite.local/logs/access.log;
    error_log /srv/www/testsite.local/logs/error.log;
    root /srv/www/testsite.local/public_html;
 
    location / {
        index index.html index.htm index.php;
    }
 
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/testsite.local/public_html$fastcgi_script_name;
    }
}

Link your virtual host to /etc/nginx/sites-enabled

cd /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/testsite.local
service nginx restart

Add your testsite.local “domain” to /etc/hosts file

/etc/hosts file Nginx on same machine
127.0.0.1 … row should look like example following:

127.0.0.1               localhost.localdomain localhost testsite.local

And if you use another machine where you are running your Nginx server, then add it’s public IP as following:

10.0.2.19               wordpress

Note: This is just very simple basic configuration, but if you want configure and optimize Nginx and PHP-FPM more then check following guide, Nginx and PHP-FPM Configuration and Optimizing Tips and Tricks

8. Test your Nginx and PHP-FPM setup

Create /srv/www/testsite.local/public_html/index.php file with following content:

<?php 
    phpinfo();
?>

Access following address, with your browser. http://testsite.local/

Enable Remote Connection to Nginx Web Server (Open Port 80 on Iptables Firewall)

1. Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

2. Add following line before COMMIT:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

3. Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

4. Test remote connection

Access following address, with your browser. http://your.domain/

Follow If Not True Then False Updates!

133 Comments

  1. Hey, thank you for this clean tutorial.

    Just one little thing, don’t know why but in order to install php-fpm I had to use

    yum --enablerepo=remi install php-fpm

    • You are welcome! :)

      So you could not use following command?

      yum --enablerepo=remi install nginx php php-fpm php-common
  2. Thanks for your post. nginx fails to start after following the directions for fedora 16. this is what systemctl status says:

    Loaded: loaded (/etc/rc.d/init.d/nginx)
    Active: failed since Sat, 19 Nov 2011 09:02:52 -0700; 25s ago
    Process: 14752 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE)
    CGroup: name=systemd:/system/nginx.service

    I am new to this, do you have any suggestions for what to do to make it work?
    Thanks

    • Hi ebobo,

      Check your /var/log/messages log file:

      grep nginx /var/log/messages

      Do you see something like following:

      Nov 19 22:06:09 fedora nginx[17850]: Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Nov 19 22:06:10 fedora nginx[17850]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Nov 19 22:06:10 fedora nginx[17850]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Nov 19 22:06:11 fedora nginx[17850]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Nov 19 22:06:11 fedora nginx[17850]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Nov 19 22:06:12 fedora nginx[17850]: nginx: [emerg] still could not bind()
      Nov 19 22:06:12 fedora nginx[17850]: [FAILED]
      Nov 19 22:06:12 fedora systemd[1]: nginx.service: control process exited, code=exited status=1
      Nov 19 22:06:12 fedora systemd[1]: Unit nginx.service entered failed state.

      You maybe have httpd (apache) running and using port 80, stop it and try to start nginx again:

      systemctl stop httpd.service
       
      /etc/init.d/nginx start
      ## OR more fedora 16 way ##
      systemctl start nginx.service

      Then you can run following command to disable httpd (apache):

      systemctl disable httpd.service
      • That was the problem, thanks you!

  3. Hi JR, thanks for the great guide.

    In Step 5, should the Stop httpd (Apache) commands be ‘stop’ rather than ‘start’?

    /etc/init.d/httpd stop
    ## OR ##
    service httpd stop

    • Thanks Ben, yes stop it should be…it’s fixed now! :)

    • if you are using f16
      systemctl stop httpd.service

      • Yes systemctl stop httpd.service is more Fedora 16 style, but also /etc/init.d/httpd stop and service httpd stop works, because it is actually redirected to systemctl.

        # service httpd stop
        Stopping httpd (via systemctl):                            [  OK  ]
  4. Before doing these steps, I needed to run the following:

    yum -y update rpm

    To fix:
    error: Failed dependencies:
    rpmlib(FileDigests) <= 4.6.0-1 is needed by epel-release-6-5.noarch
    rpmlib(PayloadIsXz) <= 5.2-1 is needed by epel-release-6-5.noarch

    This allowed me to follow this tutorial.

    • Hi Josh,

      Thanks for this note. I normally assume that every users run up-to-date systems… :)

      • I too am getting this but did run yum update before starting the installations.

        error: Failed dependencies:
        rpmlib(FileDigests) <= 4.6.0-1 is needed by epel-release-6-5.noarch
        rpmlib(PayloadIsXz) <= 5.2-1 is needed by epel-release-6-5.noarch

        running CentOS release 5.8 32 bit

      • Ignore that. RTFM.. I did but copied wrong line. DOH

  5. Thanks for this tuts, I already set my server this way and all is just working, One problem persist is that after I install WordPress on it, when I try to add new themes on wp-content/themes/ directory manually, the themes doesn’t appears on the dashboard. And when I try to add it from upload menu, it doesn’t works either. Could you help me please :) Thanks a lot before.

    • Hi Tiyo,

      Could you post following output from your wp-content/ and wp-content/themes/ directory:

      ls -la wp-content/
       
      ## AND ##
       
      ls -la wp-content/themes/
       
      ## AND ##
       
      grep -e "user =" -e "group =" /etc/php-fpm.d/[your_wordpress_conf].conf
  6. Hi JR..
    In step 7, after run this command :
    cd /etc/nginx/sites-enabled/
    ln -s /etc/nginx/sites-available/testsite.local
    service nginx restart

    i got this error :
    [root@glenn etc]# /etc/init.d/nginx start
    Starting nginx (via systemctl): Job failed. See system logs and 'systemctl status' for details.
    [FAILED]

    here my log :
    [root@glenn etc]# grep nginx /var/log/messages
    Dec 12 15:22:01 glenn nginx[1130]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 12 15:22:01 glenn nginx[1130]: [FAILED]
    Dec 12 15:22:02 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 12 15:22:02 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 12 15:26:56 glenn nginx[1155]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 12 15:26:56 glenn nginx[1155]: [FAILED]
    Dec 12 15:26:56 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 12 15:26:56 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 12 15:35:40 glenn nginx[1129]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 12 15:35:40 glenn nginx[1129]: [FAILED]
    Dec 12 15:35:40 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 12 15:35:40 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 13 03:42:07 glenn nginx[1156]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 13 03:42:07 glenn nginx[1156]: [FAILED]
    Dec 13 03:42:07 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 13 03:42:07 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 13 03:45:39 glenn nginx[1130]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 13 03:45:39 glenn nginx[1130]: [FAILED]
    Dec 13 03:45:39 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 13 03:45:39 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 13 06:07:39 glenn nginx[1144]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 13 06:07:39 glenn nginx[1144]: [FAILED]
    Dec 13 06:07:39 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 13 06:07:39 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 13 06:13:51 glenn nginx[1205]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 13 06:13:51 glenn nginx[1205]: [FAILED]
    Dec 13 06:13:51 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 13 06:13:51 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 13 06:22:55 glenn nginx[1242]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 13 06:22:55 glenn nginx[1242]: [FAILED]
    Dec 13 06:22:55 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 13 06:22:55 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 02:36:45 glenn nginx[1149]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 02:36:45 glenn nginx[1149]: [FAILED]
    Dec 15 02:36:45 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 02:36:45 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:04:30 glenn nginx[1161]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:04:30 glenn nginx[1161]: [FAILED]
    Dec 15 08:04:30 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:04:30 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:48:58 glenn nginx[3408]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:48:58 glenn nginx[3408]: [FAILED]
    Dec 15 08:48:58 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:48:58 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:49:15 glenn nginx[3452]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:49:15 glenn nginx[3452]: [FAILED]
    Dec 15 08:49:15 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:49:15 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:50:16 glenn nginx[3485]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:50:16 glenn nginx[3485]: [FAILED]
    Dec 15 08:50:16 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:50:16 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:52:36 glenn nginx[3545]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:52:36 glenn nginx[3545]: [FAILED]
    Dec 15 08:52:36 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:52:36 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:54:19 glenn nginx[3588]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:54:19 glenn nginx[3588]: [FAILED]
    Dec 15 08:54:19 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:54:19 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:54:34 glenn nginx[3605]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:54:34 glenn nginx[3605]: [FAILED]
    Dec 15 08:54:34 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:54:34 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:54:43 glenn nginx[3623]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:54:43 glenn nginx[3623]: [FAILED]
    Dec 15 08:54:43 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:54:43 glenn systemd[1]: Unit nginx.service entered failed state.
    Dec 15 08:54:56 glenn nginx[3644]: Starting nginx: nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:1
    Dec 15 08:54:56 glenn nginx[3644]: [FAILED]
    Dec 15 08:54:56 glenn systemd[1]: nginx.service: control process exited, code=exited status=1
    Dec 15 08:54:56 glenn systemd[1]: Unit nginx.service entered failed state.

    So, how to solve it?
    Thx b4.. :)

    • Hi glenn,

      Could you post content of your /etc/nginx/nginx.conf file?

      • Here :
        location ~ \.php$ {
        root html;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        include fastcgi_params;
        }
        include /etc/nginx/conf.d/*.conf
        include /etc/nginx/sites-enabled/*;

        • Your /ect/nginx/nginx.conf config should example look like following:

          user              nginx;
          worker_processes  1;
          error_log  /var/log/nginx/error.log;
          pid        /var/run/nginx.pid;
           
          events {
              worker_connections  1024;
          }
           
          http {
              include       /etc/nginx/mime.types;
              default_type  application/octet-stream;
           
              log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                                '$status $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
           
              access_log  /var/log/nginx/access.log  main;
              sendfile        on;
              keepalive_timeout  65;
           
              include /etc/nginx/conf.d/*.conf;
           
              include /etc/nginx/sites-enabled/*;
          }

          This is Fedora’s Nginx package example nginx.conf, without comment lines and include /etc/nginx/sites-enabled/*; added.

          Location block(s) should be always inside server block(s) and server block(s) should be always inside http block.

  7. Thanks for the help, and sorry for my long respond :)
    the first two commands, show that themes that I add recently is owned by root, so the problem is only on the permission?
    I new to this I’m not sure what to do, but I will try to use chmod if it is working.

    • Hi again Tiyo,

      Yes, your problem is directory permissions, and you can fix those with chmod command, but much better way is to use chown command and change your directories and files owner:group to same that PHP-FPM is using.

      More info about Nginx and PHP-FPM configuration you can find from Nginx and PHP-FPM Configuration and Optimizing Tips and Tricks

  8. Hi,

    Everything went well except that I can’t see the webpages (e.g. testsite.local) across the network. I’m running my web server from a virtual machine, if this would matter. Furthermore, I checked the logs and it doesn’t contain any error or access messages.

    Cheers

    • Hi Bar,

      Could you post output of following command from you host (where you try to load pages):

      cat /etc/hosts

      And output of following commands from your virtual machine:

      ifconfig
       
      iptables -L
      • cat /etc/hosts

        127.0.0.1 localhost localhost.localdomain testsite.local localhost4 localhost4.localdomain4
        ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

        ifconfig

        eth2 Link encap:Ethernet HWaddr 46:50:06:A0:A6:1A
        inet addr:172.16.9.17 Bcast:172.16.9.255 Mask:255.255.255.0
        inet6 addr: fe80::4450:6ff:fea0:a61a/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
        RX packets:141237 errors:0 dropped:0 overruns:0 frame:0
        TX packets:70011 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:164894974 (157.2 MiB) TX bytes:4603652 (4.3 MiB)
        Interrupt:16

        lo Link encap:Local Loopback
        inet addr:127.0.0.1 Mask:255.0.0.0
        inet6 addr: ::1/128 Scope:Host
        UP LOOPBACK RUNNING MTU:16436 Metric:1
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0
        RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

        iptables -L

        Chain INPUT (policy ACCEPT)
        target prot opt source destination
        ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
        ACCEPT icmp -- anywhere anywhere
        ACCEPT all -- anywhere anywhere
        ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
        REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
        ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http

        Chain FORWARD (policy ACCEPT)
        target prot opt source destination
        REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

        Chain OUTPUT (policy ACCEPT)
        target prot opt source destination

        • Hi Bar,

          Looks almost right, your testsite.local on your /etc/hosts should point to your virtual machine ip, so remove testsite.local from first line and add following line:

          172.16.9.17 testsite.local

          Or what ever your virtual server ip is…if you reboot your virtual machine and if you use dhcp, then it might be something else than 172.16.9.17.

    • I am having the same issue, and it appears to be with the IPTABLES configuration. I can open the page on the localhost using links ([jackman@localhost ~]$ links http://testsite.local) WITHOUT changing permissions, owners, etc. All steps in the tutorial were followed exactly.

      Also, the MySQL server is suffering the same problem. It is completely inaccessible from outside the localhost. I have to establish an SSH tunnel to the server to use MySQL Workbench.

      I’m using CentOS 6.2 in VirtualBox.

      [root@localhost ~]# iptables -L
      Chain INPUT (policy ACCEPT)
      target prot opt source destination
      ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
      ACCEPT icmp — anywhere anywhere
      ACCEPT all — anywhere anywhere
      ACCEPT tcp — anywhere anywhere state NEW tcp dpt:ssh
      REJECT all — anywhere anywhere reject-with icmp-host-prohibited
      ACCEPT tcp — anywhere anywhere state NEW tcp dpt:mysql
      ACCEPT tcp — anywhere anywhere state NEW tcp dpt:http

      Chain FORWARD (policy ACCEPT)
      target prot opt source destination
      REJECT all — anywhere anywhere reject-with icmp-host-prohibited

      Chain OUTPUT (policy ACCEPT)
      target prot opt source destination

      • This works:

        [root@localhost ~]# cat /etc/sysconfig/iptables
        # Firewall configuration written by system-config-firewall
        # Manual customization of this file is not recommended.
        *filter
        :INPUT ACCEPT [0:0]
        :FORWARD ACCEPT [0:0]
        :OUTPUT ACCEPT [0:0]
        -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
        -A INPUT -p icmp -j ACCEPT
        -A INPUT -i lo -j ACCEPT
        -A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
        -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
        -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
        -A INPUT -j REJECT –reject-with icmp-host-prohibited
        -A FORWARD -j REJECT –reject-with icmp-host-prohibited
        COMMIT

  9. i have same problem with Bar.

    The /etc/host file’s content is only this
    127.0.0.1 testsite.local

    but i run this code as root > cat /etc/hosts ## seems that
    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

    i restart pc but it dont change. it is equal.

    Thanks RJ…

  10. i use Fedora 16, i run as root but this code don’t work
    chown -R nginx:nginx /srv/www/testsite.local

    it’s works. i apply this
    chmod -R 777 /srv/www/testsite.local

  11. Hi Sargin,

    /etc/host file should not even exist, it should be /etc/hosts. So add your

    127.0.0.1 testsite.local

    to /etc/hosts file!

    Could you tell more specific what is the problem with chown -R nginx:nginx /srv/www/testsite.local command?

    Btw. Good to remember that chmod 777 is very dangerous on public servers…everybody can read, write and execute everything…so never use it, in real life.

  12. domain name is sargin.domain i add sargin.domain to /etc/hosts

    at /etc/nginx/sites-available exist sargin.domain

    sargin.domain file content below:
    server {
    server_name sargin.domain;
    access_log /home/asus/NetBeansProjects/logs/access.log;
    error_log /home/asus/NetBeansProjects/logs/error.log;
    root /home/asus/NetBeansProjects;

    location / {
    index index.html index.htm index.php;
    }

    location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/asus/NetBeansProjects$fastcgi_script_name;
    }
    }

    /etc/nginx/sited-enabled/ exist sargin.domain link

    when i go sargin.domain

    403 forbidden :(

    how can i solve__?

    • Hi sargin,

      Did you remember restart your Nginx server?

      /etc/init.d/nginx restart
      • yes i tried uubss but dont change. sargin.domain 403 Forbidden

        —-
        i make a sample different source
        /srv/www/sargin.host
        i add sargin.host to /etc/hosts.
        it works now.

        is home folders special folder so it give 403 forbidden message????

        • Do you have right permissions on your home folder?

          Please post output of following commands:

          ls -la /home/asus/
          ls -la /home/asus/NetBeansProjects
          ls -la /srv/www/
          • [root@asusFEDORA asus]# ls -la /home/asus/
            ls: /home/asus/.gvfs’e erişilemedi: Erişim engellendi
            toplam 196
            drwx——. 30 asus asus 4096 Ara 21 13:32 .
            drwxr-xr-x. 3 root root 4096 Ara 20 22:30 ..
            drwxrwxr-x. 2 asus asus 4096 Ara 20 22:31 .abrt
            -rw——-. 1 asus asus 112 Ara 21 13:17 .bash_history
            -rw-r–r–. 1 asus asus 18 Haz 22 17:38 .bash_logout
            -rw-r–r–. 1 asus asus 193 Haz 22 17:38 .bash_profile
            -rw-r–r–. 1 asus asus 124 Haz 22 17:38 .bashrc
            drwxr-xr-x. 2 asus asus 4096 Ara 20 22:31 Belgeler
            drwx——. 10 asus asus 4096 Ara 21 05:56 .cache
            drwx——. 14 asus asus 4096 Ara 21 13:36 .config
            drwx——. 3 asus asus 4096 Ara 20 22:31 .dbus
            -rw——-. 1 asus asus 16 Ara 20 22:31 .esd_auth
            drwxr-xr-x. 2 asus asus 4096 Ara 21 03:02 .fontconfig
            drwx——. 4 asus asus 4096 Ara 21 13:38 .gconf
            drwxr-xr-x. 2 asus asus 4096 Ara 20 22:31 Genel
            drwx——. 4 asus asus 4096 Ara 20 22:36 .gnome2
            -rw-r–r–. 1 asus asus 3072 Ara 21 06:28 .grl-bookmarks
            -rw-r–r–. 1 asus asus 2048 Ara 21 06:28 .grl-metadata-store
            -rw-r–r–. 1 asus asus 4096 Ara 21 06:28 .grl-podcasts
            drwxrwxr-x. 2 asus asus 4096 Ara 21 03:15 .gstreamer-0.10
            -rw-rw-r– 1 asus asus 146 Ara 21 07:57 .gtk-bookmarks
            d?????????? ? ? ? ? ? .gvfs
            -rw——-. 1 asus asus 2170 Ara 21 07:57 .ICEauthority
            -rw-r–r– 1 asus asus 3120 Ara 21 07:57 .imsettings.log
            drwxr-xr-x. 2 asus asus 4096 Ara 21 08:11 İndirilenler
            drwxr-xr-x. 3 asus asus 4096 Ara 20 22:31 .local
            drwxr-xr-x. 2 asus asus 4096 Ara 20 22:31 Masaüstü
            drwx——. 3 asus asus 4096 Ara 20 22:31 .mission-control
            drwxr-xr-x. 5 asus asus 4096 Ara 20 22:31 .mozilla
            drwxr-xr-x. 2 asus asus 4096 Ara 20 22:31 Müzik
            drwxrwxr-x 3 asus asus 4096 Ara 21 08:24 .netbeans
            drwxrwxr-x 3 asus asus 4096 Ara 21 09:06 .netbeans-derby
            drwxrwxr-x 4 nginx nginx 4096 Ara 21 11:31 NetBeansProjects
            drwxrwxr-x. 3 asus asus 4096 Ara 21 03:02 .openoffice.org
            drwx——. 2 asus asus 4096 Ara 20 22:31 .pulse
            -rw——-. 1 asus asus 256 Ara 20 22:31 .pulse-cookie
            drwxr-xr-x. 2 asus asus 4096 Ara 21 13:13 Resimler
            drwxrwxr-x 2 asus asus 4096 Ara 21 13:17 .shotwell
            drwxr-xr-x. 2 asus asus 4096 Ara 20 22:31 Şablonlar
            drwx——. 5 asus asus 4096 Ara 21 09:06 .thumbnails
            drwxr-xr-x. 2 asus asus 4096 Ara 20 22:31 Videolar
            drwxrwxr-x 4 asus asus 4096 Ara 21 12:58 www
            -rw——-. 1 asus asus 24083 Ara 21 13:44 .xsession-errors
            -rw-r–r–. 1 asus asus 658 Şub 8 2011 .zshrc
            **********************************************

            [root@asusFEDORA asus]# ls -la /home/asus/NetBeansProjects
            toplam 24
            drwxrwxr-x 4 nginx nginx 4096 Ara 21 11:31 .
            drwx——. 30 asus asus 4096 Ara 21 13:32 ..
            -rw-rw-r– 1 nginx nginx 10 Ara 21 11:31 index.php
            -rw-rw-r– 1 nginx nginx 11 Ara 21 11:23 index.php~
            drwxrwxr-x 2 nginx nginx 4096 Ara 21 09:15 logs
            drwxrwxr-x 3 nginx nginx 4096 Ara 21 09:51 PhpProject1
            ***************************************************

            [root@asusFEDORA asus]# ls -la /srv/www/
            toplam 16
            drwxr-xr-x 4 root root 4096 Ara 21 12:35 .
            drwxr-xr-x. 3 root root 4096 Ara 21 08:45 ..
            drwxr-xr-x 4 nginx nginx 4096 Ara 21 12:35 sargin.domain
            drwxrwxrwx 4 nginx nginx 4096 Ara 21 08:45 testsite.local

            • Thanks and sorry, but could you also post also following outputs:

              ls -la /
              ls -la /home
              • [root@asusFEDORA asus]# ls -la /
                toplam 188
                dr-xr-xr-x. 21 root root 4096 Ara 21 07:57 .
                dr-xr-xr-x. 21 root root 4096 Ara 21 07:57 ..
                -rw-r–r– 1 root root 0 Ara 21 07:57 .autorelabel
                dr-xr-xr-x. 2 root root 4096 Ara 21 03:48 bin
                dr-xr-xr-x. 4 root root 4096 Ara 21 00:28 boot
                drwxr-xr-x 21 root root 3800 Ara 21 13:41 dev
                drwxr-xr-x. 132 root root 12288 Ara 21 13:42 etc
                drwxr-xr-x. 3 root root 4096 Ara 20 22:30 home
                dr-xr-xr-x. 20 root root 12288 Ara 21 03:48 lib
                drwx——. 2 root root 16384 Ara 21 00:04 lost+found
                drwxr-xr-x 7 root root 140 Ara 21 13:32 media
                drwxr-xr-x. 2 root root 4096 Tem 29 11:49 mnt
                drwxr-xr-x. 4 root root 4096 Ara 21 06:11 opt
                dr-xr-xr-x 185 root root 0 Ara 21 09:57 proc
                -rw-r–r– 1 root root 86132 Ara 21 07:57 .readahead
                dr-xr-x—. 9 root root 4096 Ara 21 14:33 root
                drwxr-xr-x 35 root root 1220 Ara 21 13:42 run
                dr-xr-xr-x. 2 root root 12288 Ara 21 03:48 sbin
                drwxr-xr-x. 3 root root 4096 Ara 21 08:45 srv
                drwxr-xr-x 13 root root 0 Ara 21 09:57 sys
                drwxrwxrwt. 23 root root 4096 Ara 21 14:22 tmp
                drwxr-xr-x. 13 root root 4096 Ara 20 22:59 usr
                drwxr-xr-x. 18 root root 4096 Ara 21 00:26 var
                ********************************************************

                [root@asusFEDORA asus]# ls -la /home
                toplam 12
                drwxr-xr-x. 3 root root 4096 Ara 20 22:30 .
                dr-xr-xr-x. 21 root root 4096 Ara 21 07:57 ..
                drwx——. 30 asus asus 4096 Ara 21 13:32 asus

                thanks for answer RJ..

                • Thanks! :)

                  Try following (as root):

                  chmod 711 /home/asus
                   
                  /etc/init.d/nginx restart

                  Is it working then?

  13. Nice tutorial, i am noob in linux, is my first time in istall lemp on fedora 16…and this work without problems!

    Very tks

  14. Work like a charm, even for the first time (server name=blright.dev) it keep showing message that the root directory isn´t where it should be (/var/nginx/www). But after redo from step number 7 with new server name (kam.ty) all is well.

  15. Thanks a lot! After about 15 tutorials, I got that thing to work. Great tuto, no mistakes, all went OK !

  16. Thanks for your tutorial, but I have an error when I do this:

    yum --enablerep=remi install php-fpm
    Loaded plugins: fastestmirror
    Error getting repository data for remi, repository not found

    Could you tell me how to fix it?
    Thanks a lot!

  17. Hey JR!

    Great tutorial but I am still having issues with getting the site to display properly. At once point i was getting a 403, and that has since gone away and I only get a blank white page now.

    • Hi Hogie,

      Thanks! :)

      Could you check your error.log and access.log, do you find something suspicious? Or could you post your logs example to pastebin?

      • I had a look at /var/www/sites/mysite/logs and access.log has nothing, error.log only has “Worker connection is not enough”, but that has since been increased. That problem would result in the page timing out and when i increased them it turned to the white screen.

        I should mentioned i have virtualmin/webmin installed but am doing everything in terminal at the moment. Also, I am a linux NOOOOOOOOOOB so my conf files will be messy I am sure.

        I think I may have a issue with my virtual host as I am not sure if it should be in /etc/nginx/sites-enabled or in /etc/nginx/conf.d/. Also, I may have a issue because I am trying to test 2 sites, james.XXX.com and james2.XXX.com and I think they are either conflicting or I am not setting it up proper for a subdomain. james.XXX.com is basic HTML and works fine, james2.XXX.com is PHP and thats where I get my white screen.

        /var/log/nginx/error.log – http://pastebin.com/HiQfiAcK
        /var/log/nginx/access.log-20120131 (Lots more of this, only added the two different lines though) – http://pastebin.com/NKqdFpcs
        nginx conf – http://pastebin.com/JJpbBVrw

        Some strange things I noticed getting these logs for you. james2.XXX.com does not run any flash, and the logs show it is trying to find a flash file.

        • Yes, some problems with config files…your logs tell following:

          ...
          [error] 26499#0: *1 directory index of "/var/www/sites/james2.XXX.com/" is forbidden, client: XX.XX.40.188, server: james2.XXX.com, request: "GET / HTTP/1.1", host: "james2.XXX.com"
          ...
          [emerg] 27156#0: "server_name" directive is not allowed here in /etc/nginx/conf.d/james.XXX.com.conf:2
          ...

          Could you post all your config files and config file locations? Btw. do you have james2.XXX.com virtualhost config on nginx.conf file and another separated file?

          Could you also check/post php-fpm logs under /var/log/php-fpm/ path?

          • Yes *blush* I just noticed there is multiple virtualhosts, in fact 3 of them maybe. I deleted james2.xxx.com.conf from /eta/nginx/conf.d/ but still have it inside nginx.conf and sites-available (lm to sites-enabled)

            /etc/nginx/nginx.conf – http://pastebin.com/JJpbBVrw

            /etc/nginx/sites-enabled/james2.XXX.com.conf – http://pastebin.com/9hRrxXMm

            /var/log/php-fpm/error.log = http://pastebin.com/wxGX8Sph

            Strangely enough, I do not have a single virtual host for james.XXX.com and it works fine.

            • Currently I can only recommend you to setup both virtualhosts again, do clean setup (remove old virtualhosts and one from nginx.conf file), because you will later have huge problems if you have situation where you run multiple sites and you are not sure how or why your setup is working or not. Best setup is use separated files for virtualhosts, location is up to you, both sites-enabled and sites-available or conf.d works, or any other included path works, but just be sure that you know how your configuration files are organized and where they are located…or later you will have big big problems, if you have to change/update/modify configuration that works by chance.

              Easiest and best way to configure it is use multiple step process where you test your setup between those steps…you can example do following:

              1. Create one virtualhost, with plain html and test that it works
              2. Create another virtualhost and test that html works too and test also that the first virtual host works still
              3. Test PHP scripts
              4. …

              If you do this, then you know later where the problem is, just example if html works but PHP not, then you know that problem is between Nginx and PHP-FPM or PHP config, but not your basic Nginx config. And then all “debugging” is much easier. ;)

              Please let me know if you encounter some problems or do you got it working? :D

              • That worked perfectly! I removed the virtual host from my nginx.conf, added a new virtual host for james.XXX.com to sites-enabled and everything is working perfectly! Thanks so much for all your help. You are the first person able to explain how and where to put the virtual host and that it does not really matter where it is as long as you tell nginx where it is.

                A+ JR!

                • Excellent to hear that you got it working! :D Yes, virtual host files location does not really matter as long as you include those. :)

  18. Thank you for such a wonderful guide :) The only thing I couldn’t get working was the PHP-FPM, but a google solved that issue. Other than that, flawless!

    Thank you again :)

    • Hi Josh,

      You are welcome! Nice to hear that this guide was helpful, what kind of problems you had with PHP-FPM? If I setup PHP-FPM with this guide steps, it’s working normally… :)

  19. Hi there!

    I got problem with nginx. Its not installing. Problem in the Repository.

    yum --enablerepo=remi install nginx php php-fpm php-common
    Loaded plugins: refresh-packagekit, rhnplugin
    Repository google-chrome is listed more than once in the configuration
    This system is not registered with RHN.
    RHN support will be disabled.
    google-chrome | 951 B 00:00
    http://nginx.org/packages/rhel/6Server/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404 : http://nginx.org/packages/rhel/6Server/i386/repodata/repomd.xml
    Trying other mirror.
    Error: Cannot retrieve repository metadata (repomd.xml) for repository: nginx. Please verify its path and try again

    • Hi

      Could you post output of following commands:

      uname -a
       
      lsb_release -a
       
      cat /etc/yum.repos.d/nginx.repo
  20. Now how does one do the following when not compiling from source?

    http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Nginx-Version2

    Thanks for having this site up too. Great way to kill some time.

  21. Hi JR! first of all thank you very much for this great tutorial!
    I have a very strange problem.

    When i try to open 127.0.0.1 it opens the file which is located : usr/share/nginx/html/index.html

    But when i type http://testsite.local it opens the file which islocated : srv/www/testsite.local/public_html

    My hosts file is looking like this : 127.0.0.1 localhost localhost.localdomain testsite.local

    My second problem is when i add include /etc/nginx/sites-enabled/*; to etc/nginx/nginx.conf it does not show php files.

    For example when i type http://testsite.local/index.php it gives 404

    But when i delete include /etc/nginx/conf.d/*.conf; from etc/nginx/nginx.conf it works and when i type http://testsite.local/index.php , it shows me the info about php.

    If you have some time could you please help me to figure out how to fix my problem?

    • Hi nightshift,

      This is actually just normal behaviour. :)

      If you type testsite.local, then your virtualhost under /etc/nginx/sites-enabled catch that url and show right data. If you type just 127.0.0.1 then your config from /etc/nginx/conf.d/default.conf catch that request and show page from /usr/share/nginx/html.

      If you want to remove the default.conf, then you have to move listen, server_name, etc. to your virtualhost conf or leave default.conf and comment out example location / block. :)

      Then you can get the testsite.local and 127.0.0.1 to show same content. On real server environment this is not actually problem, because 127.0.0.1 is not used anyway and all virtualhost config files have their own real domain name. :)

      • Ok now i see the big picture :) Thank you very much for your understanding and patience.

        I’ll start over and try to use the default conf. also i’ll try to enable php under /usr/share/nginx/html

        I’ll report it here.

      • JR i found a way to work just with default nginx root directory. I’ll try to explain it here :

        After step 6 i didn’t follow other steps.

        default nginx root directory is located under : /usr/share/nginx/html

        default nginx log files are located under : /var/log/nginx/access.log and /var/log/nginx/error.log

        so first i chmod 711 both access.log and error.log

        After that i changed the default.conf which is located under : /etc/nginx/conf.d/

        to this :

        server {
        listen 80;
        server_name localhost;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        root /usr/share/nginx/html;

        location / {
        index index.html index.htm index.php;
        }

        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        }
        }

        so i’m able to use 127.0.0.1 and localhost with php support.

        Thank you very much for your instructions JR!

        Kind Regards.

        • You are very welcome!

          Nice to hear that you got it working… :D

  22. Hi,

    I’ve a little bit problem, after following all these step I was able to call my website from localhost.

    But when I’m trying to access from another PC I got this message:
    curl: (7) couldn’t connect to host

    What I’m doing wrong?

    Thank’s.

    • Hi arif,

      Do you have opened http port from firewall?

  23. i followed your guide until 7th step. i didnt use testsite.local .
    i put my info.php file at /usr/share/nginx/html .
    my nginx.conf file configuration is: (inside http block)

    “server {
    location / {
    root /usr/share/nginx/html;
    index index.html index.htm index.php;
    }
    location ~ \.php$ {
    root html;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }”

    i run it on a virtual machine.

    my /etc/hosts file is:

    “127.0.0.1 localhost.localdomain localhost
    ::1 localhost6.localdomain6 localhost6″

    my “inet addr:192.168.0.17″ .

    and when i try localhost/test.php , firefox says:

    “You have chosen to open
    info.php
    which is a: BIN file (20 bytes)
    from: http://localhost
    Would you like to save this file?”

    how to solve this?
    thanks a lot..

    • i wrote it test.php by mistake.. it should be localhost/info.php
      thaks again

  24. Hi JR,

    Want to get your advice..
    I’m facing a problem. Wish you can give me some advice.
    For example, when I type in URL http://www.abc.com, it will redirect to correct working directory… But when I type in URL abc.com, it will redirect to the page.. “Welcome to nginx”!, which is the default.. Is that possible I can set when type in abc.com will redirect to http://www.abc.com?

    Looking forward to receive your reply.

    Thanks.

    • Hi woody,

      Try following:

      server {
        listen 80; 
        server_name abc.com www.abc.com;
       
        if ($host != 'www.abc.com' ) {
          rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
        }
      }
  25. Hi, JR..
    May I know this config where should I put?

    Really appreciate for your help.
    Thanks.

    • You should put this inside your server block.

      Could you post your real config (server block) and I can add it for you. You can of course change your real domains… :)

  26. Actually, currently I’m doing this way, and also working. Is it to configure in this way? or have to follow your step is recommend?

    server {
        server_name www.abc.com abc.com;
        access_log /var/log/nginx/abc.com/access.log;
        error_log /var/log/nginx/abc.com/error.log;
        root /home/abc.com/public_html;
     
        location / {
            index index.html index.htm index.php;
            server_tokens off;
            client_max_body_size 20m;
            client_body_buffer_size 128k;
     
        }
     
        location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /home/abc.com/public_html$fastcgi_script_name;
        }
     
        location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
            access_log        off;
            log_not_found     off;
            expires           360d;
        }
     
        location ~ /\. {
            access_log off;
            log_not_found off;
            deny all;
        }
     
    }

    May need your advice. :) Appreciate it.

    • Thanks woody, then just add / change it following:

      server {
          server_name www.abc.com abc.com;
          access_log /var/log/nginx/abc.com/access.log;
          error_log /var/log/nginx/abc.com/error.log;
          root /home/abc.com/public_html;
       
          if ($host != 'www.abc.com' ) {        rewrite ^/(.*)$ http://www.abc.com/$1 permanent;    } 
          location / {
              index index.html index.htm index.php;
              server_tokens off;
              client_max_body_size 20m;
              client_body_buffer_size 128k;
          }
       
          location ~ \.php$ {
              include /etc/nginx/fastcgi_params;
              fastcgi_pass  127.0.0.1:9000;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME /home/abc.com/public_html$fastcgi_script_name;
          }
       
          location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
              access_log        off;
              log_not_found     off;
              expires           360d;
          }
       
          location ~ /\. {
              access_log off;
              log_not_found off;
              deny all;
          }
       
      }

      And reload/restart your nginx. Is it working then?

      EDIT: I actually just updated if part again… :)

  27. Hi JR,

    Just try it, seem like not working…
    If I not put in the code from server_name below, I added in http://www.abc.com & abc.com
    server {
    server_name http://www.abc.com abc.com;
    access_log /var/log/nginx/abc.com/access.log;
    error_log /var/log/nginx/abc.com/error.log;
    root /home/abc.com/public_html;
    }

    • It should work without http:// and I think that server_name with http:// is wrong nginx syntax. Could you post your full config again with your changes?

  28. My config now is below,

    server {
    server_name http://www.abc.com abc.com;
    access_log /var/log/nginx/abc.com/access.log;
    error_log /var/log/nginx/abc.com/error.log;
    root /home/abc.com/public_html;

    if ($host != 'www.abc.com' ) {
    rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
    }

    If without add in abc.com on,

    server_name http://www.abc.com abc.com;
    It doesn’t work. :(

    • Yes you need both abc.com and http://www.abc.com, but not with the http:// so it should look like following:

      ...
      server_name www.abc.com abc.com;
      ...
      • Oh, sorry…no I got it. You have exactly right config, but code-block on here just convert www. to http://www. So yes your config looks good and if it works, then it’s okay… :)

      • Roger that JR. :)

        Is this code still need?
        if ($host != 'www.abc.com' ) {
        rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
        }

        • If you want to get always permanent 301 redirect to your www. address then it’s needed. This is important if you want do search engine friendly site… :)

  29. Thanks JR. Really appreciate for your help. :)

    • You are very welcome! :)

  30. Hi, thank you for this clear tutorial. I have getting this error.

    [root@localhost ~]# service nginx restart
    nginx: [crit] pread() “/etc/nginx/sites-enabled/sites-enabled” failed (21: Is a directory)
    nginx: configuration file /etc/nginx/nginx.conf test failed

    my nginx.conf file;

    user nginx;
    worker_processes 1;

    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;

    events {
    worker_connections 1024;
    }

    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main ‘$remote_addr – $remote_user [$time_local] “$request”$
    ‘$status $body_bytes_sent “$http_referer” ‘
    ‘”$http_user_agent” “$http_x_forwarded_for”‘;

    access_log /var/log/nginx/access.log main;

    sendfile on;
    #tcp_nopush on;

    keepalive_timeout 65;

    #gzip on;

    include /etc/nginx/conf.d/*.conf;

    include /etc/nginx/sites-enabled/*;

    }

    how to fix this error? thanks.

    • Hi StmpDwn,

      Could you post output of following command:

      ls -la /etc/nginx/sites-enabled
  31. Hi JR,

    I’m facing a problem that sometimes I browsing the website, it will pop out 504 Gateway Time-out (from nginx).

    Appreciate if you can assist me on this matter.

    Thanks.

    • Hi woody,

      Could you tell more about your server, operating system and current nginx setup?

      • Hi JR,
        Thanks for your reply. :)

        My current OS is CentOS release 5.8 (Final) 32 bit.
        It is running in 2GB RAM, 2 CPU & 50 GB HDD…

        This is my nginx.conf

        user  nginx;
        worker_processes  2;
         
        error_log  /var/log/nginx/error.log warn;
        pid        /var/run/nginx.pid;
         
         
        events {
            worker_connections  1024;
        }
         
         
        http {
            include       /etc/nginx/mime.types;
            default_type  application/octet-stream;
         
            log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                              '$status $body_bytes_sent "$http_referer" '
                              '"$http_user_agent" "$http_x_forwarded_for"';
         
            access_log  /var/log/nginx/access.log  main;
         
            sendfile        on;
            #tcp_nopush     on;
         
            keepalive_timeout  65;
         
            #gzip  on;
         
            include /etc/nginx/conf.d/*.conf;
         
            ## Load virtual host conf files. ##
            include /etc/nginx/sites-enabled/*;

        This is my php-fpm.conf

        include=/etc/php-fpm.d/*.conf
        [global]
        pid = /var/run/php-fpm/php-fpm.pid
        error_log = /var/log/php-fpm/error.log
        ;log_level = notice
        ;daemonize = yes
        emergency_restart_threshold = 10
        emergency_restart_interval = 1m
        process_control_timeout = 10s
         
        </code>
         
        This is my /etc/php-fpm.d/www.conf
        <code>
        [www]
        listen = 127.0.0.1:9000
        ;listen.backlog = -1
        listen.allowed_clients = 127.0.0.1
        ;listen.owner = nobody
        ;listen.group = nobody
        ;listen.mode = 0666
        user = apache
        group = apache
        pm = dynamic
        pm.max_children = 50
        pm.start_servers = 5
        pm.min_spare_servers = 5
        pm.max_spare_servers = 35
        ;pm.max_requests = 500
        ;pm.status_path = /status
        ;ping.path = /ping
        ;ping.response = pong
        request_terminate_timeout = 30s
        ;request_slowlog_timeout = 0
        slowlog = /var/log/php-fpm/www-slow.log
        ;rlimit_files = 1024
        ;rlimit_core = 0
        ;chroot =
        ;chdir = /var/www
        ;catch_workers_output = yes
        ;security.limit_extensions = .php .php3 .php4 .php5
        ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
        ;php_flag[display_errors] = off
        php_admin_value[error_log] = /var/log/php-fpm/www-error.log
        php_admin_flag[log_errors] = on
        ;php_admin_value[memory_limit] = 32M

        Hope you can assist me on this.

        • Thanks woody!

          Could you also tell do you have any other services running on this machine, like database-server, memcache, etc.?

          And could you tell how much one www (php-fpm) process uses memory on average?

          • Hi JR,
            No database server is running in this machine.
            This server is only running in nginx+php-fpm.

            How can I calculate my one www (php-fpm) process uses memory on average?
            Sorry about that, appreciate it if you can guide me on that. :)

            Thanks.

            • Okay, very nice web server. :)

              You can check your php-fpm processes memory usage simply with top.

              Do following:

              1. Log in your server.

              2. Start top.

              3. Press Shift+F

              4. Press n and Enter

              Then you have your processes ordered by memory usage. Then you should see something like:

              32679 web    20   0  540m  40m  26m S  0.0  8.2   0:16.57 php-fpm            
              32752 web    20   0  540m  38m  25m S  0.0  7.9   0:01.96 php-fpm            
              32759 web    20   0  541m  36m  22m S  0.0  7.4   0:03.60 php-fpm

              Could you paste that output here…? :)

  32. Hi JR,

    Really cool that you share with me this command. Appreciate it.

    Please find my memory usage below,

    5364 apache 15 0 112m 32m 20m S 0.0 1.6 0:03.28 php-fpm
    2124 root 11 -10 32752 31m 1716 S 0.0 1.6 0:00.73 iscsiuio
    5367 apache 20 0 105m 24m 19m S 0.0 1.2 0:03.49 php-fpm
    5420 apache 18 0 106m 24m 18m S 0.0 1.2 0:02.89 php-fpm
    5365 apache 15 0 106m 24m 18m S 0.0 1.2 0:03.13 php-fpm
    5366 apache 16 0 106m 24m 18m S 0.0 1.2 0:03.00 php-fpm
    5369 apache 25 0 106m 23m 17m S 0.0 1.2 0:02.58 php-fpm
    5417 apache 16 0 106m 22m 17m S 0.0 1.1 0:02.69 php-fpm
    5370 apache 16 0 106m 22m 17m S 0.0 1.1 0:02.83 php-fpm
    5412 apache 17 0 106m 22m 16m S 0.0 1.1 0:02.75 php-fpm

    • Thanks! :)

      So looks like your php-fpm process is ~25 Mb. I think it might be sensible to use about half of the main memory to php-fpm processes (another half for the system and nginx). So let’s do some calculations:

      1024 / 25 = ~40

      Good pm.max_children value is 40. So I can recommend you to test following config (change only following pm. values):

      pm.max_children = 40
      pm.start_servers = 5
      pm.min_spare_servers = 5
      pm.max_spare_servers = 25
      pm.max_requests = 300

      Note you should uncomment (remove ;) from pm.max_requests value.

      Then you need to restart php-fpm.

      You can change later pm.max_requests to higher, but I have noticed that the lower value is much better than unlimited…I can’t say that this is absolutely best config, but you can try this. You can of course backup your original config, before you change it.

      Please let me know, if this helps or not? :)

  33. Hi JR,

    Thanks for your help.
    I just changed the config, will monitor it.

    May I know how you get the 25 Mb usage for php-fpm process? can you tell me which line?

    In the future, if this web server add on more virtual host, is it I have to change the php-fpm config again to match the load?

    • You are welcome! Let me know if you still have problems with it. :)

      If you check top output you see RES column which stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming. If you check all RES values then you can see php-fpm processes using 22m – 32m memory. Average 25m is just my best guess based on your top output. :)

      If you have more virtual hosts you can change your config, but your current configuration is working also. So you can create PHP-FPM configs per site or just use one bigger pool for all. It’s good to remember that the pm.max_children value (40) has nothing to do with the fact that how much a requests your web server can handle. If you have hundreds simultaneous PHP requests then those requests go to the PHP-FPM queue and are processed as soon as possible. Often it’s a much more efficient handle example 15 php requests simultaneously than 100 requests. This of course depends on number of CPU cores, amount of RAM, PHP processes execution time and memory usage. :)

  34. Hi JR, Thanks for your explanation.
    How we can calculate the amount below?

    pm.start_servers = 5
    pm.min_spare_servers = 5
    pm.max_spare_servers = 25

    For the pm.start_servers is it need to use this formula?
    Default Value: min_spare_servers + (max_spare_servers – min_spare_servers) / 2

    • Hi woody,

      You can use default value formula to calculate pm.start_servers, but actually it’s just value how many child processes are created on startup. So if you set value to 15, PHP-FPM starts 15 servers on startup and if you don’t have 15 PHP-FPM requests then it will kill processes (one by one) until current process count reaches pm.min_spare_servers. So you can freely choose any (other) value between 5-25 if you want / need. :)

      I personally setup first just some reasonable values and fine-tune them later, if needed. Most important values are pm.max_children and pm.max_requests, because too high (unlimited) values might cause big problems with memory usage.

      • Hi, JR, Thank you very much.. :)

        • You are very welcome! :)

          Do you still have 504 Gateway Time-out errors from nginx?

          • Hi JR,
            So far the errors not appear again. Have to monitor it again.

            Is that possible I can have your email or any instant messenger ID?? :)

            Thanks.

            • Hi woody,

              Excellent to hear. :)

              I’m not using IM’s, but you can easily contact via Contact form. :)

  35. How can I get a more updated version of nginx to Fedora 17?

    thanks

    • Hi Robson,

      Currently possible methods to get newer version of nginx to Fedora 17:
      - Install nginx from Fedora rawhide repo
      - Download nginx source tarball, compile and install it

      • Thanks

  36. Thanks to this site I’ve done a lot of jobs. Now it’s a strange problem.
    I installed nginx using yum and remove it, and copy configure info. Then installed another from source pack.
    After all steps described above, I wrote a php file in /etc/nginx/html and went to localhost, it works. But can’t find testsite.local
    My settings are
    # Firewall configuration written by system-config-securitylevel
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    :RH-Firewall-1-INPUT - [0:0]
    -A INPUT -j RH-Firewall-1-INPUT
    -A FORWARD -j RH-Firewall-1-INPUT
    -A RH-Firewall-1-INPUT -i lo -j ACCEPT
    -A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
    -A RH-Firewall-1-INPUT -p 50 -j ACCEPT
    -A RH-Firewall-1-INPUT -p 51 -j ACCEPT
    -A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
    -A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
    -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT
    -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
    COMMIT


    127.0.0.1 localhost.localdomain localhost testsite.local
    ::1 localhost6.localdomain6 localhost6

    • Hi Ctu,

      Could you post testsite.local virtual host configuration? If you followed exactly this guide, then it’s /etc/nginx/sites-available/testsite.local file content. :)

      Could you also post output of following commands:

      ls -la /etc/nginx/sites-available/testsite.local
       
      ls -la /etc/nginx/sites-enabled/testsite.local
      • yep, it’s

        -rw-r--r-- 1 root root 513 08-17 14:28 /etc/nginx/sites-available/testsite.local
        lrwxrwxrwx 1 root root 41 08-17 14:05 /etc/nginx/sites-enabled/testsite.local -> /etc/nginx/sites-available/testsite.local

        • Thanks and could you post also testsite.local content?

          cat /etc/nginx/sites-available/testsite.local

          • server {
            server_name testsite.local;
            access_log /srv/www/testsite.local/logs/access.log;
            error_log /srv/www/testsite.local/logs/error.log;

            location / {
            root /srv/www/testsite.local/public_html;
            index index.html index.htm index.php;
            }

            location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /srv/www/testsite.local/public_html$fastcgi_script_name;
            }
            }

            and when i alter nginx.conf as:


            location ~ \.php$ {
            root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /etc/nginx/html$fastcgi_script_name;
            include fastcgi_params;
            }

            and put an phpinfo page under html, it works. Still can’t access testsite.local.

            • Looks good. Do you have following include on your nginx.conf?

              ## Load virtual host conf files. ##
              include /etc/nginx/sites-enabled/*;

              And are you sure that the nginx what your are using (build from source) use your nginx.conf file?

              • I’m sure it’s the right nginx.conf. You may forget I memtioned that when I set


                location ~ \.php$ {
                root html;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /etc/nginx/html$fastcgi_script_name;
                include fastcgi_params;
                }

                in this file, and then put


                ls -la /etc/nginx/html/test.php
                -rwxr-xr-x 1 root root 21 08-17 15:55 /etc/nginx/html/test.php

                It works. PHP info is printed.

                Sure, I’ve added following code.


                http {
                include mime.types;
                include /etc/nginx/sites-enabled/*;

              • Woooooooooooo, I’ve fixed the problem. It’s quite simple. I’m able to access http://testsite.local/ after clearing browser cache…
                WTF…orz…

                Thanks for your help:)

                • You are welcome! Excellent to hear that the fix was so simple and you got it working! :)

  37. Hello JR !
    First of all EXCELLENT tutorials. Thanks for all your hard work.

    Second of all I’m having a little issue. After completing your tutorial when I’m trying to check the configuration using a index.php file I’m getting ” File not found. ” instead of php-info. With index.html works like a charm !

    thanks in advance for your time !

    • Hi Mosfet,

      Could you post output of following command:

      ls -la /path/to/your/document_root
       
      cat /path/to/your/virtualhost_file
      • JR thanks again for you answer, as you suspected it was all my fault.
        I misspelled a path in virtualhost. To be more precisely the pat is fastcgi_param SCRIPT_FILENAME /srv/www/testsite.local/public_html$fastcgi_script_name;

        Anyway in order to figure this I’ve reinstalled my vps and started again.

        THANKS again for your time and effort !
        (I’ll probably ask you something else on a different post)

        P.S. This time I installed PHP 5.4 and skiped step 4 (install php 5.4 modules) is that wrong ?

      • Ignore the PS, I’ve spotted my “stupidity”.

        • Hi Mosfet,

          By the way you can use even following syntax:

          fastcgi_param SCRIPT_FILENAME $ducument_root$fastcgi_script_name;

          And yes you are totally right that the php modules is totally optional and normally you need just some, like mysql, apc, etc. not all :)

  38. Hello JR.

    I’m having another difficulty.
    I need ftp access, more specific in /var/www the location of all virtualhost websites.
    for the ftp access I’ve configured a new user, set his homepage /etc/www + chrome the user to home directory. The only problem is that I can’t modify or add files since /etc/www is owned by root
    drwxr-xr-x 8 root root 4096 Oct 27 01:46 www
    changingg the owner of www from root to www group (where my user is memmber) will cause any problems with nginx php-fpm phpmyadmin or mysql ?

    If true or bad practice can you recommend me a different method. Please thate in consideration that I want full access over all websites hosted on the vps.

    Thanks again.

    BTW if there is any way to return at least a pat of the favors you did for me please just let me know.

    • Hello Mosfet,

      Do you need old school ftp or is it possible to use sftp? With sftp you can use even root user directly and do everything over encrypted connection.

      Of course you can spread the word and follow if-not-true-then-false.com on fb/twitter, but for me this site is just hobby and it’s very nice to help, if only I can. :)

  39. I’ll be using sftp with a self-sign certificate. vsftp offers this option.
    From a security point of view it’s OK-ish, from a best practice point of view it’s almost never ok to use root account with remote access.

    I’m still wondering what are the effects but I’ll give it a shot and just hope for the best.

    I was thinking to include root and ftpaccount in a group and change ownership to that group.As a result root will shtill have full access to those folders.

    I’ll follow on twitter, but I’m not a Fb fan.

    • It’s totally true that root account usage with remote access is not very good practice.

      Let’s think other options.

      1. Your original question was about effects changing owner and group to www. Until nginx can read files it should work, you can easily test if it’s working for you. There is not direct effects to php-fpm phpmyadmin and mysql, if you want use php upload, then just change some upload directory permission example to apache user. So you can easily try your original idea, if it’s working as you wish.

      2. Then another option is make your root login much more secure, limiting login by ip address, change port and maybe even user name, but still it’s not so secure option.

      3. One totally different approach is use normal user (example your www user) home dir where you have desired directory structure with files and you make all changes there, then setup simple local cron rsync script which sync your changes every minute to /var/www as root user. :)

  40. Hi I follow your steps and install nginx successfully. I am bit new to this stuff and I have a question.
    My current nginx version is v0.8.something
    How can I update to latest version of nginx?

    • Hi kazunn,

      Nginx 0.8x is very old, what Linux distro you are using?

  41. I used your tutorial for installing nginx + php-fpm in centos but php no working. I can see ‘index.html’ page in my localhost; but, when I have tested with a php page – test.php- it is not working, just downloading the php page through browser.

  42. One CentOS you don’t need to install php to use php-fpm. Yeah that’s right. The php package actually includes mod_php and requires apache. We want neither of those. So just install php-fpm and the extension specific php packages like php-mbstring and php-gd.

    • Hi abdussamad,

      Excellent note, I will test this and update this guide accordingly. Thank you!

  43. Just wanted to say a great THANK YOU – everything worked like a charm on a new VPS, and very clear and understandable for someone with only limited *nix knowledge :)

  44. Hello JR, Great article. But i can’t seem to run my centos 5.8 with this setup(maybe it’s not suitable for this version but i had no errors during installation). I’ve made every step like in this article(changed name from testsite.local to salomon, added 90.156.232.212 salomon
    to /etc/hosts file), but when i try to show test page by adressing ip adress http://90.156.232.212/ – error 118 (net::ERR_CONNECTION_TIMED_OUT): operation timeout is written.

    • First make sure nginx is running:
      service nginx status

      If it’s running make sure in /etc/sysconfig/iptables you added the line:
      -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
      before the line containing REJECT one and not after.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks/Pingbacks

  1. Nginx and PHP-FPM Configuration and Optimizing Tips and Tricks - [...] wrote before a guide Howto install Nginx/PHP-FPM on Fedora 16/15, CentOS/RHEL 6.1/6/5.7, but this guide is just installation guide ...
  2. Nginx - default.conf file missing - [...] can checkout this link also for installing and configuring nginx. Link You may configure in nginx.conf file [...]