我用Symfony框架6.2版构建了一个PHP网站,并在PHP 8.2上运行。通过Github操作,我设法将其部署到Microsoft Azure Web App。
当我访问由Microsoft Azure Web App创建的默认域时,我看到“403 Forbidden,nginx/1.22.1”错误消息。
通过SSH,我可以转到已创建的Azure Web App以检查一些设置。
我的Symfony网站被部署到文件夹/home/site/wwwroot
。
这是默认的/etc/nginx/nginx.conf
:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 10068;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log off;
error_log /dev/stderr;
##
# Gzip Settings
##
gzip on;
# 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/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
我很确定我需要像Symfony文档中解释的那样更改nginx.conf
配置:https://symfony.com/doc/current/setup/web_server_configuration.html#nginx
但是我不知道在哪里可以添加这个额外的配置,因为nginx.conf
文件将被每次部署覆盖。即使我手动更改配置文件,它也不起作用。
有人能给我指个方向吗?
1条答案
按热度按时间c0vxltue1#
您认为过程是正确的,尽管您正在查看错误的配置文件。应该修改的文件是
/etc/nginx/sites-available/default
。对于第二个问题,即设置被覆盖,解决方案是使用命令行指令。
如果你想了解更多,我在https://www.azurephp.dev/2021/09/php-8-on-azure-app-service/上有一篇关于它的完整文章。
祝你好运🍀