'deploy laravel on nginx
My nginx and php have installed and run successfully.Enter URL http://127.0.0.1:8080/ in my browser will show 'Welcome to NGINX' page and when i run
php phpinfo.php
on terminal will display all the settings in my php.ini. I tried to run MY_SERVER_NAME/phpinfo.php will keep loading without showing anything. When i try to open my website with the MY_SERVER_NAME i set in nginx.conf, it will keep loading without showing anything too.
My web.conf listens to port 80 and original nginx.conf listens to port 8080
server{
listen 80;
server_name MY_SERVER_NAME;
root /...../public;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php=404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
running sudo nginx -t display syntax is ok and test is successful
Solution 1:[1]
This should work!
server{
listen 80;
listen [::]:80;
server_name SERVER_NAME; # server name of your choice.
root ROOT_DIRECTORY/public; # assumes the index.php is in public folder
index index.php index.html index.htm index-nginx-debian.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php=404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000; # assumes PHP listens on the port 9000
}
}
Solution 2:[2]
i was stuck with something similar, hope this link will be of help to anyone who faces anything similar Install Laravel PHP Framework CentOS 8 with NGINX
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | kevin ochieng |
