how to install nginx ?
how to install nginx ?
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
system is centos 6.7
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: how to install nginx ?
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.
You can also try to install Nginx manually you can use the installation script to change the right configuration.
Re: how to install nginx ?
Edit the file and change user and group from apache to nginx. It should look similar to the block below.
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
Create a test PHP file in the following directory with the following command:
Insert the following code in the space then save and exit:
Restart apache so all the changes take effect:
Code: Select all
/etc/php-fpm.d/www.con
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
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>
Code: Select all
<?php
phpinfo();
?>
Code: Select all
sudo service nginx restart
-
- Posts: 16
- Joined: Sun Oct 02, 2016 10:48 am
- Contact:
- Os: Ubuntu 15x
- Web: apache + nginx
Re: how to install nginx ?
Is the same guide for ubuntu?
Ubuntu 14.04
Ubuntu 14.04
Re: how to install nginx ?
Yep, but I like to take viewtopic.php?f=11&t=10368#p38024 offer an re-install.