Доброго времени . Помогите разобраться. В другой версии Nginx я настраивал хосты так ,-создавал конфиги в /etc/nginx/sites-available затем активировал с помощью - sudo ln -s /etc/nginx/sites-available/test.com /etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ а дефолтный конфиг удалял ,добавлял ip в hosts ,затем проверял и перезагружал сервер,и работали два хоста. Тут я чёт не пойму, не много всё по другому , папок sites-available и sites-enabled-нет.Пробовал так- дефолтный конфиг лежит в папке conf.d , есть пустая папка modules в неё добавил свои файлы_conf. создал две символьные ссылки к папке к /etc/nginx/conf.d в hosts добавил 127.0.0.1 - site_name. По началу одна и таже страница отзывалась по двум адресам. а потом вообще nginx перестал работать , Сейчас починил, заменил дефолтный конфиг на свой , чтобы рнр работал ,но мне надо два хоста ,кто знает как настроить это дело... подскажите .
две папки это просто две папки в одной nginx ищет конфиги другая для него не существует в какой папке нгинкс ищет конфиги можно вычитать в его конфиге, которой там же валяется и называется типа nginx.cfg так что просто загляни в него
/etc/nginx/conf.d /etc/nginx/modules /etc/nginx/fastcgi_params /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/mime.types /etc/nginx/nginx.conf /etc/nginx/scgi_params /etc/nginx/uwsgi_params /etc/nginx/win-utf Вот всё что есть.
Если nginx.conf ,-то он инклюдит с с папки conf.d. Код (Text): user www-data; worker_processes auto; #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; } если в эту папку положить ещё один конфиг. то одна и таже страница отзывается на оба адреса.
положи в неё только тот конфиг, который тебе нуже или только те конфиги, которые нужны. если у тебя проблема с конфигом - нужно настраивать конфиг, а не перекладывать файлы. покажи конфиги
/etc/nginx/conf.d/default.conf server { charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name view.com; root /var/www/view.com; index index.php index.html index.htm index.nginx-debian.html; access_log /var/www/view.com/log/access.log; error_log /var/www/view.com/log/error.log; #phpmyadmin location /phpmyadmin { root /usr/share/; index index.php; try_files $uri $uri/ =404; location ~ ^/phpmyadmin/(doc|sql|setup)/ { deny all; } location ~ /phpmyadmin/(.+\.php)$ { fastcgi_pass unix:/run/php/php7.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #include snippets/fastcgi-php.conf; include fastcgi_params; } } location / { # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php$is_args$args; } # uncomment to avoid processing of calls to non-existing static files by Yii #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { # try_files $uri =404; #} #error_page 404 /404.html; # deny accessing php files for the /assets directory location ~ ^/assets/.*\.php$ { deny all; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; try_files $uri =404; } location ~* /\. { deny all; } } /etc/nginx/conf.d/example.com server { charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name example.com; root /var/www/example.com; index index.php index.html index.htm index.nginx-debian.html; access_log /var/www/example.com/log/access.log; error_log /var/www/example.com/log/error.log; #phpmyadmin location /phpmyadmin { root /usr/share/; index index.php; try_files $uri $uri/ =404; location ~ ^/phpmyadmin/(doc|sql|setup)/ { deny all; } location ~ /phpmyadmin/(.+\.php)$ { fastcgi_pass unix:/run/php/php7.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #include snippets/fastcgi-php.conf; include fastcgi_params; } } location / { # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php$is_args$args; } # uncomment to avoid processing of calls to non-existing static files by Yii #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { # try_files $uri =404; #} #error_page 404 /404.html; # deny accessing php files for the /assets directory location ~ ^/assets/.*\.php$ { deny all; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; try_files $uri =404; } location ~* /\. { deny all; } } --- Добавлено --- ceйчас раскоментировал вторую строчку в hosts ,сервер стал выдавать ошибку. 127.0.0.1 view.com 127.0.0.1 example.com 127.0.1.1 user.user user # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters --------------------------- # systemctl status nginx.service ● nginx.service - nginx - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: failed (Result: exit-code) since Чт 2018-05-17 01:34:50 MSK; 12s ago Docs: http://nginx.org/en/docs/ Process: 29262 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS) Process: 29382 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE) Main PID: 5858 (code=exited, status=0/SUCCESS) май 17 01:34:50 roswel systemd[1]: nginx.service: control process exited...=1 май 17 01:34:50 roswel systemd[1]: Failed to start nginx - high performa...r. май 17 01:34:50 roswel systemd[1]: Unit nginx.service entered failed state. май 17 01:34:50 roswel nginx[29382]: nginx: [emerg] open() "/var/www/view...) Hint: Some lines were ellipsized, use -l to show in full.
# journalctl -xn -- Logs begin at Вт 2018-05-15 15:12:48 MSK, end at Чт 2018-05-17 02:11:25 MSK. май 17 02:09:02 roswel CRON[2458]: pam_unix(cron:session): session closed for us май 17 02:10:12 roswel su[2402]: pam_unix(su:session): session closed for user r май 17 02:10:21 roswel systemd[1]: Starting nginx - high performance web server. -- Subject: Начинается запуск юнита nginx.service -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Начат процесс запуска юнита nginx.service. май 17 02:10:21 roswel nginx[2554]: nginx: [emerg] open() "/var/www/view.com/log май 17 02:10:21 roswel systemd[1]: nginx.service: control process exited, code=e май 17 02:10:21 roswel systemd[1]: Failed to start nginx - high performance web -- Subject: Ошибка юнита nginx.service -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Произошел сбой юнита nginx.service. -- -- Результат: failed. май 17 02:10:21 roswel systemd[1]: Unit nginx.service entered failed state. май 17 02:11:24 roswel su[2568]: Successful su for root by roswel май 17 02:11:24 roswel su[2568]: + /dev/pts/0 roswel:root май 17 02:11:25 roswel su[2568]: pam_unix(su:session): session opened for user r lines 1-23 --- Добавлено --- И вот ещё что странно,-как только произошёл этот сбой я через сунаптик увидел что у меня поставился apache2, у меня его точно не было только что удалил..но ошибка по прежнему ,как я понимаю и за высокой производительности.
нет не в логах она была при перезагрузки появилась приблизительно так надпись,я я запустил в терминал и прислал вывод.. sudo service nginx restart Job for nginx.service failed. See "systemctl status nginx.service" and "journalctl -xe" --- Добавлено --- я уже починил. --- Добавлено --- в какой версии nginx есть эти папки/sites-available и sites-enabled?
ты сам можешь устроить себе эту версию: создаешь папки. в nginx.conf добавляешь include-ы со звездочками: Код (Text): http { . . . бла бла бла тыц тыц тыц . . . ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }