我有一台生产服务器,并且对项目做了一个重要更新,所以我决定将新的更新部署到单独的服务器上,以便首先在同一生产服务器的另一个端口上进行测试,但它没有起作用。
我尝试设置端口 9090 来指向我的测试服务器,但是我得到:
http://example.com:9090/
This webpage is not available
任何想法?
这是我的积木:
测试服务器:
server {
listen 9090;
server_name tree;
root /home/forge/tree/public;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/tree-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
生产服务器:
server {
listen 80 default_server;
server_name default;
root /home/forge/default/public;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/default-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
错误是:
2015/11/19 17:42:16 [error] 2878#0: *60 FastCGI sent in stderr: "PHP message: PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0" while reading response header from upstream, client: 46.185.165.167, server: default, request: "POST /api/get-country-tree?country_id=-1&level=3 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "kalimon.info", referrer: "http://kalimon.info/new_tree"
编辑
$ netstat -antp
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 18539/nginx: worker
tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 18539/nginx: worker
$ wget localhost:9090
--2015-11-22 11:26:57-- http://localhost:9090/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:9090... connected.
HTTP request sent, awaiting response... 403 Forbidden
2015-11-22 11:26:57 ERROR 403: Forbidden.
编辑2
我已通过以下方式修复权限错误:
$ chmod -R 775 ~/tree
现在我得到了回应... 200:
$ wget 0.0.0.0:9090
--2015-11-22 12:17:47-- http://0.0.0.0:9090/
Connecting to 0.0.0.0:9090... connected.
HTTP request sent, awaiting response... 200 OK
但在浏览器中,我仍然收到错误ERR_CONNECTION_REFUSED
编辑3
好的,我越来越接近答案了:
$ nmap localhost
Starting Nmap 6.40 ( http://nmap.org ) at 2015-11-22 13:27 AST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00040s latency).
Not shown: 995 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
9090/tcp open zeus-admin
3306/tcp open mysql
5432/tcp open postgresql
那么,端口 9090 没有像端口 80 那样使用 http 服务,这是问题吗?如何解决?
我尝试了端口 96,但使用 nmap localhost 时未列出该端口,我得到了ERR_CONNECTION_TIMED_OUT
因此,我只能本地连接,但是当使用浏览器时,我知道ERR_CONNECTION_TIMED_OUT
如何正确打开端口?
答案1
感谢每一位努力支持的人,解决方案非常简单:
sudo ufw allow [port number]
我不知道我必须自己打开端口!
答案2
错误显示 403 - 禁止,请确保 Nginx 用户可以从你的 webroot 读取(/home/forge/tree/public
)并且如果启用了 SELinux,你还必须添加此端口以允许访问:
semanage port -a -t http_port_t -p tcp 9090