嗨,我是nginx上的新手,我试着在我的服务器(运行Ubuntu 4)上设置它,它已经运行了apache。
所以在我apt-get install它之后,我尝试启动nginx。然后我得到这样的消息:
Starting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)这是有意义的,因为Apache正在使用端口80。
然后我试着修改nginx.conf,我参考了一些文章,所以我把它改成这样:
server {
listen 8080;
location / {
proxy_pass http://xx.xx.xx.xx:9500;
proxy_set_header Host $host:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}在保存此文件并尝试再次启动nginx后,我仍然得到与以前相同的错误。我真的找不到关于这方面的相关帖子,有没有好的人能给我一点启发?
提前感谢:)
=========================================================================
我应该在这里发布中的所有内容:
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/*;
server {
listen 81;
location / {
proxy_pass http://94.143.9.34:9500;
proxy_set_header Host $host:81;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}
}
mail {
See sample authentication script at:
http://wiki.nginx.org/NginxImapAuthenticateWithApachePhpScript
auth_http localhost/auth.php;
pop3_capabilities "TOP" "USER";
imap_capabilities "IMAP4rev1" "UIDPLUS";
server {
listen localhost:110;
protocol pop3;
proxy on;
}
server {
listen localhost:143;
protocol imap;
proxy on;
}
}基本上,除了添加服务器部分之外,我什么也没做。
发布于 2012-10-09 20:52:10
您必须转到/etc/nginx/sites-enabled/,如果这是默认配置,那么应该有一个名称为:default的文件。
通过定义所需的端口来编辑该文件;在下面的代码片段中,我们在端口81上为Nginx实例提供服务。
server {
listen 81;
}要启动服务器,请运行以下命令行;
sudo service nginx start您现在可以在端口81上访问您的应用程序(对于本地主机,http://localhost:81)。
发布于 2013-10-08 22:36:37
您需要更改Apache或Nginx的配置端口。完成此操作后,您将需要使用您使用的'service‘命令重新启动重新配置的服务器。
Apache
编辑
sudo subl /etc/apache2/ports.conf 并将以下行中的80更改为不同的值:
Listen 80如果只是在此处更改端口或添加更多端口,则很可能还必须在
sudo subl /etc/apache2/sites-enabled/000-default.conf并将以下行中的80更改为不同的值:
<VirtualHost *:80>然后通过以下方式重新启动:
sudo service apache2 restartNginx
编辑
/etc/nginx/sites-enabled/default并更改以下行上的80:
listen 80;然后通过以下方式重新启动:
sudo service nginx restart发布于 2015-07-13 17:21:04
遵循以下步骤:打开您的配置文件
vi /etc/nginx/conf.d/default.conf更改您正在侦听的端口号;
listen 81;
server_name localhost;向iptables添加规则
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 81 -j ACCEPT重新启动IPtables
service iptables restart;重启nginx服务器
service nginx restart访问端口81上的yr nginx服务器文件
https://stackoverflow.com/questions/10829402
复制相似问题