How to deploy php7 project with nginx: 1. Install nginx and php7 through install; 2. Copy the laravel project to the specified directory and modify the configuration document; 3. Restart nginx.
The operating environment of this article: centos7.4 system, PHP7.0 version, Dell G3 computer.
How to deploy php7 project on nginx?
Simple 7 steps to build the nginx php7 environment and deploy the laravel project
Build the nginx php7 environment and deploy the laravel project
0. Preparation work
1. Host, mine is centos7.4
2. Written laravel project
3. Update yum warehouse
[root@piehost ~]# yum install https://centos7.iuscommunity.org/ius-release.rpm -y
1. Install nginx
[root@piehost ~]# yum -y install nginx && systemctl start nginx && systemctl enable nginx
2. Install database
3. Install php7
[root@piehost ~]# 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. After the environment is set up, copy the laravel project to the specified directory and modify the configuration document
Assume your laravel The project is called mylaravelproject, copy it to the /root /soft/www directory
[root@piehost ~]# vim /etc/nginx/conf.d/mylaravelproject.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. Restart nginx
[root@piehost ~]# systemctl restart nginx
6. Change permissions in your project directory
Modify the permissions of these two folders: bootstrap storage
[root@piehost mylaravelproject]# chmod 777 -R bootstrap storage
7. Open port 80
[root@piehost mylaravelproject]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
You can now access your website through your address
Recommended learning : "PHP Video Tutorial"
The above is the detailed content of How to deploy php7 project in nginx. For more information, please follow other related articles on the PHP Chinese website!