Mac下php环境配置
Mac自带apache目录配置
如果我们希望修改 httpd.conf 的主目录配置,而不使用apache默认的目录 /Library/WebServer/Documents,默认的目前对于创建修改有权限限制使用也不方便。
1.前往文件夹/etc/apache2 2.打开apache2文件夹下的httpd.conf 3.编辑文件以下文件内容并保存
找到 DocumentRoot "/Library/WebServer/Documents" <Directory "/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 </Directory> 改成 DocumentRoot "/Users/username/Sites" <Directory "/Users/username/Sites"> Require all granted Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
找到 #LoadModule php7_module libexec/apache2/libphp7.so 去掉前面的#
username是你的用户名,Sites是你的根目录名称,要手动创建。修改这个文件需要输入计算机开机密码。
apache常用操作
sudo apachectl start // 开启Apache
sudo apachectl stop // 关闭Apache
sudo apachectl restart // 重启Apache
文章来源: https://blog.csdn.net/leiyu231/article/details/86615073