阿里雲部署LNMP注意事項

1、登錄一下阿里賬號,直接購買所需配置的服務器,我這邊方便測試用sql直接放在服務器上。

2、打開鏈接https://help.aliyun.com/document_detail/97251.html,根據步驟來部署。

3、部署自己的php項目這邊需要說下幾個注意事項:

  1.  location / {   
                root  /home/wwwroot;                  
                index index.php index.html index.htm;          
                if (!-e $request_filename) {
                  rewrite /admin.php(.*)$ /admin.php$1 last;
                  rewrite ^(.*)$ /index.php/$1;
                  break;
                }
            }                    

            location /pub {
                alias  /home/www/;                  
                index index.php index.html index.htm; 
            }

            location ~ \.php {                       
                root /home/wwwroot; 
                fastcgi_pass 127.0.0.1:9000;   #Nginx通過本機的9000端口將PHP請求轉發給PHP-FPM進行處理
                fastcgi_index index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include fastcgi_params;   #Nginx調用fastcgi接口處理PHP請求
                
                set $path_info "";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
                }
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info; 

            }         這是我nginx.conf 中的配置,裏面指定文件路徑以及設置phpinfo的路徑     

  2. location /pub {
                alias  /home/www/;                  
                index index.php index.html index.htm; 
            }這部分是指定前端項目的訪問路徑 ,這裏不能用root,要用alias並且路徑是以/結束的

  3.      set $path_info "";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
                }
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info; 指定phpinfo,要不然後面後臺接口訪問的時候會出現404

  4. fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";這段話要加在fastcgi.conf文件中,這是nginx 部署thinkphp 配置,apache的可直接參考thinkphp官網.

  5. 後臺訪問的時候會遇到跨域的問題,此時你要設置鉤子,具體配置可參照thinkphp官網的教程.

以上就是我部署服務器中遇到的所有問題,怕以後會忘記就記錄一下。有所疏漏還望提醒。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章