我刚开始在AWS AMI实例上使用Nginx,并且遇到了一些启动问题。
我已按照此链接安装php-fpm和nginx https://gist.github.com/sumardi/5559803
除此之外,我不需要mysql,因此我没有运行此命令Internet:
Destination Gateway Flags Refs Use Netif Expire
default link#19 UCS 9 0 utun1
default 192.168.2.1 UGScI 3 0 en0
10.10.10/24 link#19 UCS 1 0 utun1
10.10.10.11 link#19 UHW3I 0 4 utun1 62
17.158.10.25 link#19 UHW3I 0 1 utun1 62
17.158.10.42 link#19 UHW3I 0 20 utun1 62
17.158.10.46 link#19 UHW3I 0 1 utun1 62
127 127.0.0.1 UCS 0 7 lo0
127.0.0.1 127.0.0.1 UH 15 128507 lo0
128.29.154.114 link#19 UHWIi 31 117 utun1
129.83.20.9 link#19 UHW3I 0 20 utun1 61
129.83.26.209 link#19 UHWIi 2 2 utun1
129.83.100.38 link#19 UHW3I 0 46 utun1 62
169.254 link#19 UCS 0 0 utun1
172.31.160/19 link#19 UCS 0 0 utun1
172.31.163.172/32 127.0.0.1 UGSc 3 67 lo0
192.80.55.9/32 192.168.2.1 UGSc 1 0 en0
192.168.2 link#19 UCS 0 0 utun1
192.168.2.1 68:7f:74:81:8b:b0 UHLSr 7 8 en0
192.168.2.1/32 link#19 UCS 0 0 utun1
192.168.2.106/32 link#4 UCS 0 0 en0
216.58.217.132 link#19 UHW3I 0 2 utun1 59
239.255.255.250 link#19 UHmW3I 0 17 utun1 62
我的sudo yum -y install mysql-server mysql
看起来像这样:
/etc/nginx/conf.d/default.conf
我的location / {
root /var/www/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/
html$fastcgi_script_name;
include fastcgi_params;
}
/etc/php-fpm.d/www.conf
然而,我可以看到当我调用.php文件时,它只是下载。当我运行; Start a new pool named 'www'.
[www]
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1
;listen.backlog = -1
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = 127.0.0.1
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0666
;listen.owner = nobody
listen.owner = nginx
;listen.group = nobody
listen.group = nginx
;listen.mode = 0666
listen.mode = 0664
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives:
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; Note: This value is mandatory.
pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 50
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 5
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 5
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 35
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
; accepted conn - the number of request accepted by the pool;
[....]
时,我收到以下错误:
service nginx start
请帮忙
答案 0 :(得分:4)
这就是我能够解决问题的方法。服务器标记应该包含/etc/nginx/conf.d/default.conf
server {
location / {
root /var/www/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}