Apache+php+MySql手动配置

本文详细介绍了如何在Apache服务器上配置PHP,包括加载PHP模块、配置PHP.ini、设置时区和会话参数等。同时,还指导了如何安装MySQL数据库并将其作为服务运行。此外,提供了静态化链接的方法,包括开启mod_rewrite模块、修改AllowOverride选项以及在WordPress环境中实现静态链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

备忘一下



备忘一下:


一. Apacha2.2 修改 httpd.conf, 添加以下配置:

#PHP配置
LoadModule php5_module "D:/PHP5.4/php5apache2_2.dll"
AddHandler application/x-httpd-php .php

# 配置 php.ini 的路径
PHPIniDir "D:/PHP5.4"

#修改一下配置,让apache优先转发php请求
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
ps:把httpd.exe 加入系统服务:
httpd.exe -k install -n apache2.2
删除:sc delete apache2.2
二。php的配置

//关于php 的版本选择:--------------------
Please use the Apache builds provided by Apache Lounge. They also provide VC11 builds of Apache for x86 and x64. We use their binaries to build the Apache SAPIs.

If you are using PHP with Apache 1 or Apache2 from apache.org (not recommended) you need to use the older VC6 versions of PHP compiled with the legacy Visual Studio 6 compiler. Do NOT use VC9+ versions of PHP with the apache.org binaries.

With Apache you have to use the Thread Safe (TS) versions of PHP.
//-----------------------------------

复制 php.ini-production,并重命名为 php.ini
添加D:/PHP5.4 到环境变量的path中。

去掉以下dll的注释:
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_pdo_mysql.dll //drupal需要这个

其它配置:时区:
[Date]
date.timezone = Asia/Shanghai
会话:
[Session]
session.save_path = "D:/PHP5.4/tmp"
动态链接库目录:
extension_dir = "ext"
三.解压zip文件,安装最简单的来。
复制my-small.ini,重命名为 my.ini
添加D:/MySQL/bin的位置到环境变量的path中。
在[mysqld]里面,添加以下几行配置:

basedir="D:/MySQL"
datadir="D:/MySQL/data"
character-set-server=utf8


//安装MySQL为服务(要求cmd以管理员身份运行)
c:\>mysqld --install MySQL --defaults-file="D:/MySQL/my.ini"

//启动服务
c:\> net start MySQL

//更改mysql的用户密码
// root 初始密码为空
c:\> mysql -u root -p

#登录mysql
>use mysql
>update user set password=password("new_pass") where user="userName"; #userName换成你要修改的用户名的密码,比如root
>flush privileges;
>exit;
四、关于链接的静态化:
1)开启apache 的mod_rewrite模块,去掉注释:
LoadModule rewrite_module modules/mod_rewrite.so

2)修改 AllowOverride选项
<Directory "E:/workspace_shawn/CMS">

#
# 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


</Directory>
3)在wordpress里面,选一个静态链接的选项,系统会在wordpress的根目录生成一个.htaccess文件。搞定!

4)因为我本机的目录CMS,并不是wordpress的更目录,所以.htaccess其实访问不到。
只有手动copy内容到 httpd.conf里面啦。呵呵。
<VirtualHost shawn.tianya.cn:1234>
DocumentRoot "E:\workspace_shawn\CMS"
ServerName shawn1234
<IfModule rewrite_module.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

</VirtualHost>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值