mac安装hhhpd

一、非macos系统自带的httpd安装

采用homebrew安装

brew install httpd

 

 

安装完成后的配置如下:

==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/httpd-2.4.51.arm64_big_sur.bottle.tar.gz

Already downloaded: /Users/huangdan07/Library/Caches/Homebrew/downloads/6bdde48eee3bcc27f1997226ea9626280388f3892ca9f8d03f91ef8f74de2c27--httpd-2.4.51.arm64_big_sur.bottle.tar.gz

==> Reinstalling httpd

==> Pouring httpd-2.4.51.arm64_big_sur.bottle.tar.gz

==> Caveats

DocumentRoot is /opt/homebrew/var/www.

 

The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in

/opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

 

To start httpd:

  sudo brew services stop httpd

  sudo brew services restart httpd

Or, if you don't want/need a background service you can just run:

  /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND

==> Summary

🍺  /opt/homebrew/Cellar/httpd/2.4.51: 1,660 files, 32.0MB

 

httpd -t

httpd -M

 

二、macos系统自带的httpd

/etc/apache2/httpd.conf

DocumentRoot is /Library/WebServer/Documents

 

 

三、httpd链接php配置

在/opt/homebrew/etc/httpd/httpd.conf中加入如下配置,配置完成后,http://localhost:8080/index.php链接,展示hello world(非原始代码)

#加载PHP
LoadModule php7_module /usr/libexec/apache2/libphp7.so
#加载PHP配置文件
PHPIniDir /opt/homebrew/etc/php/8.0/php.ini
#分配给PHP
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
posted @ 2021-10-18 10:20  larybird  阅读(61)  评论(0编辑  收藏  举报