I tried this:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /nginx/www/laravel842/public;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
That worked, but the problem is the url is like:
http://localhost/
and
http://localhost/login/
I wanted:
http://localhost/laravel842/login
I also tried:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 81; #tried various ports 80 also.
server_name laravel.test;
# server_name localhost; # This line works.
root /nginx/www/laravel842/public;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
But nginx doesn't seem to work with another server name, I only got:
Hmm. We’re having trouble finding that site.
We can’t connect to the server at www.laravel.test.
If that address is correct, here are three other things you can try:
Try again later.
Check your network connection.
If you are connected but behind a firewall, check that Firefox has permission to access the Web.
Any idea why laravel.test for the server name will not work? Thanks, I am new to nginx. I did add in the host file:
127.0.0.1 laravel842.test