Mac 自带Apache环境
环境:MacOS Big Sur
启动Apache服务,sudo apachectl start
浏览器打开 http://localhost/ 显示 It Works!
Apache默认根目录在:/Library/WebServer/Documents/ 中
备份httpd.conf
cd /etc/apache2
sudo cp httpd.conf httpd.conf.bak
查看apache 的httpd.conf 如何配置
sudo vim httpd.conf
界面如下:
搜索 /DocumentRoot,更改目录地址
之后搜索/Options,在之后找到Options FollowSymLinks:修改为Options Indexes FollowSymLinks,在两个单词间添加一个Indexes单词。
再搜索/php,把这行注释取消
搜索/ServerName, 替换为localhost:80
切换到/etc目录,拷贝php.ini 文件
sudo cp php.ini.default php.ini
保存推出:wq!,重新启动服务,sudo apachectl -k restart
打开http://localhost:80,服务开启。