Question
404 On CentOS8 NGINX
I have setup a latest centos 8 on the server with nginx
and i am having a multiple projects will be running at server
For example :
var/www/html/project1
var/www/html/project2
var/www/html/project3
I have configured my NGINX.conf file as below
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format scripts '$document_root$fastcgi_script_name > $request';
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/scripts.log scripts;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
index index.php index.html index.htm;
location / {
try_files $uri /index.html index.php;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
and server is running on the ipaddress so in server name i have just put _ as server name which will consider it localhost or ip.
But when i am running the projects
I am getting 404 Error and when i configured the script log. i found it going wrong as below
/var/log/nginx/scripts.log
/var/www/html/project1/public/404.html > GET /project1/ HTTP/1.1
/var/www/html/project2/public/404.html > GET /project2/ HTTP/1.1
Can please guide me where i am going wrong on NGINX configuration ?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×