jjzjj

php - 在 MacOS Sierra 10.12.1 上安装/卸载 Apache2

coder 2024-04-08 原文

我不知道我的 Mac 附带了 Apache2.4,也没有检查我在哪个操作系统上运行,我按照本指南使用 Homebrew 在我的机器上获取 Apache/MySQL/PHP:https://echo.co/blog/os-x-109-local-development-environment-apache-php-and-mysql-homebrew

这导致我在我的机器上运行了两个版本的 Apache2:2.2 和 2.4。当在终端中询问哪个 apache 正在运行时,答案是 2.4,但是当试图在我的虚拟主机上打开我的程序实例时,我无法访问该页面。 之后发生的事情很困惑,因为我让其他人在努力解决它,他们更改并移动了文件,所以当我拿回电脑时,我什至不知道从哪里开始了解我在哪里,所以我尝试卸载两个 apache 版本并重新安装 2.4。

因为我找不到任何帮助我卸载 apache 的指南并且 brew 命令 remove 不起作用,我开始删除 apache 文件夹并在我的目录中搜索任何包含单词“apache”或“httpd”的东西"(我能找到的任何东西,这意味着我可能还遗漏了一些文件,因为我只是不知道在哪里搜索它们)。

在我这样做之后,我按照其他指南重新安装了 apache 2.4 https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions直到 PHP 安装(我还没有执行)。

再次安装 apache 后,我在 httpd-vhost.conf 中插入了虚拟主机的数据,如下所示:

<VirtualHost *:80>
    ServerAdmin personal@mail.com
    DocumentRoot "/Users/username/apache_vh/myApp"
    ServerName myApp.username.com
    ErrorLog "/usr/local/var/log/apache2/myApp-error_log"
    CustomLog "/usr/local/var/log/apache2/myApp-access_log" common
 <Directory />
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
 </Directory>
</VirtualHost>

然后我使用以下内容修改了/usr/local/etc/apache2/2.4 文件夹中的 httpd.conf 文件(我省略了注释行):

ServerRoot "/usr/local/opt/httpd24"
Listen 80

LoadModule authn_file_module libexec/mod_authn_file.so
[...]
LoadModule authn_core_module libexec/mod_authn_core.so
LoadModule authz_host_module libexec/mod_authz_host.so
LoadModule authz_groupfile_module libexec/mod_authz_groupfile.so
LoadModule authz_user_module libexec/mod_authz_user.so
[...]
LoadModule authz_core_module libexec/mod_authz_core.so
LoadModule access_compat_module libexec/mod_access_compat.so
LoadModule auth_basic_module libexec/mod_auth_basic.so
[...]
LoadModule reqtimeout_module libexec/mod_reqtimeout.so
[...]
LoadModule filter_module libexec/mod_filter.so
[...]
LoadModule mime_module libexec/mod_mime.so
LoadModule log_config_module libexec/mod_log_config.so
[...]
LoadModule env_module libexec/mod_env.so
[...]
LoadModule headers_module libexec/mod_headers.so
[...]
LoadModule setenvif_module libexec/mod_setenvif.so
LoadModule version_module libexec/mod_version.so
[...]
LoadModule unixd_module libexec/mod_unixd.so
[...]
LoadModule status_module libexec/mod_status.so
LoadModule autoindex_module libexec/mod_autoindex.so
[...]
<IfModule mpm_prefork_module>
    #LoadModule cgi_module libexec/mod_cgi.so
</IfModule>
<IfModule !mpm_prefork_module>
    #LoadModule cgid_module libexec/mod_cgid.so
</IfModule>
[...]
LoadModule dir_module libexec/mod_dir.so
[...]
LoadModule alias_module libexec/mod_alias.so
LoadModule rewrite_module libexec/mod_rewrite.so

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

ServerAdmin you@example.com

ServerName localhost

<Directory />
    AllowOverride none
    Require all denied
