完整版:
nginx配置:
位置:
内容:
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;
}
# A部分
# server{
# listen 80;
# server_name location;
# location / {
# root /www/wwwroot/mikotofans/client/dist;
# index index.html ;
# try_files $uri $uri/ index.html;
# }
# location /api {
# proxy_pass http://127.0.0.1:5214/api;
# }
# }
# B部分
include /www/server/panel/vhost/nginx/*.conf;
}
项目配置文件:
位置:
内容:
server
{
listen 80;
server_name localhost;
index index.php index.html index.htm default.php default.htm default.html;
#下面的地址以自己的前端地址为准,虽然不写也没关系,下面的必写
root /www/wwwroot/XXXXXXX/client/dist;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-71.conf;
#PHP-INFO-END
#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
# 此处为自动配置的,如果删除了,可以按照下面的地址写
include /www/server/panel/vhost/rewrite/www.xxxxx.fans.conf;
#REWRITE-END
location / {
# 下面的地址以自己的前端地址为准,此次必写,上面的可以不写
root /www/wwwroot/XXXXXXXX/client/dist;
index index.html ;
try_files $uri $uri/ index.html;
}
location /api {
# 改为自己的端口号
proxy_pass http://127.0.0.1:XXXX/api;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
# location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
# {
# expires 30d;
# error_log /dev/null;
# access_log /dev/null;
# }
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
# 此处为自动配置的,如果删除了,可以按照下面的地址写
access_log /www/wwwlogs/www.XXXXX.fans.log;
# 此处为自动配置的,如果删除了,可以按照下面的地址写
error_log /www/wwwlogs/www.XXXXX.fans.error.log;
}
注意事项:
1,其中nginx配置中最后一行“include /www/server/panel/vhost/nginx/*.conf;”,配置文件就是项目配置文件,所以在nginx配置中A和B两部分(上面代码中已经标注)任选其一即可,不过我更推荐选择B,因为这样可以不用修改nginx配置,修改nginx配置后容易引来不必要的错误。文章来源:https://www.toymoban.com/news/detail-570906.html
2,如果phpmyadmin本来好好的,突然打不开,或者打开需要登录,那有可能动了nginx中phpmyadmin的配置,即server:888的部分,重要的一点:如果nginx配置中有多个server,那请吧phpmyadmin的配置放最上面,就像我上面那样,要不然phpmyadmin端口号可能会变成其他的,导致错误。文章来源地址https://www.toymoban.com/news/detail-570906.html
到了这里,关于关于宝塔面板中项目配置文件与nginx配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!