Page 1 of 1

how to install nginx ?

Posted: Thu Jan 21, 2016 5:52 am
by balinese
Hi, i iinstalled vesta completelly without nginx, only apache. now i need to add nginx as a proxy for apache, how can i do that?
system is centos 6.7

Re: how to install nginx ?

Posted: Thu Jan 21, 2016 10:12 am
by tjebbeke
The fastest way is to take a backup of your users, reinstall your server with Nginx enabled and restore all backups.
You can also try to install Nginx manually you can use the installation script to change the right configuration.

Re: how to install nginx ?

Posted: Fri Jan 29, 2016 3:57 am
by Elizine
Edit the file

Code: Select all

/etc/php-fpm.d/www.con
and change user and group from apache to nginx. It should look similar to the block below.

Code: Select all

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
Now we need to make some changes to the Nginx configuration file so that php-fpm works correctly with Nginx. Using your favorite editor, edit the file /etc/nginx/conf.d/default.conf and carry out the following changes or copy the following block below into your conf file.

1) Add the index.php to the index location

2) Change the root location to /usr/share/nginx/html

3) Uncomment the Pass PHP scripts to FastCGI section.

4) Change the fastcgi_param SCRIPT_FILENAME to use /usr/share/nginx/html$fastcgi_script_name

Code: Select all

#
# The default server
#
server {
    listen       80 default_server;
    server_name  _;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    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 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/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;
    }
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

Create a test PHP file in the following directory with the following command:

Code: Select all

sudo vi <tt>/usr/share/nginx/html/info.php</tt>
Insert the following code in the space then save and exit:

Code: Select all

<?php
phpinfo();
?>
Restart apache so all the changes take effect:

Code: Select all

sudo service nginx restart

Re: how to install nginx ?

Posted: Sat Dec 10, 2016 7:59 pm
by DESSAR_SEGA
Is the same guide for ubuntu?
Ubuntu 14.04

Re: how to install nginx ?

Posted: Thu Mar 02, 2017 8:30 pm
by skurudo
Yep, but I like to take viewtopic.php?f=11&t=10368#p38024 offer an re-install.