</Directory>

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

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

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

ErrorLog "/usr/local/var/log/apache2/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/apache2/access_log" common

</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/usr/local/var/apache2/cgi-bin/"

</IfModule>

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

<IfModule mime_module>
    TypesConfig /usr/local/etc/apache2/2.4/mime.types

    #AddType application/x-gzip .tgz
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    #AddHandler cgi-script .cgi
    #AddHandler type-map var
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

# Virtual hosts
Include /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf

[...]

<IfModule proxy_html_module>
Include /usr/local/etc/apache2/2.4/extra/proxy-html.conf
</IfModule>

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

后来我在/etc 文件夹中的主机文件中添加了以下内容(这与/usr/local/etc 不同,这个位于根目录中,在/usr 上一级):

127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

127.0.0.1  myApp.username.com

我希望看到“它有效!”在 localhost:8080 上,myApp 在 localhost:80 上。 我确实看到“它有效!”在 localhost:8080 上,但如果我更新页面,我会得到“无法访问此站点/localhost 拒绝连接。”。我已经启动、停止、重新启动 apache,但我一直都有同样的行为。 在 localhost:80 上,我得到了 myApp,但我无法运行它,PHP 没有被解析,我只看到文件夹的树结构。

我运行了 apachectl configtest 并得到 Syntax OK。我运行了 php -v 并获得了 PHP 5.4.45 (cli)(构建时间:2016 年 11 月 23 日 11:12:05)所以一切正常。

检查上面粘贴的 httpd.conf 文件,我发现缺少 php 模块,所以我添加了 LoadModule php5_module libexec/libphp5.so

我仍然遇到同样的问题。

我真正不明白的是所有文件夹的结构,因为我正在尝试遵循其他指南,但它们似乎指向一个 apache2 文件夹,我必须删除它,而我不应该尝试卸载旧版本,显然它在重新安装期间没有重新创建 (/etc/apache2/users)。我的 etc 文件夹中没有根级别的 apache2 文件夹,所以我假设我必须在/usr/local 下的/etc/apache2 中搜索/users,但在该文件夹中我只有目录 2.4。

我对所有这些目录和文件的组织感到非常困惑,我似乎无法理解它们是否被试图帮助我的人移动过,如果我不小心删除了/etc/apache2/users,同时卸载那些以前的版本,或者如果我基本上搞砸了太多不同的指南。

所以我的问题是:

我能否以某种方式解决此问题,因为它会在本地主机的 80 端口上显示 myApp 正确解析 PHP?

如果没有,我怎样才能以干净的方式卸载 apache,确保我不会删除不应该触及的重要文件,同时删除所有会与新安装的版本?

最佳答案

经过大量研究和合作,让 Apache 再次工作的唯一方法是为我的操作系统恢复出厂设置并恢复到默认组织。 现在我的文件夹看起来很干净,apache 正在端口 80 上运行,而不是 8080。我现在将继续为 myApp 创建一个虚拟主机。

关于php - 在 MacOS Sierra 10.12.1 上安装/卸载 Apache2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40914827/

有关php - 在 MacOS Sierra 10.12.1 上安装/卸载 Apache2的更多相关文章

  1. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  2. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  3. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  4. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  5. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  6. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  7. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  8. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  9. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  10. ruby - 通过 RVM 安装 Ruby 1.9.2 永远行不通! - 2

    当我执行>rvminstall1.9.2时一切顺利。然后我做>rvmuse1.9.2也很顺利。但是当涉及到ruby​​-v时..sam@sjones:~$rvminstall1.9.2/home/sam/.rvm/rubies/ruby-1.9.2-p136,thismaytakeawhiledependingonyourcpu(s)...ruby-1.9.2-p136-#fetchingruby-1.9.2-p136-#downloadingruby-1.9.2-p136,thismaytakeawhiledependingonyourconnection...%Total%Rece

随机推荐