#查看apache信息 #httpd -V #其中HTTPD_ROOT和SERVER_CONFIG_FILE 就可以确定httpd.conf的路径了 #源码安装完后路径为:/etc/httpd/httpd.conf ============================================================ #指明php类型、php.ini的路径 AddType application/x-httpd-php .php AddType application/x-httpd-php .php .phtml .php3 AddType application/x-httpd-php-source .phps PHPIniDir "/etc" ============================================================ #指定模块 #LoadModule php5_module modules/libphp5.so ============================================================ Forbidden You don't have permission to access / on this server. 开始的时候我是用http://localhost/test.php进行的测试,没有发现问题,后来要在内网测试一下就要用IP地址进行那个访问了,如:http://10.10.50.195/test.php,就出现了这个问题。 后来咨询了一下朋友(php高手),说修改一下php的配置文件httpd.conf。 在原有的位置文件中找到配置节 Options FollowSymLinks AllowOverride None Order deny,allow Deny from all Satisfy all 修改成 Options FollowSymLinks AllowOverride None Order deny,allow #Deny from all Allow from all #允许所有访问 Satisfy all 还有 # # 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.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride all # # Controls who can get stuff from this server. # # onlineoffline tag - don't remove Order Deny,Allow Deny from all Allow from 127.0.0.1 修改成 # # 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.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride all # # Controls who can get stuff from this server. # # onlineoffline tag - don't remove Order Deny,Allow # Deny from all # Allow from 127.0.0.1 Allow from all 然后保存,重启服务,在访问就解决了这个问题。 =========================================================== #复制php.ini-production cp php.ini-production /etc/php.ini ============================================================ #修改权限 #Forbidden #You don't have permission to access /index.php on this server. chmod +x /var/www/html/index.php ============================================================ apache在make install时会生成/etc/httpd下的配置文件,如/etc/httpd/httpd.conf php在make install时会备份/etc/httpd/httpd.conf成/etc/httpd/httpd.conf.bak 并修改/etc/httpd/httpd.conf,发现是添加了这一行: LoadModule php5_module modules/libphp5.so LoadModule php7_module modules/libphp7.so 这个文件在安装目录/apache/modules/下