我的内容目录是:/home/ubuntu/domain.name/laravel_server/code
我的www-web目录是:/var/www/domain.name/html
个
创建从内容到www-web的符号链接sudo ln -s /home/ubuntu/domain.name/laravel_server/code /var/www/domain.name/html
个
现在这个目录/var/www/domain.name/html
显示/home/ubuntu/domain.name/laravel_server/code
的内容
但nginx不阅读内容,给我文件找不到。
server {
index index.php;
server_name domain.name www.domain.name;
root /var/www/domain.name/html/public/;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
autoindex on;
autoindex_exact_size on;
disable_symlinks off;
index index.nginx-debian.html index.html index.php;
try_files $uri $uri/ /index.php$is_args$args;
root /var/www/domain.name/html/public/;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_buffering off;
fastcgi_buffer_size 2M;
fastcgi_buffers 8 2M;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.domain.name) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = domain.name) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name domain.name www.domain.name;
return 404; # managed by Certbot
}
个字符
enter image description here
我的网站应该与符号链接内容。
1条答案
按热度按时间mum43rcc1#
你已经禁用了使用
disable_symlinks off;
的符号链接,你也不应该在location块中使用root指令,除非绝对必要。更新你的Nginx配置,看起来像这样:
字符串
记住在修改配置文件后重新启动或重新加载Nginx。此外,请确保符号链接权限正确。