useradd hehe -M -s /sbin/nologin //创建用户 hehe
//-M 不创建home目录
//-s /sbin/nologin 不给登陆
make && make install
cd /usr/local/php/etc //去到有php-fpm.conf的配置目录
vim php-fpm.conf //编辑,把下面的 ; 去了 分号去掉
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
daemonize = yes
保存退出来之后,还要启动php-fpm.
/usr/local/php/sbin/php-fpm //开启php-fpm
ps -ef | grep -fpm //看一下进程
完成上面的步骤,下面就是到nginx。
cd /usr/local/nginx/conf
vim nginx.conf
user hehe; //添加一个用户吧,最好不是root,我的是hehe
worker_processes //默认1个,cpu核数的1-2倍
pid logs/nginx.pid; //这个把#号去了。
server {
listen 8777; //这个是我搞的8777端口
server_name localhost; //域名的地方,没有就localhost
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /web; //你网站的根目录
index index.html index.htm index.php;
}
location ~ .*.php$ {
root /web; //这个是我自己根目录路径
fastcgi_pass 127.0.0.1:9000; //你自己的域名,后面一般跟着:9000
include /usr/local/nginx/conf/fastcgi_params; //看这个fastcgi_params,下面有参数
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
fastcgi_params文件的参数,用到的时候回来看看
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#脚本文件请求的路径
fastcgi_param QUERY_STRING $query_string; #请求的参数;如?app=123
fastcgi_param REQUEST_METHOD $request_method; #请求的动作(GET,POST)
fastcgi_param CONTENT_TYPE $content_type; #请求头中的Content-Type字段
fastcgi_param CONTENT_LENGTH $content_length; #请求头中的Content-length字段。
fastcgi_param SCRIPT_NAME $fastcgi_script_name; #脚本名称
fastcgi_param REQUEST_URI $request_uri; #请求的地址不带参数
fastcgi_param DOCUMENT_URI $document_uri; #与$uri相同。
fastcgi_param DOCUMENT_ROOT $document_root; #网站的根目录。在server配置中root指令中指定的值
fastcgi_param SERVER_PROTOCOL $server_protocol; #请求使用的协议,通常是HTTP/1.0或HTTP/1.1。
fastcgi_param GATEWAY_INTERFACE CGI/1.1;#cgi 版本
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;#nginx 版本号,可修改、隐藏
fastcgi_param REMOTE_ADDR $remote_addr; #客户端IP
fastcgi_param REMOTE_PORT $remote_port; #客户端端口
fastcgi_param SERVER_ADDR $server_addr; #服务器IP地址
fastcgi_param SERVER_PORT $server_port; #服务器端口
fastcgi_param SERVER_NAME $server_name; #服务器名,域名在server配置中指定的server_name
#fastcgi_param PATH_INFO $path_info;#可自定义变量
# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS 200;
在php可打印出上面的服务环境变量
如:echo $_SERVER['REMOTE_ADDR']
最后一步启动nginx //可以./nginx -h看帮助,一堆英文
/usr/local/nginx/sbin/nginx //开启
pkill nginx //关闭,直接杀进程,虽然不建议。
/usr/local/nginx/sbin/nginx -s reload //重启
ps -ef | grep nginx //自己去看进程吧。
自己phpinfo去浏览器看看吧。额~我用的是8777端口还有nginx很多很多参数,百度就可以找到了。多百度,谷歌