1. 程式人生 > >簡單7步搭建nginx+php7環境並部署laravel專案

簡單7步搭建nginx+php7環境並部署laravel專案

0.準備工作

1、主機,我的是centos7.4
2、寫好的laravel專案
3、更新yum倉庫

[[email protected] ~]# yum install https://centos7.iuscommunity.org/ius-release.rpm -y

1.安裝nginx

[[email protected] ~]# yum -y install nginx  && systemctl start nginx && systemctl enable nginx

2.安裝資料庫

3.安裝php7

[[email protected]
~]# yum install -y php70u-fpm && yum install php70u-gd php70u-mysqlnd php70u-pdo php70u-mcrypt php70u-mbstring php70u-json -y && systemctl start php-fpm && systemctl enable php-fpm

4.環境搭建完畢,下面拷貝laravel工程到指定目錄並修改配置文件

假設你的laravel專案叫mylaravelproject,將其拷貝到/root /soft/目錄下

[[email protected]
~]# vim /etc/nginx/conf.d/plscp.conf //修改配置文件 server { listen 80; server_name 你的伺服器ip地址或者域名; root /soft/www/mylaravelproject/public; index index.php index.html; location / { try_files $uri $uri/ /index.php?$query_string; client_max_body_size 1000m; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

5.重啟nginx

[[email protected] ~]# systemctl restart nginx

6.到你的工程目錄下修改許可權

修改這兩個資料夾的許可權:bootstrap storage

[[email protected] mylaravelproject]# chmod 777 -R bootstrap storage

7.開放80埠

[[email protected] PLSCP]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

此時可以通過你的地址訪問你的網站了