Mac os nginx restart

Содержание
  1. Как перезапустить nginx на OS X
  2. 12 ответов
  3. jimothyGator / README.md
  4. This comment has been minimized.
  5. spamguy commented Sep 25, 2015
  6. This comment has been minimized.
  7. Vetal4eg commented Oct 1, 2015
  8. This comment has been minimized.
  9. anthonybrown commented Oct 13, 2015
  10. This comment has been minimized.
  11. wellington1993 commented Mar 30, 2016
  12. This comment has been minimized.
  13. andresnator commented May 28, 2016
  14. This comment has been minimized.
  15. iplus26 commented Jun 7, 2016
  16. This comment has been minimized.
  17. raulvillca commented Aug 14, 2016
  18. This comment has been minimized.
  19. cr2121 commented Sep 20, 2016
  20. This comment has been minimized.
  21. craigiswayne commented Dec 19, 2016
  22. This comment has been minimized.
  23. j0t3x commented Dec 26, 2016
  24. This comment has been minimized.
  25. sivcan commented Jan 19, 2017
  26. This comment has been minimized.
  27. trainiac commented Jan 22, 2017
  28. This comment has been minimized.
  29. Oliboy50 commented Feb 1, 2017
  30. This comment has been minimized.
  31. nyxee commented Aug 25, 2017
  32. This comment has been minimized.
  33. ihorvorotnov commented Feb 22, 2018
  34. This comment has been minimized.
  35. efthemiosprime commented Mar 25, 2018
  36. This comment has been minimized.
  37. agm1984 commented Oct 11, 2018 •
  38. dtomasi / default
  39. This comment has been minimized.
  40. baumannsven commented Aug 2, 2016
  41. This comment has been minimized.
  42. baumannsven commented Aug 3, 2016 •
  43. This comment has been minimized.
  44. baumannsven commented Aug 3, 2016
  45. This comment has been minimized.
  46. baumannsven commented Aug 3, 2016
  47. This comment has been minimized.
  48. raymondjplante commented Jan 2, 2017
  49. This comment has been minimized.
  50. ghost commented Feb 14, 2017
  51. This comment has been minimized.
  52. johnwilson commented Mar 22, 2017
  53. This comment has been minimized.
  54. chaeMil commented Mar 22, 2017
  55. This comment has been minimized.
  56. datadimension commented Mar 25, 2017
  57. This comment has been minimized.
  58. njsubedi commented Apr 4, 2017
  59. This comment has been minimized.
  60. tobecwb commented Jun 1, 2017
  61. This comment has been minimized.
  62. birchcode commented Nov 24, 2017
  63. This comment has been minimized.
  64. apedicdev commented Nov 24, 2017
  65. This comment has been minimized.
  66. fsebbah commented Feb 20, 2018 •
  67. This comment has been minimized.
  68. thanhoangxuannghiep commented Apr 22, 2018
  69. This comment has been minimized.
  70. bindzus commented Apr 26, 2018
  71. This comment has been minimized.
  72. pooyagolchian commented Jun 18, 2018
  73. This comment has been minimized.
  74. maitandat1507 commented Oct 7, 2018

Как перезапустить nginx на OS X

Я использую nginx на OS X 10.8. Свежеустановленная nginx но не могу найти способ перезапустить nginx, кроме kill nginx_pid сказать kill 64116 . Интересно, есть ли лучшие способы перезапустить nginx .

нашел некоторые методы в Google и так, но не работал:

сообщение об ошибке nginx -s restart и

иногда также появляется эта ошибка msg:

12 ответов

каково ваше местоположение файла nginx pid? Это указано в файле конфигурации, пути по умолчанию указаны во время компиляции в сценарии конфигурации. Вы можете искать его как таковой:

find / -name nginx.pid 2>/dev/null (должен выдавать во время работы nginx)

попробуй sudo nginx перед запуском nginx

перезагрузить конфигурационный файл:

для полного перезапуска nginx :

подробности

нет restart сигнал для nginx. Из документов вот сигналы, которые принимает главный процесс:

предположительно вы могли бы отправить эти сигналы идентификатору процесса вручную, но флаг nginx -s это посылает сигналы к главному процессу для вас. Ваши параметры являются:

нет необходимости futz с pid вручную.

Edit: только что понял, что большая часть этой информации уже была в комментариях к другим ответам. Оставим это здесь, чтобы подытожить ситуацию.

Я делаю это так:

затем запустите nginx

как будущий ресурс, вы можете проконсультироваться http://wiki.nginx.org/CommandLine

