绿色版Apache + PHP的环境搭建

Apache

1. httpd.exe -k install


D:\DevelopPlatform\Apache24X86\bin>httpd.exe -k install
Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd.exe: Syntax error on line 37 of D:/DevelopPlatform/Apache24X86/conf/httpd.
conf: ServerRoot must be a valid directory
修正错误:
进入httpd.conf, 设置ServerRoot:(apache安装目录)
示例:ServerRoot "D:/DevelopPlatform/Apache24X86"

1.1. httpd.exe -k uninstall

Removing the 'Apache2.4' service
The 'Apache2.4' service has been removed successfully.

2. httpd.exe -k install

Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
AH00526: Syntax error on line 244 of D:/DevelopPlatform/Apache24X86/conf/httpd.c
onf:
DocumentRoot must be a directory
修正错误:
进入httpd.conf, DocumentRoot:(apache htdocs目录)
示例:DocumentRoot "D:\DevelopPlatform\Apache24X86\htdocs"

2.1. httpd.exe -k uninstall

Removing the 'Apache2.4' service
The 'Apache2.4' service has been removed successfully.

3. httpd.exe -k install

Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.

4.

至此, apache已经安装完毕,
然后配置一下apache
进入httpd.conf
找到
Listen 80改为8080(将监听端口改为8080,防止80端口被占用出错)
开启ServerName
改为ServerName localhost:8080
重新启动下apache, 进入浏览器输入: localhost:8080/index.html 进行访问
这时有可能发生错误, 网页会输出如下内容:
You don't have permission to access /index.html on this server.

我的解决办法是进入httpd.conf
在DocumentRoot "D:\DevelopPlatform\Apache24X86\htdocs"下一行的
找到<Directory "">并将其改为:<Directory "D:\DevelopPlatform\Apache24X86\htdocs">

这时重新启动服务器, 再次输入: localhost:8080/index.html 进行访问, 不出意外的话, 网页会输出如下内容:
It works!

到这里apache正式完成安装!

5. 添加PHP支持

首先还是进入httpd.conf
1)添加如下模块, 格式为:
LoadModule php5_module (php5apache2_4.dll的完整路径)
PHPIniDir (php安装目录)
示例如下:
LoadModule php5_module D:/DevelopPlatform/php/php5.6.5X86/php5apache2_4.dll
PHPIniDir D:/DevelopPlatform/php/php5.6.5X86
2)添加PHP支持
AddType application/x-httpd-php .php
apache配置完毕

php配置

进入php安装目录:
找到php.ini-developer或者php.ini-production
备份, 然后将去掉后面的-xxxx-->php.ini
然后打开php.ini
找到;extension_dir 修改为extension_dir="php下的ext目录路径"
示例: extension_dir = "D:/DevelopPlatform/php/php5.6.5X86/ext"
如果还要使用My SQL,则添加如下语句

extension=php_mysql.dll

重新启动apache服务器!


至此实现了apache + PHP的环境搭建;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值