Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
|
1 | |
Настройка локальной папки для запуска сервера17.09.2014, 12:16. Показов 5846. Ответов 30
Метки нет Все метки)
(
Поставил недавно ubuntu и nginx вкупе с MySQL и php. До этого (ооо-О-очень давно и недолго) сидел под виндой на апаче, т.е. каких-то навыков ноль. Хотелось бы иметь возможность порписать путь к локальной (а может и нет) папке, откуда сервер по умолчанию будет грузить страницы. Если проблему изложил не совсем по-русски - уточню, спрашивайте. Заранее спасибо.
0
|
|
17.09.2014, 12:16 | |
Ответы с готовыми решениями:
30
Настройка DNS-сервера Bind9 для локальной WIFI-сети Настройка web сервера и локальной сети Настройка раздачи интернета по локальной сети с сервера через оптику sh скрипт для запуска с другой папки |
1362 / 1074 / 110
Регистрация: 16.03.2012
Сообщений: 4,547
|
|
17.09.2014, 13:59 | 2 |
Сколько сайтов? Планируется ли создание виртуальных хостов? Знаете такие директивы в nginx как
Код
set $root_path /var/www/your_site;
1
|
Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
|
19.09.2014, 00:23 [ТС] | 4 |
пока один, а там - хз
вероятно я еще ничего не знаю выполнение данной строки (логика команды как бы ясна) осуществить независимо от предыдущих вопросов?
0
|
Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
|
25.09.2014, 02:58 [ТС] | 5 |
Amet13, попробовал - не получилось. Полез в nginx.conf. После моих потуг имеет примерно следующее содержание:
Код
user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; ## # nginx-naxsi config ## # Uncomment it if you installed nginx-naxsi ## #include /etc/nginx/naxsi_core.rules; ## # nginx-passenger config ## # Uncomment it if you installed nginx-passenger ## #passenger_root /usr; #passenger_ruby /usr/bin/ruby; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server{ listen 80; root /media/tanatix/example; index index.php index.html index.htm; server_name test.com; location / { root /media/tanatix/example; } } }
0
|
1362 / 1074 / 110
Регистрация: 16.03.2012
Сообщений: 4,547
|
|
25.09.2014, 09:23 | 6 |
Лучше для каждого хоста создавать свой файл конфигурации в /etc/nginx/sites-enabled/ так удобнее.
Насчёт корневого каталога, вроде верно всё, гляньте, что там в логах.
1
|
Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
|
25.09.2014, 10:56 [ТС] | 7 |
Amet13, в той папке присутствует файд default со следующим
содержимым:
Код
# You may add here your # server { # ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} 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; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; 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; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ =404; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ =404; # } #} Т.е. мне его нужно привести к следующему виду:
Код
# You may add here your # server { # ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { listen 80 test.com;#менял тут listen [::]:80 default_server ipv6only=on; root /media/tanatix/example;#менял тут index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name /media/tanatix/example;#менял тут location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} 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; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; 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; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ =404; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ =404; # } #} И содержимое nginx.conf оставить как сейчас? Вот содержимое логов с ошибками Кликните здесь для просмотра всего текста
С доступами пока не выкладываю: не помещается в сообщение.
0
|
1362 / 1074 / 110
Регистрация: 16.03.2012
Сообщений: 4,547
|
|
25.09.2014, 11:51 | 8 |
Привести к изначальному виду.
Файл default можно сменить для вашего каталога. Тогда всё должно работать. Если будете создавать несколько хостов, для них будете свои файлы конфигураций создавать.
1
|
Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
|
25.09.2014, 13:14 [ТС] | 9 |
Создал копированием файл ttx.com, затем изменил его:
Не по теме: Код
# You may add here your #server { #} # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { listen 80; root /media/tanatix/example; index index.php index.html index.htm; server_name ttx.com; #listen 80 default_server; #listen [::]:80 default_server ipv6only=on; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; root /media/tanatix/example; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} 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; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; 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; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ =404; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ =404; # } #} При этом при перезагрузке получаю
0
|
Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
||||||
27.09.2014, 19:34 [ТС] | 10 | |||||
Не знаю, каким образом, но родилось следущее (лишнее поудалял):
nginx.conf в /etc/nginx
Код
user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; } http { 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; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/example; } example в /etc/nginx/sites-enabled
Код
server { listen 127.0.0.1:80; charset utf8; root /var/www/test.com; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?q=$uri; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } и в /var/www/test.com
Как побороть? Не по теме: ЗЫ. ну и может какие-то другие очевидные косяки мимоходом в настройках подскажите...
0
|
Заблокирован
|
|
27.09.2014, 22:04 | 15 |
А это уже не скажешь что. Смотри что в логах. Скорее всего 404, а ошибку(саму страницу) выдать не может т.к. там ссылка на дефолтные nginx с правами на www-data.
Добавлено через 1 минуту Ну и да - если у тебя там php - нету у тебя никакого php, и вести тебя в его прикручивании я не буду, это долго и геморно.
0
|
1362 / 1074 / 110
Регистрация: 16.03.2012
Сообщений: 4,547
|
|
27.09.2014, 22:27 | 18 |
Для начала /var/log/nginx/access.log и error.log
0
|
Модератор
2887 / 1745 / 178
Регистрация: 19.02.2011
Сообщений: 6,434
|
|
27.09.2014, 22:43 [ТС] | 19 |
Из последних записей:
access.log
127.0.0.1 - - [27/Sep/2014:18:18:43 +0400] "GET / HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0"
127.0.0.1 - - [27/Sep/2014:21:53:28 +0400] "GET / HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" 127.0.0.1 - - [27/Sep/2014:21:53:30 +0400] "GET / HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" 127.0.0.1 - - [27/Sep/2014:21:53:31 +0400] "GET / HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" 127.0.0.1 - - [27/Sep/2014:21:53:32 +0400] "GET / HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" 127.0.0.1 - - [27/Sep/2014:21:53:32 +0400] "GET / HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" 127.0.0.1 - - [27/Sep/2014:21:54:14 +0400] "GET / HTTP/1.1" 502 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" 127.0.0.1 - - [27/Sep/2014:22:38:46 +0400] "GET /favicon.ico HTTP/1.1" 404 151 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0" error.log
2014/09/27 18:14:15 [crit] 11587#0: *29 stat() "/home/tanatix/active" failed (13: Permission denied), client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "127.0.0.1"
2014/09/27 18:14:15 [crit] 11587#0: *29 stat() "/home/tanatix/active" failed (13: Permission denied), client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "127.0.0.1" 2014/09/27 18:14:15 [crit] 11587#0: *29 stat() "/home/tanatix/active/index.php" failed (13: Permission denied), client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "127.0.0.1" 2014/09/27 18:15:26 [notice] 11640#0: signal process started 2014/09/27 18:15:51 [notice] 11670#0: signal process started 2014/09/27 21:54:11 [notice] 12100#0: signal process started 2014/09/27 21:54:14 [crit] 12103#0: *40 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "127.0.0.1" 2014/09/27 22:38:05 [emerg] 3434#0: "user" directive is not allowed here in /etc/nginx/sites-enabled/example:3 2014/09/27 22:38:27 [emerg] 3437#0: "user" directive is not allowed here in /etc/nginx/sites-enabled/example:3 2014/09/27 22:38:36 [notice] 3439#0: signal process started
0
|
1362 / 1074 / 110
Регистрация: 16.03.2012
Сообщений: 4,547
|
|
27.09.2014, 23:00 | 20 |
Судя по error.log ругается на директиву "user".
Нужен полный конфиг nginx.conf и example
0
|
27.09.2014, 23:00 | |
Помогаю со студенческими работами здесь
20
Куда сохранить папки для запуска? Расшаренные папки в локальной сети. Запрет копирования файлов/папки? Настройка терминала для запуска по сети Для чего нужен DNS сервера в локальной сети ? Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |