Yes. After I complete a Laravel project, I plan to transfer it to Nginx. The previous figure is convenient. Therefore, in the development environment, php-Slocalhost: 1234 is used to start the HTTP server, it is not developed in Nginx, and the server is Ubuntu14.10. Repeat the entire project... Yes. After I finish a Laravel project, I plan to transfer it to Nginx. The previous figure is convenient, so in the development environment
php -S localhost:1234
The HTTP server is not developed in Nginx. The server is Ubuntu 14.10.
Copy the entire project/usr/share/nginx/html
, Modifyapp/storage
Permission:777
And then access/
Yes, but/
All other routes returned404
For example/home
Return404 NOT FOUND
But there is no such problem during development. The database is okay, because the development is on the same machine.
The following is my Nginx configuration file:
config
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php index.html index.htm; server_name localhost; location / { try_files $uri $uri/ /index.php; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
I saw the same problem in stackoverflow, so I tried to modify my Nginx configuration file and add it:
config
try_files $uri $uri/ @rewrite;location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1;}
Or404
.
Later, I created a Laravel project under the Nginx root directory and modifiedapp/storage
Access to the root route after permission is normal, and access to other custom routes is the same404
For example:
app/route.php
php
Route::get('home', function(){ return View::make('hello');});
The level of food is really helpless. Thank you very much.
Reply content:
Yes. After I complete a Laravel project, I plan to transfer it to Nginx. The previous figure is convenient, so in the development environmentphp -S localhost:1234
The HTTP server is not developed in Nginx. The server is Ubuntu 14.10.
Copy the entire project/usr/share/nginx/html
, Modifyapp/storage
Permission:777
And then access/
Yes, but/
All other routes returned404
For example/home
Return404 NOT FOUND
But there is no such problem during development. The database is okay, because the development is on the same machine.
The following is my Nginx configuration file:
config
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php index.html index.htm; server_name localhost; location / { try_files $uri $uri/ /index.php; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
I saw the same problem in stackoverflow, so I tried to modify my Nginx configuration file and add it:
config
try_files $uri $uri/ @rewrite;location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1;}
Or404
.
Later, I created a Laravel project under the Nginx root directory and modifiedapp/storage
Access to the root route after permission is normal, and access to other custom routes is the same404
For example:
app/route.php
php
Route::get('home', function(){ return View::make('hello');});
The level of food is really helpless. Thank you very much.
php -S
One fatal problem is that the 'Home' in the route must be written as '/Home' to work.
See http://lvwenhan.com/php/406.html
However, this problem seems to be a problem of targeting the portal file, that is, you did not send all non-static requests to the portal file.index.php
. Don't forget to point the root directorylaravel/public
.
Laravel does not know what it is, but it does not seem like WordPress directly parses the URI, but uses PATH_INFO to decide what to display.
Can you try to write the request rewrite to the PHP entry file? Like this:
location / { rewrite ^/(/.*)?$ /index.php$1 last;}location = / { index index.php;}location ~ (.+\.php\d?)($|/) { fastcgi_pass unix:/run/php-fpm/php-fpm.sock; fastcgi_index index.php; set $script $request_filename; if ($request_filename ~ ^(.+\.php\d?)(/.*)$){ set $script $1; set $pathinfo $2; } fastcgi_param PATH_INFO $pathinfo if_not_empty; fastcgi_param SCRIPT_FILENAME $script; include fastcgi_params;}
location / { try_files $uri $uri/ /index.php?$query_string;}
For details, see the official Laravel documentation:
Http://laravel.com/docs/5.0/installation#pretty-urls
Location/{try_files $ uri // index. php;} Add a root file and try location/{root/var/www/try_files $ uri // index. php ;}
I used iis8 Win8 to encounter this 404 problem. After installing the Url Rewrite component for iis to import the htacss file, it will be fine.
Try_files $ uri = 404;
Comment out this line?
Http://www.yimiju.com/articles/593.html