Nginx вероятно, работает как root, поэтому вам нужно будет запустить вариант следующей команды, чтобы повлиять на него.

обычно нет особых причин для перезапуска Nginx как Apache потребуется. Если вы изменили файл конфигурации,вы можете просто захотеть перезагрузить опцию.

проверьте, существует ли этот каталог:

эта ошибка может возникнуть, когда nginx пытается инициализировать PID-файл в локализация, которой не существует.

здесь есть ошибка. В зависимости от того, работает ли nginx во время изменения/перезапуска apache и/или изменения конфигураций nginx, этот файл (который по существу является указателем идентификатора процесса) может быть уничтожен.

Читайте также:  Операционная система windows для слабых компьютеров

при попытке отправить любой сигнал nginx, как

nginx использует этот файл для ссылки на идентификатор процесса, которому он должен отправить сигнал. Если файл не существует связи между активным запущенным процессом nginx и приложение cli эффективно сломано.

Я фактически оказался в состоянии, когда два процесса nginx работали одновременно, поэтому убили обоих.

чтобы обойти это, вы можете либо принудительно завершить существующие процессы nginx через монитор активности (затем запустите nginx и попросите приложение cli создать новый nginx.PID-файл) или если вам действительно нужно сохранить nginx, но хотите запустить перезагрузку nginx-s — вручную создайте файл в пути /run под названием nginx.pid и вставить PID в настоящее время запущены процессы nginx (полученные с помощью монитора активности).

для перезагрузки пользовательского файла конфигурации используйте

Источник

jimothyGator / README.md

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/

Not documented yet:

  • How to create self-signed SSL certificates
  • How to start and stop Nginx
