I've read a lot of articles about this today, but I can't get what am I doing wrong. I'm trying to use one vps with nginx for placing two websites (site1.com, site2.com) on it together.
Here is my nginx.conf
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
conf.d directory is empty, and there is my configs in sites-enabled directory:
server {
listen 80 default;
root /home/site1/www;
access_log /home/site1/logs/nginx.access.log;
server_name site1.com;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
and
server {
listen 80;
root /home/site2/www;
access_log /home/site2/logs/nginx.access.log;
server_name site2.com;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Of course /home/site1/www and /home/site2/www both contains files of website.
Now if I trying to open site1.com, here is interesting:
I've get: Can't open site1.com:81 error
What am I doing wrong? Why there is this 81 port added to URL?
我认为只需将site80.com服务器上的监听80更改为监听81
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.