nginx deploy thinkphp and laravel

Recently, bloggers deployed a TP5 project they practiced under Centos+Nginx environment. Some problems were encountered in the process, but the probl...

Recently, bloggers deployed a TP5 project they practiced under Centos+Nginx environment. Some problems were encountered in the process, but the problem was solved successfully. So they shared the configuration code with you, so that you can avoid some detours.

First, the configuration code of larave5. Replace test.com with your own domain name and testProject with your own project address. The code is as follows:

server { listen 80; server_name test.com; set $root_path 'testProject'; root $root_path; index index.php index.html index.htm; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index /index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root $root_path; } location ~ /\.ht { deny all; } }

The following is the configuration of Thinkphp project. Replace test.com with your own domain name and testProject with your own project address. The code is as follows:

server { listen 80; server_name test.com; set $root_path 'testProject'; root $root_path; index index.php index.html index.htm; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index /index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root $root_path; } location ~ /\.ht { deny all; } location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } }

Remember to restart Nginx after modification, so that the configuration will take effect. The above is the configuration code of thinkphp and Laravel in the environment of Nginx.

More shares, please pay attention to WeChat public.

2 December 2019, 16:16 | Views: 1667

Add new comment

For adding a comment, please log in
or create account

0 comments