ThinkPHP5.0,
1. Download and install tp5
Use git to clone the following repository address. The download speed of this address is faster, almost two minutes.
Clone the tp5 application project:
Git clone https://github.com/top-think/think tp5
This command cloned a think web application project from the https server and renamed it tp5
Clone the Framework Package of tp5:
Git clone https://github.com/top-think/framework thinkphp
This command cloned a framework package from the https server and named it thinkphp. If thinkphp is not named, an error will be reported during web access, because the directory of the referenced framework in the tp5 application is thinkphp
2. Configure the nginx server and hosts file
Server {
Root D:/project/tp5 /;
Index. php index.html;
Server_name dev.tp5.com;
# Set $ yii_bootstrap "index.html ";
Set $ yii_bootstrap "index. php ";
Charset UTF-8;
Location /{
Index $ yii_bootstrap;
Try_files $ uri/$ yii_bootstrap? $ Args;
If (! -E $ request_filename ){
Rewrite (. *)/index. php/$1;
}
}
Location ~ ^/(Protected | framework | nbproject | themes/\ w +/views ){
Deny all;
}
Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $ {
Expires 30d;
}
Location ~ . * \. (Js | css )? $ {
Expires 7d;
}
# Avoid processing of callto unexisting static files by yii
Location ~ \. (Js | css | png | jpg | gif | swf | ico | pdf | mov | fla | zip | rar) $ {
Try_files $ uri = 404;
}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ \. Php $ {
Fastcgi_split_path_info ^ (. + \. php) (. *) $;
# Let yii catch the callto unexising PHP files
Set $ fsn/$ yii_bootstrap;
If (-f $ document_root $ fastcgi_script_name ){
Set $ fsn $ fastcgi_script_name;
}
# Fastcgi_next_upstream error timeout invalid_header http_500 http_503 http_404;
# Fastcgi_pass unix:/var/run/php5-fpm.sock;
Fastcgi_pass 127.0.0.1: 9000;
Include fastcgi_params;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fsn;
# PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
Fastcgi_param PATH_INFO $ fastcgi_path_info;
Fastcgi_param PATH_TRANSLATED $ document_root $ fsn;
}
Location ~ /\. Ht {
Deny all;
}
}
This code configures a virtual host in nginx. conf.
127.0.0.1 dev.swzqclient.yingyongdaren.com
127.0.0.1 dev.swzqapi.yingyongdaren.com
127.0.0.1 dev.swzq.yingyongdaren.com
127.0.0.1 dev.bbs.nianyuapp.com
127.0.0.1 dev.tp5.com
In the hosts file, the dev.tp5.com domain name is configured to access the local host.
The two parts are completed:
Dev.tp5.com maps to 127.0.0.1. D:/project/tp5/directory of the computer.
3. Start nginx and php
Start nginx
Nginx-s reload
This code starts the nginx server and reloads the nginx configuration file
4. Access http://dev.tp5.com/public/
: Successful