我有一些问题需要明确。我有安装和配置nginx但没有成功。这是我的文件/usr/local/etc/nginx/nginx.conf
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/etc/nginx/logs/access.log main;
sendfile off;
keepalive_timeout 65;
index index.html index.php;
include /usr/local/etc/nginx/sites-enabled/*;
}
file / usr / local / etc / nginx / sites-enabled / mage
server {
listen 80;
server_name mage.local;
root /Users/nghiepthan/Sites/html/;
access_log /Users/nghiepthan/Sites/html/nginx.access.log;
error_log /Users/nghiepthan/Sites/html/nginx.error.log;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
try_files $uri $uri/ /test.php?$query_string;
}
}
我已经设置了dnsmasq。文件配置/usr/local/etc/dsnmasq.conf
address=/.local/127.0.0.1
listen-address=127.0.0.1
接下来,我定义了/ etc / resolver / local nameserver 127.0.0.1
但是,当我运行命令curl -IL http://mage.local
时我收到了消息:* curl:(6)无法解析主机:mage.local *
但如果我运行命令
curl -IL http://localhost
我得到了这样的成功回应
HTTP/1.1 200 OK
Server: nginx/1.13.12
Date: Tue, 29 May 2018 11:07:27 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.1.18
当我在浏览器上运行时,我键入了URL = localhost,它转到我定义的路径。我不知道我错在哪里。我试着运行命令sudo nginx但是我遇到了这个错误:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()
如何解决这些问题?
答案 0 :(得分:0)
将listen 80;
更改为listen 8080;
您已在端口80上创建了一个进程。
编辑:尝试从dnsmasq.conf中删除listen-address=127.0.0.1
。
使用sudo brew services restart dnsmasq
重新启动dnsmasq。
启动或停止在端口1000下运行的服务时始终使用sudo...
。
我认为它最有可能是dnsresolver。