Mac Apache PHP 基础环境配置

本文详细介绍了如何在终端中配置Apache服务器,包括进入Apache目录、备份及还原配置文件、编辑http.conf文件更改DocumentRoot路径、启动、停止及重启Apache服务器等步骤,并解决了启动时可能出现的错误。


apache 在终端中进入apache所在目录
cd /etc/apache2
sudo 表示用管理员权限
备份apache2配置文件
sudo cp http.conf http.conf.bak

还原apache2配置文件
sudo cp http.conf.bak http.conf

# 编辑http.conf 不能使用粘贴
$ sudo vim http.conf

# 查找 DocumentRoot
/DocumentRoot

#将一下两行中的目录 ,替换成在Finder中新建的目录
#例如在 用户目录下 新建的 Sites
# mkdir ~ Sites
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/Webserver/Documents">

DocumentRoot "/Users/userName/Sites"
<Directory "/Users/userName/Sites">

#进入编辑模式
i

#向下找到

Options FollowSymLinks Multiviews

加一个单词

Options Indexes FollowSymLinks Multiviews

#进入命令模式 esc
# 查找PHP配置项
/php
去掉php前的#

$sudo cp /etc/php.ini.default /etc/php.ini

# 启动apache服务器
$ sudo apachectl -k start
#停止apache服务器
$ sudo apachectl -k stop
#重启apache服务器
$ sudo apachectl -k restart

如果 启动apache的时候提示这个错误: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

回到http.conf 文件 修改下

原始的ServerName 被#号注释着  修改成?这样的  就改成本机地址;

ServerName 127.0.0.1:80



转载于:https://my.oschina.net/soci/blog/633098

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值