Конфигурация Nginx не влияет на MacOS High Sierra - PullRequest
0 голосов
/ 29 мая 2018

У меня есть проблема, которую нужно очистить.Я установил и настроил 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;
    }
}

Iесть настройка 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()

Как я могу исправить эти проблемы?

1 Ответ

0 голосов
/ 29 мая 2018

Измените listen 80; на listen 8080; У вас уже есть процесс на порту 80.

РЕДАКТИРОВАТЬ: попробуйте удалить listen-address=127.0.0.1 из dnsmasq.conf.

и перезапустите dnsmasq с помощью sudo brew services restart dnsmasq.

Всегда используйте sudo... при запуске или остановке служб, работающих под портом 1000.

Я думаю, что наиболее вероятно dnsresolver.

...