通過寶塔面板配置完後,正常的一個流程是
有個總的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版本,其他版本相應修改即可)