第二步:配置nginx的FCGI vi /usr/local/nginx/conf/fcgi.conf
写入以下内容:
复制代码代码示例:
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REMOTE_ADDR $remote_addr;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
第三步:配置php-fpm文件
重新写入以下内容
复制代码代码示例:
<?xml version="1.0" ?> All relative paths in this config are relative to php's install prefix <section name="global_options">
Pid file
Error log file
Log level
When this amount of php processes exited with SIGSEGV or SIGBUS ...
... in a less than this interval of time, a graceful restart will be initiated.
Time limit on waiting child's reaction on signals from master
Set to 'no' to debug fpm </section> <workers> <section name="pool">
Name of pool. Used in logs and stats.
Address to accept fastcgi requests on. <value name="listen_options">
Set listen(2) backlog
Set permissions for unix socket, if one used.
Additional php.ini defines, specific to this pool of workers.
Unix user of processes
Unix group of processes
Process manager settings
Sets style of controling worker process count.
Sets the limit on the number of simultaneous requests that will be served.
Settings group for 'apache-like' pm style
Sets the number of server processes created on startup.
Sets the desired minimum number of idle server processes.
Sets the desired maximum number of idle server processes. </value> </value>
The timeout (in seconds) for serving a single request after which the worker process will be terminated
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
The log file for slow requests
Set open file desc rlimit
Set max core size rlimit
Chroot to this directory at the start, absolute path
Chdir to this directory at the start, absolute path
Redirect workers' stdout and stderr into main error log.
How much requests each process should execute before respawn.
Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
Pass environment variables like LD_LIBRARY_PATH </section> </workers> </configuration>
第四步:配置nginx.conf文件
复制代码代码示例:
user www www;
worker_processes 8;
#error_log /usr/local/nginx/logs/error.log; #pid logs/nginx.pid; worker_rlimit_nofile 204800;
events {
http {
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' #access_log logs/access.log main;
sendfile on;
ignore_invalid_headers on;
gzip on;
server_names_hash_bucket_size 256;
open_file_cache max=204800 inactive=20s;
location ~ .*\.(js|css)?$ {
location ~ .*\.(log|txt)$
location ~ .*\.(php)?$
7、启动服务
复制代码代码示例:
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
检查是否成功启动:
复制代码代码示例:
[root@localhost ~]# netstat -tunlp
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 3937/snmpd tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3954/php-cgi tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2662/mysqld tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 18066/nginx tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 17955/vsftpd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4137/sendmail: acce tcp 0 0 :::5989 :::* LISTEN 2714/cimserver tcp 0 0 :::22 :::* LISTEN 2574/sshd udp 0 0 0.0.0.0:161 0.0.0.0:* 3937/snmpd 可见php-cgi和nginx端口已经正常监听了。 (责任编辑:IT) |