【问题标题】:Localhost on mac doesn't work / Server can't connect / 404 Not found / 403 Forbiddenmac 上的 localhost 不工作 / 服务器无法连接 / 404 未找到 / 403 禁止
【发布时间】:2018-03-05 00:57:20
【问题描述】:

Localhost 说 - 它可以工作,但是这些 localhost/phpmyadmin 和 localhost/~username:

Safari 无法连接服务器

我不使用 MAMP。我另外安装了 MySQL,我下载了 Phpmyadmin 并将这个文件夹放到了 Sites 中。

我的 httpd-vhosts.confg 有

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    DocumentRoot "/Users/bereshka/Sites/parustrans"
    ServerName parustrans.local
</VirtualHost>

我的主人有

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1 parustrans.local
my users/bereshka.conf has

<Directory "/Users/bereshka/Sites/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

我的 httpd.confg 有

【问题讨论】:

  • 我的 httpd-vhosts.confg 有
  • 你的问题不是很清楚,目前的状态很可能会被搁置。一般来说,如果http://localhost 有效,那么其他两个地址(仍在http://localhost/)应该做一些事情。 “不起作用”是什么意思 - 您是否收到 404 错误?
  • 请阅读有关如何使用本网站的帮助部分。这不是一个论坛,您不会在 answers 上发布更多信息。您创建一个问题并包含所有信息。
  • 好的,抱歉。我编辑了那个
  • @halfer 我想我搞砸了 apache 或/和主机。这两个链接 localhost/phpmyadmin 和 localhost/~bereshka/ 显示此错误 Safari Can't connect with Server

标签: mysql macos apache localhost


【解决方案1】:

看起来我自己找到了解决方案。想与所有面临相同问题的人分享。我做的步骤:

  1. 我将 httpd.confg、httpd-vhosts.confg、hosts、username.confg 中的代码替换为相同文件中的代码,但其他 mac 中的代码从未与 apache 一起使用过。因为在过去的几天里,我编辑了很多次,我已经失去了修复它的希望))它让我从零开始。这一步解决了 "Safari Can't connect with Server" 的问题,但是当我通过 localhost/~username 我得到 404 Not Found 时出现了其他错误

  2. 我在 httpd.confg 中取消了这些行的注释

    LoadModule authz_core_module libexec/apache2/mod_authz_core.so LoadModule authz_host_module libexec/apache2/mod_authz_host.so LoadModule userdir_module libexec/apache2/mod_userdir.so LoadModule include_module libexec/apache2/mod_include.so LoadModule rewrite_module libexec/apache2/mod_rewrite.so LoadModule php5_module libexec/apache2/libphp5.so

查看article 了解所有步骤的详细说明

  1. 但此操作(在我的情况下)再次返回此错误 - “服务器无法连接..”。我在上面提到的 cmets 文章中发现,如果评论这一行可能会解决 - LoadModule php5_module libexec/apache2/libphp5.so 我做到了(我在 mac Sierra 10.12.6 上)

    李>
  2. 这有帮助 )) 但是当我检查 localhost/~username 时,我得到一个新的错误 403 Forbidden by link localhost/~username。但是当我只输入 localhost - 它可以工作。

  3. 这显然是权限和用户的问题。因此,我检查了文件夹 apache2/users 中的两个文件 username.conf 和 bereshka.conf 并设置了此代码(对于 Apache 2.4)而不是所有的代码(相应地 /Users/bereshka/Sites/)

    允许覆盖所有 选项索引 MultiViews FollowSymLinks 要求所有授予

这个不行

<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

适用于 apache 2.2

  1. 现在我可以看到站点中的文件夹列表,下一个任务是安装 Joomla,但这是另一回事 :)

【讨论】:

    猜你喜欢
    • 2020-02-03
    • 2020-02-04
    • 1970-01-01
    • 2013-03-04
    • 2021-02-17
    • 2020-05-18
    • 2021-12-18
    • 2010-09-12
    • 2012-11-30
    相关资源
    最近更新 更多