Nginx+PHP+FastCGI的部署(2)

编译安装nginx:
[root@server5 pcre-7.9]# cd ..
[root@server5 software]# tar -zxvf ../tarbag/nginx-0.8.20.tar.gz
[root@server5 software]# cd nginx-0.8.20/
[root@server5 nginx-0.8.20]# groupadd www
[root@server5 nginx-0.8.20]# useradd -g www www
root@server5 nginx-0.8.20]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1 library is not used
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
[root@server5 nginx-0.8.20]# make && make install

修改fpm主配置文件,将运行的用户和组改为www
[root@server5 ~]# grep -A 2 'www' /usr/local/php5/etc/php-fpm.conf
<value>www</value>                        

Unix group of processes
<value>www</value>

[root@server5 ~]# getenforce //关闭selinux,否则需要修改php的content,Apache亦是如此
Permissive    

[root@server5 ~]# /usr/local/php5/sbin/php-fpm start //启动fpm
Starting php_fpm done

[root@server5 ~]# netstat -ntpl |grep 9000   //侦听回环地址的9000端口,若PHP和nginx不在同一台服务器上,则需监听在内网地址上
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      30739/php-cgi

[root@server5 ~]# ps -ef |grep php |grep -v 'grep' |wc -l
6
[root@server5 ~]# /usr/local/nginx/sbin/nginx -t     //测试nginx配置文件语法
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@server5 ~]# /usr/local/nginx/sbin/nginx   //启动nginx
[root@server5 ~]# cat > /usr/local/nginx/html/info.php <<EOF
> <?php
> phpinfo();
> ?>
> EOF

[root@server5 ~]# grep -v '^#' /usr/local/nginx/conf/nginx.conf |grep -v '#' |uniq //修改主配置文件如下
user www;
worker_processes 1;

events {
worker_connections 1024;
}

http {
include       mime.types;
default_type application/octet-stream;

sendfile        on;

keepalive_timeout 65;

server {
listen       80;
server_name server5;

location / {
root   html;
index index.php index.html index.htm;
}

error_page   500 502 503 504 /50x.html;
location = /50x.html {
root   html;
}

location ~ \.php$ {
root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include        fastcgi_params;
}

}

}

[root@server5 ~]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid` //重启nginx

Nginx+PHP+FastCGI的部署

Nginx+PHP+FastCGI的部署

Nginx+PHP+FastCGI的部署

linux

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydfdf.html