启用Apache Mac上自带的有Apache和PHP,所以直接启用就可以了,先切换到root用户,在执行命令比较方便 sudo su - 启用Apache命令 apachectl start 可以在浏览器上验证,打开http://localhost 使PHP可以用于Apache 备份Apache的配置文件 cd /etc/apache2/cp h
备忘一下备忘一下:
一. 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请求
DirectoryIndex index.php index.html
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]里面,系统:Windows 7 x64 php版本:php 5.4.14下载地址 apache版本:2.2 mysql版本:5.5.29 点击下载 mysql为x64版本,其他版本请到官网下载 针对每次配置php都要从网上搜一下,感觉很麻烦。于是写了一下过程进行记录,以方便以后的配置。 1. apache的安装 apache添加以下几行配置:
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选项
#
# 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
3)在wordpress里面,选一个静态链接的选项,系统会在wordpress的根目录生成一个.htaccess文件。搞定!
4)因为我本机的目录CMS,并不是wordpress的更目录,所以.htaccess其实访问不到。
只有手动copy内容到 httpd.conf里面啦。呵呵。
DocumentRoot "E:\workspace_shawn\CMS"
ServerName shawn1234
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]