PHP項目部署 Linux 服務器


一。運行環境

  • Centos7 x64
  • lnmp (Linux , Nginx , Mysql , PHP/Python)

二。安裝依賴和修改配置

安裝Lnmp環境集成包:https://lnmp.org/install.html

wget -c http://soft.vpser.net/lnmp/lnmp1.4.tar.gz && tar zxf lnmp1.4.tar.gz && cd lnmp1.4 && ./install.sh lnmp


添加、刪除虛擬主機及偽靜態管理:https://lnmp.org/faq/lnmp-vhost-add-howto.html

lnmp vhost add 、 lnmp vhost list 、 lnmp vhost del


LNMP默認網站配置文件:/usr/local/nginx/conf/nginx.conf

LNMPA默認網站配置文件:/usr/local/nginx/conf/nginx.conf 和 /usr/local/apache/conf/extra/httpd-vhosts.conf

LAMP默認網站配置文件:/usr/local/apache/conf/extra/httpd-vhosts.conf


相關配置:

TP5 需要設置 防跨目錄設置:https://lnmp.org/faq/lnmp-vhost-add-howto.html


LNMP 1.4上如果不想用防跨目錄或者修改.user.ini的防跨目錄的目錄還需要將 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 在該行行前添加 # 或刪除改行,需要重啟nginx。


1
/usr/local/php/etc/php.ini

找到disable_functions 后面的scandir刪除掉這個函數。

lnmp restart


2
/usr/local/nginx/conf/vhost/域名.conf/


3
include enable-php.conf;

修改為

include enable-php-pathinfo.conf;


4 nginx 配置


server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        #server_name _;
        #server_name 127.0.0.1;
		server_name 服務器ip;
		index index.html index.htm index.php;
		root /data/wwwroot/項目名/;

        include enable-php.conf;

	location / {
          #autoindex  on;
          if (!-e $request_filename){
            rewrite  ^(.*)$  /index.php?s=/$1  last;
          }
        }

	}



5 網站訪問目錄指向public


6 設置相關目錄權限

chmod -R 777 目錄


7 如需要用到Redis 則需要PHP環境安裝擴展支持Redis

https://lnmp.org/faq/addons.html

安裝

進入lnmp解壓后的目錄,執行:./addons.sh install redis


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM