Hi, Guys please I’m stuck on hosting my website in LEMP stack on centos 7 for about a week now :( I’ve been through a lot of tutorials but none of them works when it comes to hosting in a custom root. When I access my IP I get the nginx’s welcome but when I try with my domain maydara.ovh I get a 503 error. Now here is my config:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
default.conf
server {
listen 80;
server_name 178.62.36.194;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#try_files $uri =404;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
virtual.conf
server {
listen 80;
server_name maydara.ovh www.maydara.ovh;
location / {
root /var/www/maydara.ovh/htdocs/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php =404;
}
location ~ \.php$ {
root /var/www/maydara.ovh/htdocs;
fastcgi_pass unix:/var/run/php-fpm/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
error.log
2014/10/13 04:57:37 [error] 9833#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:00:27 [error] 9859#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:05:11 [error] 9893#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:06:23 [error] 9906#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:10:10 [error] 9920#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:10:14 [error] 9920#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:13:41 [error] 9920#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.105.11, server: maydara.ovh, request: "GET /robots.txt HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "maydara.ovh"
2014/10/13 05:24:27 [error] 19164#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:28:15 [error] 681#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:30:22 [error] 1949#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:31:43 [error] 1949#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:33:24 [error] 1949#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:54:46 [error] 674#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 05:54:57 [error] 674#0: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 06:11:00 [error] 1957#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 06:23:20 [warn] 1979#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:23:20 [warn] 1980#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:23:26 [warn] 1985#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:24:19 [error] 1984#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.maydara.ovh"
2014/10/13 06:25:37 [emerg] 1993#0: "server" directive is not allowed here in /etc/nginx/nginx.conf:34
2014/10/13 06:25:48 [emerg] 1997#0: "server" directive is not allowed here in /etc/nginx/nginx.conf:34
2014/10/13 06:26:59 [warn] 1999#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:27:04 [warn] 2002#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:27:04 [warn] 2003#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:27:06 [warn] 2008#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:30:40 [warn] 2017#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:30:40 [warn] 2019#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:30:43 [warn] 2024#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:31:45 [warn] 2033#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:31:45 [warn] 2034#0: conflicting server name "178.62.36.194" on 0.0.0.0:80, ignored
2014/10/13 06:31:56 [crit] 2038#0: *2 connect() to unix:/var/run/php-fpm/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php5-fpm.sock:", host: "www.maydara.ovh"
2014/10/13 06:50:25 [crit] 2066#0: *1 connect() to unix:/var/run/php-fpm/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php5-fpm.sock:", host: "www.maydara.ovh"
2014/10/13 07:02:20 [crit] 2066#0: *4 connect() to unix:/var/run/php-fpm/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 108.162.254.139, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php5-fpm.sock:", host: "maydara.ovh"
2014/10/13 07:06:32 [error] 2066#0: *7 open() "/usr/share/nginx/html/hhhh/hhh/hh.php" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /hhhh/hhh/hh.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:32 [error] 2066#0: *7 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /hhhh/hhh/hh.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:32 [error] 2066#0: *8 open() "/usr/share/nginx/html/phpMyAdmin/scripts/setup.php" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /phpMyAdmin/scripts/setup.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:32 [error] 2066#0: *8 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /phpMyAdmin/scripts/setup.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:32 [error] 2066#0: *9 open() "/usr/share/nginx/html/pma/scripts/setup.php" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /pma/scripts/setup.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:32 [error] 2066#0: *9 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /pma/scripts/setup.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:33 [error] 2066#0: *10 open() "/usr/share/nginx/html/myadmin/scripts/setup.php" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /myadmin/scripts/setup.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:06:33 [error] 2066#0: *10 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 109.236.86.20, server: 178.62.36.194, request: "GET /myadmin/scripts/setup.php HTTP/1.1", host: "178.62.36.194"
2014/10/13 07:23:15 [crit] 2066#0: *11 connect() to unix:/var/run/php-fpm/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php5-fpm.sock:", host: "www.maydara.ovh"
2014/10/13 07:23:20 [crit] 2066#0: *13 connect() to unix:/var/run/php-fpm/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php5-fpm.sock:", host: "www.maydara.ovh"
2014/10/13 07:29:13 [crit] 2066#0: *15 connect() to unix:/var/run/php-fpm/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.101.98.176, server: maydara.ovh, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php5-fpm.sock:", host: "www.maydara.ovh"```
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.
Problem solved, I removed default.conf then I’ve changed my virtual.conf file to look like this: