Ho usato questo blog come base per la creazione di un ambiente locale per l'esecuzione di siti PHP su MacOS Sierra. Ho installato NGINX, PHP 7, PHP-FPM, MySQl e PhpMyAdmin. Tutte le parti sembrano funzionare:
Utilizzando l'impostazione predefinita nginx.conf e in esecuzione: curl -IL http://127.0.0.1:8080
, Ottengo:
HTTP/1.1 200 OK
Server: nginx/1.12.1
Date: Tue, 22 Aug 2017 08:10:03 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 11 Jul 2017 13:24:27 GMT
Connection: keep-alive
ETag: "5964d18b-264"
Accept-Ranges: bytes
Per quanto riguarda PHP-FPM, in esecuzione: lsof -Pni4 | grep LISTEN | grep php
, Ottengo:
php-fpm 13178 phil 6u IPv4 0x2b2cdb4c34e4e2c3 0t0 TCP 127.0.0.1:9000 (LISTEN)
php-fpm 13181 phil 0u IPv4 0x2b2cdb4c34e4e2c3 0t0 TCP 127.0.0.1:9000 (LISTEN)
php-fpm 13182 phil 0u IPv4 0x2b2cdb4c34e4e2c3 0t0 TCP 127.0.0.1:9000 (LISTEN)
Posso anche iniziare MySQL, ottengo:
mysql>
Utilizzando l'impostazione predefinita nginx.conf , posso visitare http://localhost-8080.com/ e vedo il 'Welcome to nginx!' schermata di test.
Il problema viene quando modifico il mio nginx.conf . Ecco come l'ho modificato:
user phil staff;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /Users/phil/sites/drupal/;
index index.php;
}
location ~ \.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}
Ora, se corro brew services restart nginx
e poi sudo nginx -t
, Ottengo:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
... ma, se visito http: // localhost / , Ottengo Local host refused to connect
.
La mia impressione รจ che siano permessi e usi la porta 80, ma non sono sicuro di cosa fare per farlo funzionare.
Se lo faccio curl -IL http://127.0.0.1:80
, Ottengo:
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
Grazie.