mac apache php 项目路径,Mac 配置Apache自定义目录

本文指导如何在Apache服务器上进行配置,包括进入/etc/apache2目录,编辑httpd.conf文件,将DocumentRoot改为/Users/username/Sites,并启用Indexes、MultiViews和php7模块,启动Apache服务,最后通过localhost或172.0.0.1访问本地文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.前往文件夹/etc/apache2

2.打开apache2文件夹下的httpd.conf

3.编辑文件以下文件内容并保存

找到

DocumentRoot "/Library/WebServer/Documents"

#

# Possible values for the Options directive are "None", "All",

# or any combination of:

# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

#

# Note that "MultiViews" must be named *explicitly* --- "Options All"

# doesn't give it to you.

#

# The Options directive is both complicated and important. Please see

# http://httpd.apache.org/docs/2.4/mod/core.html#options

# for more information.

#

Options FollowSymLinks Multiviews

MultiviewsMatch Any

#

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

# AllowOverride FileInfo AuthConfig Limit

#

AllowOverride None

#

# Controls who can get stuff from this server.

#

Require all granted

改成

DocumentRoot "/Users/username/Sites"

Require all granted

Options Indexes MultiViews

AllowOverride All

Order allow,deny

Allow from all

找到 #LoadModule php7_module libexec/apache2/libphp7.so 去掉前面的#

⚠️username是你的用户名,Sites是你的根目录名称,要手动创建。修改这个文件需要输入计算机开机密码。

4.使用命令行sudo apachectl start启动apache

5.打开浏览输入localhost或者172.0.0.1即可访问你的文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值