Home > Backend Development > PHP7 > body text

How to deploy php7 project in nginx

藏色散人
Release: 2023-02-18 09:24:01
Original
2194 people have browsed it

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.

How to deploy php7 project in 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
Copy after login

1. Install nginx

[root@piehost ~]# yum -y install nginx  && systemctl start nginx && systemctl enable nginx
Copy after login

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
Copy after login

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;
}
Copy after login

5. Restart nginx

[root@piehost ~]# systemctl restart nginx
Copy after login

6. Change permissions in your project directory

Modify the permissions of these two folders: bootstrap storage

[root@piehost mylaravelproject]# chmod 777 -R bootstrap storage
Copy after login

7. Open port 80

[root@piehost mylaravelproject]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template