通过宝塔面板配置完后,正常的一个流程是
有个总的nginx配置,路径在
/www/server/nginx/conf/nginx.conf
内容如下:
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}
这里重点看这行
include /www/server/panel/vhost/nginx/*.conf;
这里意为引入改路径下的单独网站的server配置。(这样的好处是如果多个网站,则可以每个网站单独分开配置各自的server内容)
任意一个网站有如下简单的配置
这里可以在主nginx配置文件的路径/www/server/nginx/conf/下,找到enable-php-72.conf 文件,打开可以看到如下内容:
即代表,访问的每个php文件,必须要经过72版本的php解释器
这里使用php-fpm sock 方式,使php与nginx 通信,配置如下:(php-fpm是FastCGI进程管理器,php-fpm不需要再依赖php-cgi,直接把php解释器的功能集成进php-fpm了)
fastcgi_pass unix:/tmp/php-cgi-72.sock;
当然,也可以使用tcp方式,使php-cgi(PHP-CGI是PHP自带的FastCGI管理器)与nginx通信,端口9000,配置如下
fastcgi_pass 127.0.0.1:9000;
这两种都是可以的,速度来说,使用socket更快,而tcp可以跨服务器,详情比较可见
https://www.jianshu.com/p/b430d0abad0e 进行了解。
附宝塔形式下,ssh命令操作nginx的操作
/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx restart
/etc/init.d/nginx reload
宝塔下的php-fpm重启
service php-fpm-72 restart (这里是重启7.2版本,其他版本相应修改即可)