Не работает nginx на windows

12
G2
На сайте с 16.02.2013
Offline
35
13774

Вчера начал знакомится с ОС Windows.

Нужно поставить nginx. Скачал, запустил, поставил апач на другой порт, а nginx пишет ошибку 404.

На главной странице пишет: Welcome to nginx!

А если, к примеру, спустится в 127.0.0.1/forum.php пишет ошибку 404.

Конфиг:


user nginx;
worker_processes 1;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include 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 logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 15;

gzip on;

upstream backend {
server 127.0.0.1:88
}

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root c:/nginx-1.5.5/html;
index index.html index.htm index.php;
proxy_pass http://79.171.120.141:88;
proxy_redirect http://79.171.120.141:88 /;


proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}


#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 html;
}



# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$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;
}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}
Оптимизайка
На сайте с 11.03.2012
Offline
396
#1

А php который FastCGI у вас запущен-то локально, на 9000-порту, нет?

⭐ BotGuard (https://botguard.net) ⭐ — защита вашего сайта от вредоносных ботов, воровства контента, клонирования, спама и хакерских атак!
G2
На сайте с 16.02.2013
Offline
35
#2
Оптимизайка:
А php который FastCGI у вас запущен-то локально, на 9000-порту, нет?

я эту часть конфига взял и статьи, как сделать nginx под windows.

Но и перед этим не работало.

Как мне найти порт, который слушает php?

Оптимизайка
На сайте с 11.03.2012
Offline
396
#3

http://ru.wikipedia.org/wiki/Netstat

Или просто посмотреть, что вы задали в качестве параметра -b при запуске php-cgi.exe

G2
На сайте с 16.02.2013
Offline
35
#4
Оптимизайка:
http://ru.wikipedia.org/wiki/Netstat

Или просто посмотреть, что вы задали в качестве параметра -b при запуске php-cgi.exe

не в нем дело. Есть еще варианты?

AU
На сайте с 03.09.2009
Offline
88
#5

Логи какие то включены? Давайте начнем с простого - посмотрим что же в логах. Далее будем действовать согласно сообщениям из лог файлов...

Unix в вопросах и ответах https://unixhow.com (https://unixhow.com)
G2
На сайте с 16.02.2013
Offline
35
#6
adm.unix:
Логи какие то включены? Давайте начнем с простого - посмотрим что же в логах. Далее будем действовать согласно сообщениям из лог файлов...

Вот, что в логах nginx'a:

2
013/09/21 18:27:11 [error] 3656#3152: *1140 CreateFile() "C:\nginx-1.5.5/html/forum.php" failed (2: Не удается найти указанный файл), client: 79.171.120.141, server: localhost, request: "GET /forum.php HTTP/1.1", host: "79.171.120.141"

Как я понял, nginx читает файлы в папке html, а мой проект находится на: E:/www/

Переношу файлы в папку html, все равно. Что менять и где?))

MO
На сайте с 25.04.2010
Offline
40
#7

в настройке нгинкса

root c:/nginx-1.5.5/html

поменять на

root E:/www/

G2
На сайте с 16.02.2013
Offline
35
#8
miliORATOR:
в настройке нгинкса
root c:/nginx-1.5.5/html
поменять на
root E:/www/

теперь на любой странице пишет Welcome to nginx!

Оптимизайка
На сайте с 11.03.2012
Offline
396
#9

потому что он идёт на прокси который вы указали

что это за адрес? уберите, если php-cgi.exe работает локально

G2
На сайте с 16.02.2013
Offline
35
#10
Оптимизайка:
потому что он идёт на прокси который вы указали


что это за адрес? уберите, если php-cgi.exe работает локально

все равно. Даже если уберу location php, все равно...

В логах:

2013/09/21 22:05:46 [error] 3656#3152: *1186 CreateFile() "C:\nginx-1.5.5/html/favicon.ico" failed (2: Не удается найти указанный файл), client: 79.171.120.141, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "79.171.120.141"

Конфиг:


user nginx;
worker_processes 1;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include 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 logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 15;

gzip on;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root E:\VertrigoServ\www\;
index index.php;
proxy_pass http://79.171.120.141:88;
proxy_redirect http://79.171.120.141:88 /;


proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}






# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root E:\VertrigoServ\www;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}
12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий