lnmp安裝包配置tp5專案所需要的準備
阿新 • • 發佈:2018-12-27
配置 *.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
- 記得把預設的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