配置 *.conf 文件
-
添加配置文件目录
-
# 打开nginx.conf配置文件目录 cd /usr/local/nginx/conf # 添加配置目录 vim nginx.conf
user www www; worker_processes auto; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; multi_accept on; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; 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; 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 application/xml+rss; 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; ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off; access_log off; server { listen 80 default_server; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/default; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } # 此处添加配置文件目录 # 本文件在 /usr/local/nginx/conf/nginx.conf # 配置目录在 /usr/local/nginx/conf/vhost/配置文件 # *.conf 使用正则表达式匹配该配置文件的目录 include vhost/*.conf; }
- 记得把默认的serverl里的内容加上#都注释掉,不然网页打开还是在默认页面里
-
修改vhost中的配置文件
- 使用 lnmp1.5一键安装包 添加虚拟机主机会自动生成配置文件
例如:网站域名.conf -> test.baidu.com.conf -
server { listen 80; server_name test.baidu.com; index index.html index.htm index.php default.html default.htm default.php; #根目录设置到Public下 root /home/wwwroot/test.baidu.com/public; #======================================= # 添加内容部分 #定义变量 set $root /home/wwwroot/test.baidu.com/public; location ~ [^/]\.php(/|$) { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; #设置PATH_INFO fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name; #引入fastcgi配置 include fastcgi.conf; } #从URL中去掉index.php入口文件 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } # 添加内容结束 #================================== location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log off; }
-
修改 fastcgi.conf 中的配置文件
-
# 进入 fastcgi.conf 文件目录 cd /usr/local/nginx/conf # 修改 fastcgi.conf 配置文件 vim fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REQUEST_SCHEME $scheme; fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; # 初始化配置文件 # fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; #=========================================== #添加内容 # 开放目录访问权限(因为根目录设置到public下导致框架访问上级目录权限不够) fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/wwwroot/:/tmp/:/proc/";
-
修改 php.ini 中的配置文件
-
# 进入 php.ini 文件目录 cd /usr/local/php/etc # 修改 php.ini 配置文件 vim php.ini # 修改内容 cgi.fix_pathinfo = 1
-
修改完成,重启lnmp1.5
-
lnmp restart
-
解决TP5权限不足问题
-
简单粗暴方法一
-
# 进入 TP5 根目录 cd /home/wwwroot/test.baidu.com # 输入命令 chmod -R 777 runtime
-
安全方法二
-
# 进入 TP5 根目录 cd /home/wwwroot/test.baidu.com # 输入命令 chown -R www runtime
转自:https://blog.csdn.net/wangartorange/article/details/81052353
- 还可以看一下:https://blog.csdn.net/u010474681/article/details/80722173