提问人:user15255579 提问时间:9/19/2023 最后编辑:user15255579 更新时间:9/19/2023 访问量:77
Ventura 13.5.2更新破坏了apache和虚拟主机配置?
Ventura 13.5.2 update broke apache & virtual hosts configuration?
问:
几个月前,我完全按照该指南使用自制软件安装和配置Apache和PHP。还有那个安装 MySQL 并配置一些虚拟主机,我需要开发网站(使用 dnsmasq)。在上次 Ventura 更新 (13.5.2) 之前,一切都很正常。现在,访问我的 vhost url 显示“It Works!”,但我无法访问我的本地 vhost 文件。看起来它忽略了 vhost 配置中的 DocumentRoot 设置......此外,“ps aux”命令显示 httpd 仍以 _www 或 root 身份运行,而忽略了我在 /opt/homebrew/etc/httpd/httpd.conf 中设置的设置。
我已经仔细检查了每个设置,但我仍然不明白为什么它显示“它有效”而不是我的 vhost 文件夹中的文件。
你能帮我了解一下出了什么问题吗?
谢谢!
R.
/opt/homebrew/etc/httpd/httpd.conf :
ServerRoot "/opt/homebrew/opt/httpd"
Listen 80
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
LoadModule authn_file_module lib/httpd/modules/mod_authn_file.so
LoadModule authn_core_module lib/httpd/modules/mod_authn_core.so
LoadModule authz_host_module lib/httpd/modules/mod_authz_host.so
LoadModule authz_groupfile_module lib/httpd/modules/mod_authz_groupfile.so
LoadModule authz_user_module lib/httpd/modules/mod_authz_user.so
LoadModule authz_core_module lib/httpd/modules/mod_authz_core.so
LoadModule access_compat_module lib/httpd/modules/mod_access_compat.so
LoadModule auth_basic_module lib/httpd/modules/mod_auth_basic.so
LoadModule reqtimeout_module lib/httpd/modules/mod_reqtimeout.so
LoadModule filter_module lib/httpd/modules/mod_filter.so
LoadModule mime_module lib/httpd/modules/mod_mime.so
LoadModule log_config_module lib/httpd/modules/mod_log_config.so
LoadModule env_module lib/httpd/modules/mod_env.so
LoadModule headers_module lib/httpd/modules/mod_headers.so
LoadModule setenvif_module lib/httpd/modules/mod_setenvif.so
LoadModule version_module lib/httpd/modules/mod_version.so
LoadModule unixd_module lib/httpd/modules/mod_unixd.so
LoadModule status_module lib/httpd/modules/mod_status.so
LoadModule autoindex_module lib/httpd/modules/mod_autoindex.so
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
LoadModule dir_module lib/httpd/modules/mod_dir.so
LoadModule alias_module lib/httpd/modules/mod_alias.so
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule php_module /opt/homebrew/opt/[email protected]/lib/httpd/modules/libphp.so
<IfModule unixd_module>
User myname
Group staff
</IfModule>
ServerAdmin [email protected]
ServerName localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/Users/myname/Documents/Sites"
<Directory "/Users/myname/Documents/Sites">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "/Users/myname/Documents/Sites/error_log"
LogLevel warn
<IfModule log_config_module>
...
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/opt/homebrew/var/www/cgi-bin/"
</IfModule>
<Directory "/opt/homebrew/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
...
</IfModule>
Include /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
Include /opt/homebrew/etc/httpd/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
/opt/homebrew/etc/httpd/extra/httpd-vhosts.conf :
<VirtualHost *:80>
DocumentRoot "/Users/myname/Documents/Sites"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/myname/Documents/Sites/myfolder"
ServerName myfolder.local
ServerAlias www.myfolder.local
ErrorLog "/Users/myname/Documents/Sites/myfolder/error_log"
CustomLog "/Users/myname/Documents/Sites/myfolder/access_log" common
<Directory "/Users/myname/Documents/Sites/myfolder">
Options Indexes FollowSymLinks
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/myname/Documents/Sites/myotherfolder"
ServerName myotherfolder.local
ServerAlias www.myotherfolder.local
ErrorLog "/Users/myname/Documents/Sites/myotherfolder/error_log"
CustomLog "/Users/myname/Documents/Sites/myotherfolder/access_log" common
</VirtualHost>
重新启动计算机后,或成功运行“brew services restart httpd”后,https _www,而不是 myname/staff :
myname@MacBook 2.4.57_1 % ps aux | grep httpd
_www 3188 0,0 0,0 408788960 3808 ?? S 9:01 0:00.01 /usr/sbin/httpd -D FOREGROUND
_www 3179 0,0 0,0 408788960 3872 ?? S 9:00 0:00.02 /usr/sbin/httpd -D FOREGROUND
_www 832 0,0 0,0 408799200 3936 ?? S 6:12 0:00.02 /usr/sbin/httpd -D FOREGROUND
_www 472 0,0 0,0 408788960 3824 ?? S 6:08 0:00.03 /usr/sbin/httpd -D FOREGROUND
root 151 0,0 0,0 408657952 6288 ?? Ss 6:07 0:00.57 /usr/sbin/httpd -D FOREGROUND
myname 6134 0,0 0,0 408626896 1296 s000 S+ 9:58 0:00.00 grep httpd
myfolder.local 正确解析:
myname@MacBook 2.4.57_1 % ping www.myfolder.local
PING myfolder.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.119 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.200 ms
我几乎尝试了所有方法,当我在浏览器中访问 myfolder.local 时,仍然得到“它有效”。我期待看到我的索引 .php 文件的内容...
**编辑。 哇... ** 我发现我必须停止内置的 apache 并使用
sudo apachectl -k stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
然后我重新启动了“brew services restart httpd”,并看到使用“sudo lsof -i:80”,httpd 现在以 myname 的身份运行。这解决了我的问题......
答: 暂无答案
评论