mac编程php

切到root帐号

sudo su

查看当前版本
httpd -v

配置文件与网站根目录默认所在位置
/etc/apache2/httpd.conf //配置文件 /Library/WebServer/Documents //网站根目录

服务基本操作
sudo apachectl start // 开启Apache sudo apachectl stop // 关闭Apache sudo apachectl restart // 重启Apache

开启目录浏览
[图片上传失败...(image-8b4761-1535088658283)]
修改/etc/apache2/httpd.conf,把Options FollowSymLinks Multiviews改成Options Indexes FollowSymLinks Multiviews
AllowOverride none Require all granted Allow from all DocumentRoot "/Library/WebServer/Documents" Options Indexes FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted

其它操作:去除配置文件的空行与以#开头的行
cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.back //备份 grep -Ev "^$|[#; ]" /etc/apache2/httpd.conf > /etc/apache2/httpd.conf/去除空行与#号行

总结:
apache出现403 Forbidden主要有两个原因:
1是DocumentRoot目录或以下的文件没有权限,如:把文档目录设成/root/abcd,因为root目前默认没有X权限导致403,又或者具体文件没有644 权限
#查看目录权限 ll /root drwxrwx---.11 root root 4096 Feb 24 02:18 root #通过以下命令修改 chmod 641 /root #查看文件权限 -rw-r-----1 root root52532 Feb 24 02:37 index.html #通过以下命令修改 chmod 644 index.html -rw-r--r--1 root root52532 Feb 24 02:37 index.html

【mac编程php】目录权限修改说明: R=4 ,W=2 ,X=1 (R表示读,W表示写,X表示执行)
rwx 相加就是 7
2是apache配置文件问题,需要修改http.conf文件。
http://域名/indexphp?m=api&a=tool_caiji&key=推券客的key

    推荐阅读