nginx配置thinkphp5
生活随笔
收集整理的這篇文章主要介紹了
nginx配置thinkphp5
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
nginx,php,tp框架版本:
nginx版本: [root@z_centos nginx]# /usr/local/nginx/sbin/nginx -h nginx version: nginx/1.13.9tp5版本: thinkphp 5.0.18PHP版本: [root@z_centos nginx]# php -v PHP 7.2.3 (cli) (built: Mar 8 2018 14:43:32) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologieswith Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologiesusr/locol/nginx/conf/vhost/www.xxxx.com.conf 配置文件
主配置文件中使用 include ./vhost/*.conf; 引入即可
https 443端口配置項(xiàng):
server {listen 443 ssl;server_name www.xxxx.com;set $root /usr/local/nginx/webroot/tp5/public; ssl_certificate /etc/letsencrypt/live/www.xxxx.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/www.xxxx.com/privkey.pem;ssl_session_timeout 5m;ssl_prefer_server_ciphers on;access_log logs/www.myzb.pw.access.log main;if ($http_user_agent ~* "qihoobot|Baiduspider|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot") { return 403; } location ~ ..(gif|jpg|jpeg|bmp|png|ico|txt|js|css)${root $root;}location / {root $root;index index.php index.html index.htm;if ( -f $request_filename) {break;}if ( !-e $request_filename) {rewrite ^(.*)$ /index.php?s=/$1 last;}}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}location ~ .+\.php($|/) {set $script $uri;set $path_info "";if ($uri ~ "^(.+\.php)(/.+)") {set $script $1;set $path_info $2;}fastcgi_pass unix:/var/run/www/php-cgi.sock;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;include fastcgi_params;}location ~ /\.(ht|svn|git) {deny all;}} http 80端口配置項(xiàng):server {listen 80;server_name tp510.manzb.top;set $root /usr/local/nginx/www/tp510/public; access_log logs/tp510.manzb.top.access.log main;location ~ ..(gif|jpg|jpeg|bmp|png|ico|txt|js|css)${root $root;}location / {root $root;index index.php index.html index.htm;if ( -f $request_filename) {break;}if ( !-e $request_filename) {rewrite ^(.*)$ /index.php?s=/$1 last;}}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}location ~ .+\.php($|/) {set $script $uri;set $path_info "";if ($uri ~ "^(.+\.php)(/.+)") {set $script $1;set $path_info $2;}fastcgi_pass unix:/var/run/www/php-cgi.sock;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;include fastcgi_params;}location ~ /\.(ht|svn|git) {deny all;} }
其中:fastcgi_pass之所以使用unix:/var/run/www/php-cgi.sock;配置參數(shù),是因?yàn)?#xff1a;http://www.cnblogs.com/manzb/p/8875406.html
?
重啟nginx時(shí)若出現(xiàn)了如下錯(cuò)誤:
nginx: [emerg] unknown log format "proxy_log" in /usr/local/macports/etc/nginx/nginx.conf:147
解決辦法:
打開(kāi)nginx.conf,"main"錯(cuò)誤是因?yàn)閬G失了log_format選項(xiàng),之前把他屏蔽掉了,修改之后問(wèn)題解決。
http {??? include?????? mime.types;
??? default_type? application/octet-stream;
??? log_format? main? '$remote_addr - $remote_user [$time_local] "$request" '
????????????????????? '$status $body_bytes_sent "$http_referer" '
????????????????????? '"$http_user_agent" "$http_x_forwarded_for"';
?
轉(zhuǎn)載于:https://www.cnblogs.com/deverz/p/8876323.html
總結(jié)
以上是生活随笔為你收集整理的nginx配置thinkphp5的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux ping不通百度的解决方法
- 下一篇: 动态规划算法php,php算法学习之动态