欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

【Linux】实际应用中的LNMP环境配置

最编程 2024-08-09 21:18:28
...
server {

listen 80;
listen 443 ssl;
ssl_certificate /etc/nginx/cert/***.crt; #SSL证书,这个cert目录一般是没有,需要创建的
ssl_certificate_key /etc/nginx/cert/***.key; #SSL证书

server_name *******; #域名
server_tokens off;
root *********; #项目的主目录
index index.php index.html index.htm;
client_max_body_size 300m;
#自动跳转到HTTPS
if ($server_port = 80) {
rewrite ^(.*)$ https://$host$1 permanent;
}

location / {

if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}


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

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 1h;
}

location ~ .*\.(js|css)?$
{
expires 1h;
}

location ~ .+\.php($|/) {

fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_connect_timeout 600;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_buffer_size 64k;
fastcgi_buffers 8 16k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 64k;


fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php?IF_REWRITE=1;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param HTTP_X_FORWARDED_FOR $http_x_forwarded_for;
include fastcgi_params;
}

if ($time_iso8601 ~ "(\d{4})-(\d{2})") {
set $time $1$2;
}
location ~ /\.well-known/apple-app-site-association {
allow all;
}

location ~ /\. {
deny all;
}
}

推荐阅读