OSX High Sierra升级后出现Apache 500错误

时间:2017-11-27 06:35:13

标签: macos apache

我的Mac上有一个开发网站 工作正常。升级到OSX High Sierra后,它停止了工作。为了解决这个问题,我按照以下说明重新安装了Apache:https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions

当我在浏览器中打开我的网站时,我收到500内部服务器错误:The server encountered an internal error or misconfiguration and was unable to complete your request.

这是我的httpd.conf

ServerRoot "/usr/local/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 ssl_module lib/httpd/modules/mod_ssl.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

<IfModule unixd_module>
    #User _www
    #Group _www
    User alan
    Group staff
</IfModule>

ServerAdmin you@example.com
<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/usr/local/var/www"
<Directory "/usr/local/var/www">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/var/log/httpd/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "/usr/local/var/log/httpd/access_log" common
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/usr/local/var/www/cgi-bin/"
</IfModule>

<IfModule cgid_module>
</IfModule>

<Directory "/usr/local/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>
    TypesConfig /usr/local/etc/httpd/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
    Include /usr/local/etc/httpd/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

这是我的httpd-vhosts.conf

<VirtualHost *:80>
  ServerName www.mysite.test
  ServerAlias mysite.test
  DocumentRoot /var/www/mysite.test/dist
  ErrorLog /var/www/mysite.test/error.log

  <Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

错误日志:

[Sun Nov 26 22:08:41.069343 2017] [mpm_prefork:notice] [pid 86] AH00169: caught SIGTERM, shutting down
AH00557: httpd: apr_sockaddr_info_get() failed for Alans-MacBook-Pro.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[Sun Nov 26 22:08:56.872361 2017] [ssl:warn] [pid 86] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Nov 26 22:08:56.900975 2017] [mpm_prefork:notice] [pid 86] AH00163: Apache/2.4.29 (Unix) OpenSSL/1.0.2m configured -- resuming normal operations
[Sun Nov 26 22:08:56.901060 2017] [core:notice] [pid 86] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

你必须在你的机器上找到libphp5.so。

添加

LoadModule php5_module /PATH/TO/libphp5.so

你必须添加

<IfModule mod_php5.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>

到你的

/etc/apache2/httpd.conf

别忘了

apachectl restart