怎样解决手动配置apache+mysql+php8环境下更改完httpd.conf后在cmd中无法启动apache的问题

我们在手动搭建上述环境时,首先要注意版本问题。

话不多说,直接上图:

再经过一番尝试后,作为小白的我终于成功了呜呜呜QAQ

此处我的问题在于在httpd.conf文件添加了三行必须的代码:

(我以为需要两边模式参照一样啥的...)

第一次失败:(我直接从网上扒的,没注意php5啥的直接就用了,然后寄了)

 第二次失败:我使用如下命令在apache的bin目录下尝试后:

httpd.exe -t

 它告诉我在第190行出了问题,然后我就以为是要改成php8,因为我后面就是php8...

 然后我再进行尝试,还是寄了。

第n次尝试,哥们突发奇想,干脆把这个8删掉,然后就改成如下形式:

LoadModule php_module "F:\PHP\php8apache2_4.dll"
PHPIniDir "F:\PHP"
AddType application/x-httpd-php .php .html .htm

然后,然后就成功启动辣!!!

厚礼谢!!!

改完后大家可以打开apache然后在这个网站试试哈~~

localhost由此去

如果各位得到的却是FORBIDDEN

那么我估计你又遇到了我遇到的问题。 (这个也折磨了我好久)

闲话少叙,我们应该做如下的事情:

设置主机(站点)的物理路径

形式:
DocumentRoot “实际物理路径”
重要观念:“站点”就是文件夹

在httpd.conf文件中,我们找到这里:

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
# 前面设置了 Define SRVROOT "E:/amp/Apache"
# 这里是原始站点,要写改为自己的站点位置
DocumentRoot "${SRVROOT}/htdocs" 
<Directory "${SRVROOT}/htdocs">
    # 
    # 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 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 None
 
    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

改成如下:

apache2.2:

    #修改为自己的站点位置
    DocumentRoot "F:\PHP\File" 
    #此时在浏览器中访问"localhost"会发现被禁止访问(Forbidden),需要添加如下的访问权限
    <Directory "F:\PHP\File">
        Options Indexes
        Order Deny,Allow
        Allow from all
        DirectoryIndex my_index.html
    </Directory>

 apache2.4:(我就是2.4...)

    # 自定站点配置
    DocumentRoot "F:\PHP\File"
    <Directory "F:\PHP\File">
        # 允许访问目录下的文件列表
        Options Indexes
        # Require all denied
        Require all granted
        DirectoryIndex index.html index.php
        # 下一行,表示当前目录,允许"分布式"权限配置
        AllowOverride all
    </Directory>

然后重启apache再试试这个链接,看看是不是成功了?!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值