server <
listen 443;
server_name localhost;
ssl on;
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / <
root html;
index index.html index.htm;
>
>
server <
listen 80;
server_name localhost;
#access_log logs/host.access.log main;
location / <
root html;
index index.html index.htm;
>
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html <
root html;
>
>
xml version = » 1.0 » encoding = » UTF-8 » ?>
DOCTYPE plist PUBLIC «-//Apple//DTD PLIST 1.0//EN» «http://www.apple.com/DTDs/PropertyList-1.0.dtd»>
plist version = » 1.0 » >
dict >
key > Label key >
string > homebrew.mxcl.nginx string >
key > RunAtLoad key >
true/>
key > KeepAlive key >
false/>
key > ProgramArguments key >
array >
string > /usr/local/opt/nginx/sbin/nginx string >
string > -g string >
string > daemon off; string >
array >
key > WorkingDirectory key >
string > /usr/local string >
dict >
plist >
#user nobody;
worker_processes 1 ;
error_log /Library/Logs/nginx/error.log;
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 /Library/Logs/nginx/access.log main ;
sendfile on ;
keepalive_timeout 65 ;
index index.html index.php;
upstream www-upstream-pool <
server unix:/tmp/php-fpm.sock;
>
include /etc/nginx/conf.d/*.conf;
include /usr/local/etc/nginx/sites-enabled/*.conf;
>

This comment has been minimized.

Copy link Quote reply

spamguy commented Sep 25, 2015

Good idea putting the logs in /Library/Logs. I had to create the directory /Library/Logs/nginx first—nginx couldn’t handle that itself.

This comment has been minimized.

Copy link Quote reply

Vetal4eg commented Oct 1, 2015

@spamguy What good in logs at /Library/Logs? Only unix way, only hardcore!

This comment has been minimized.

Copy link Quote reply

anthonybrown commented Oct 13, 2015

I can’t seem to get nginx to load anything on port :8080
brew install nginx —with-passenger

followed brew’s instructions but couldn’t get localhost to work.
I have it running on my iMac but not on my MBP, is there some difference in configuration?

This comment has been minimized.

Copy link Quote reply

wellington1993 commented Mar 30, 2016

This comment has been minimized.

Copy link Quote reply

andresnator commented May 28, 2016

This comment has been minimized.

Copy link Quote reply

iplus26 commented Jun 7, 2016

You saved my day.

Forgot to include /usr/local/etc/nginx/sites-enabled/*.conf;

This comment has been minimized.

Copy link Quote reply

raulvillca commented Aug 14, 2016

include /etc/nginx/conf.d . i must make it, cause i didn’t find it

This comment has been minimized.

Copy link Quote reply

cr2121 commented Sep 20, 2016

This comment has been minimized.

Copy link Quote reply

craigiswayne commented Dec 19, 2016

Found this «create your own signed certificate for mac» tutorial
https://certsimple.com/blog/localhost-ssl-fix

This comment has been minimized.

Copy link Quote reply

j0t3x commented Dec 26, 2016

This comment has been minimized.

Copy link Quote reply

sivcan commented Jan 19, 2017

Thanks a lot dude!

This comment has been minimized.

Copy link Quote reply

trainiac commented Jan 22, 2017

/usr/local/opt/nginx/sbin/nginx was /usr/local/opt/nginx/bin/nginx for me. Thanks!

This comment has been minimized.

Copy link Quote reply

Oliboy50 commented Feb 1, 2017

This comment has been minimized.

Copy link Quote reply

Читайте также:  Объект файл windows это

nyxee commented Aug 25, 2017

people always fail to inform others to edit /private/etc/hosts and add entries for the servers.

This comment has been minimized.

Copy link Quote reply

ihorvorotnov commented Feb 22, 2018

@nyxee or just let dnsmasq handle it

This comment has been minimized.

Copy link Quote reply

efthemiosprime commented Mar 25, 2018

where can i find the /private/etc/hosts?

This comment has been minimized.

Copy link Quote reply

agm1984 commented Oct 11, 2018 •

The hosts files is found at /etc/hosts in both Mac OS and Unix systems.

Typically, you can type

and it will open the file, if you have nano installed. There is a good chance you have nano installed. Try it, if not, use your favourite text editor. Make sure you open the file with elevated privileges so you can save it. It is a system file.

As mentioned above, you can also use dnsmasq which auto forwards *.dev domains in your browser to localhost.

Источник

dtomasi / default

Install NGINX with PHP7-FPM on Mac OS X with Homebrew

Install Commandline Tools

ruby -e «$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)»

Install brew services

brew tap homebrew/services

Install bash completion (Optional)

brew install bash-completion

Update Brew and Packages if allready installed

brew update && brew upgrade

Add following lines

DNSMasq is used to resolve all domains that end with .dev to 127.0.0.1. So you don´t need to touch hosts-File anymore.

Start, Stop and Restart

sudo nano /usr/local/etc/php/7.0/php-fpm.d/www.conf

sudo brew services start php70

show running processes

lsof -Pni4 | grep LISTEN | grep php

Output should look like this

sudo brew services stop nginx

Create missing directories

Start and Test Nginx

Create a folder for our SSL certificates and private keys:

mkdir -p /usr/local/etc/nginx/ssl

Generate 4096 bit RSA keys and the self-sign the certificates in one command:

openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj «/C=US/ST=State/L=Town/O=Office/CN=localhost» -keyout /usr/local/etc/nginx/ssl/localhost.key -out /usr/local/etc/nginx/ssl/localhost.crt

Setup example virtual hosts

These are working presets. But you need to edit Document-Root

Activate Virtual Hosts

Create info.php for testing echo » /path/to/your/document/root

server <
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / <
include /usr/local/etc/nginx/conf.d/php-fpm;
>
location = /info <
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
>
error_page 404 /404.html;
error_page 403 /403.html;
>
server <
listen 443;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default-ssl.access.log main;
ssl on;
ssl_certificate ssl/localhost.crt;
ssl_certificate_key ssl/localhost.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / <
include /usr/local/etc/nginx/conf.d/php-fpm;
>
location = /info <
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
>
error_page 404 /404.html;
error_page 403 /403.html;
>
address=/.dev/127.0.0.1
listen-address=127.0.0.1
worker_processes 1 ;
error_log /Library/Logs/nginx/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 /Library/Logs/nginx/access.log main ;
sendfile on ;
keepalive_timeout 65 ;
index index.html index.php;
include /usr/local/etc/nginx/sites-enabled/*;
>

\.php$ < try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; >

This comment has been minimized.

Copy link Quote reply

baumannsven commented Aug 2, 2016

By section dnsmasq => configure.
Before download the dev in /etc/resolver, must be create the resolver directory.

This comment has been minimized.

Copy link Quote reply

baumannsven commented Aug 3, 2016 •

By sites configuration default in line 15 and default-ssl in line 25 replace with:
rewrite (.*) /info.php;

This comment has been minimized.

Copy link Quote reply

baumannsven commented Aug 3, 2016

Replace the correctly curl url for:

  • default
  • default-ssl

This comment has been minimized.

Copy link Quote reply

baumannsven commented Aug 3, 2016

After download site configuration, download php-fpm configuration.

This comment has been minimized.

Copy link Quote reply

raymondjplante commented Jan 2, 2017

MySQL and nginx modules are installed by default in the php70 install (apache is disabled by default).
—without-apache —with-fpm —with-mysql is unneeded as the options no longer exist and you’ll get warnings from brew (it will probably still build fine, but it always hurts my OCD).

Читайте также:  Greater windows and doors

This comment has been minimized.

Copy link Quote reply

ghost commented Feb 14, 2017

In the section
«Test Installation and Start and Test Nginx»
curl -IL http://127.0.0.1:8080
curl -IL http://localhost

I get curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused and curl: (7) Failed to connect to localhost port 80: Connection refused

Help! Everything else went fine with no trouble, I just can’t view anything.

This comment has been minimized.

Copy link Quote reply

johnwilson commented Mar 22, 2017

@the-interactive-company you might have manually create the /Library/Logs/nginx/ directory

This comment has been minimized.

Copy link Quote reply

chaeMil commented Mar 22, 2017

i keep getting bad gateway error when trying to run php files. Im on El Capitan.

This comment has been minimized.

Copy link Quote reply

datadimension commented Mar 25, 2017

This is completely full of bugs and direct rip off of https://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/ for an older version of PHP.
It does more damage that usefulness — cannot even get HTML to work now.

This comment has been minimized.

Copy link Quote reply

njsubedi commented Apr 4, 2017

@chaeMil your php-fpm instance is not running.

This comment has been minimized.

Copy link Quote reply

tobecwb commented Jun 1, 2017

Some corrections to make this thing works:

on PHP-FPM, in Configure ( sudo nano /usr/loca/etc/php7.0/php-fpm.d/www.conf ), use:

(don’t need the YOUR_GROUP || staff)

After Stop Nginx, Create missing directories and Configure nginx.conf , edit nginx.conf and make following changes:

remove the line error_log /Library/Logs/nginx/error.log debug;

inside http section, insert/update the following lines:

remove sendfile on;

then, the php-fpm must be configured.

create a file in /usr/local/etc/nginx/conf.d/php-fpm with the following content:

and finally, configure the virtual hosts.

edit the files /usr/local/etc/nginx/sites-available/default and /usr/local/etc/nginx/sites-available/default-ssl , and remove the files access_log (access log is already configured in nginx.conf

I don’t remember if this is all that I changed, but worked fine after this.

This comment has been minimized.

Copy link Quote reply

birchcode commented Nov 24, 2017

Thank you for wasting my time with this buggy shit.

This comment has been minimized.

Copy link Quote reply

apedicdev commented Nov 24, 2017

@birchcode you may write yours

This comment has been minimized.

Copy link Quote reply

fsebbah commented Feb 20, 2018 •

@tobecwb : your config are correct just in the nginx.conf at the header it’s important to add
user YOUR_NAME YOUR_GROUP;
without this you have an 403 error

Here you find a good config nginx website

This comment has been minimized.

Copy link Quote reply

thanhoangxuannghiep commented Apr 22, 2018

I cannot tap to homebrew/dupes. When I run command «brew tap homebrew/dupes». I got this message: «Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated». How’s about this issue?

This comment has been minimized.

Copy link Quote reply

bindzus commented Apr 26, 2018

@thanhoangxuannghiep I don’t think you need homebrew/dupes anymore, it looks like everything you need is available from Homebrew core.

This comment has been minimized.

Copy link Quote reply

pooyagolchian commented Jun 18, 2018

sudo nginx -t
nginx: [emerg] open() «/usr/local/etc/nginx/conf.d/php-fpm» failed (2: No such file or directory) in /usr/local/etc/nginx/sites-enabled/default:9
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

Why php-fpm is not in conf.d folder?

This comment has been minimized.

Copy link Quote reply

maitandat1507 commented Oct 7, 2018

Some corrections to make this thing works:

on PHP-FPM, in Configure ( sudo nano /usr/loca/etc/php7.0/php-fpm.d/www.conf ), use:

(don’t need the YOUR_GROUP || staff)

After Stop Nginx, Create missing directories and Configure nginx.conf , edit nginx.conf and make following changes:

remove the line error_log /Library/Logs/nginx/error.log debug;

inside http section, insert/update the following lines:

remove sendfile on;

then, the php-fpm must be configured.

create a file in /usr/local/etc/nginx/conf.d/php-fpm with the following content:

and finally, configure the virtual hosts.

edit the files /usr/local/etc/nginx/sites-available/default and /usr/local/etc/nginx/sites-available/default-ssl , and remove the files access_log (access log is already configured in nginx.conf

I don’t remember if this is all that I changed, but worked fine after this.

Thanks for your php-fpm configuration content! It save my day!

Источник

Оцените статью