我遇到了求救信号。 我在新服务器上从 apache 迁移到 nginx,设置了 nginx+php-fpm+mariadb。
现在除了 MVC 结构的错误之外,还有另一个错误 - Chrome 控制台充满红色 - net::ERR_CONNECTION_REFUSED 在连接到 jpg 和 css 文件时。
它可以是什么?它是 Assets Yii 组件中的错误还是在 NGINX 配置中? 这是我的配置。
server {
listen 80;
server_name example.ru;
root /var/www/sites/example.ru;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass php-fpm;
fastcgi_split_path_info ^(.+\.php)(.*)$;
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
.htaccess 几乎是空白
AddDefaultCharset UTF-8
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
最佳答案
我在迁移到新服务器后忘记在我的 NGINX 服务器上启用 SSL,并且搜索的所有脚本服务器都以“https://”开头。
关于php - Nginx + Yii 应用程序 = js,css - net::ERR_CONNECTION_REFUSED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47902715/