先安装Apache然后再安装PHP5安装时选择apche服务器,完成后找到Apache\conf目录下的httpd.conf文件将port 80改成别的参数比如8083(系统不占用的)80端口一般被IIS所占用。
在其后面加入ScriptAlias /cgi-bin/ "d:/Apache/cgi-bin/"
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php/php-cgi.exe"
在其后面加入ScriptAlias /cgi-bin/ "d:/Apache/cgi-bin/"
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php/php-cgi.exe"
# Virtual hosts
Include conf/extra/httpd-vhosts.conf 去掉";"
保存重启Apache
1.
FreeBSD
可以使用编译方式安装php,使用ports或源码编译安装
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/sbin/apxs --with-mysql=/usr/local/mysql -enable-fastcgi --enable-sockets --enable-ftp --enable-zip --enable-mbstring --enable-mbregex --enable-calendar --with-curl=/usr/local/include/curl --with-curlwrappers --disable-debug --enable-inline-optimization --with-zlib --with-gd --with-kerberos --with-gettext --enable-force-cgi-redirect --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --with-bz2 --enable-pcntl --with-iconv
make && make install
复制配置文件
cp php.ini-dist /usr/local/php/lib/php.ini
执行步骤3
linux:
ubuntu:
sudo apt-get install php5
sudo apt-get install php5-gd
redhat;
yum install php
yum install php-gd
linux下执行步骤4即可
2.windows下比较简单
下载phpzip包解压到某个文件夹
我解压到d盘xin/php目录
将目录下的所有dll复制到system32目录
这个可以利用windows的搜索功能。
或者直接修改系统环境变量
将PHP目录下的php.exe、php-win.exe和php.ini-dist三个文件拷到C:\Windows ( Windows 2000 下为 C:\WINNT)下;将C:\Windows\php.ini-dist改名为php.ini,然后用记事本打开,利用记事本的查找功能搜索 CODE: register_globals = Off //ubuntu,freebsd,redhat都需要注意这个地方可能默认是off需要改为On,将 Off 改成 On ; 再搜索 CODE: extension_dir = ,并将其路径指到你的 PHP 目录下的 extensions 目录,比如:extension_dir = "d:\xin\ext" ; 3.
编辑httpd.conf
在# Example:
# LoadModule foo_module modules/mod_foo.so
#
加上一行
LoadModule php5_module d:/xin/php/php5apache2_2.dll
zai
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
加上两行
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html
4.
找到
#LoadModule rewrite_module modules/mod_rewrite.so
去掉#号
找到
# Alias /webpath /full/filesystem/path
去掉#号,
其中/webpath指的是虚拟目录名如d
访问时
http://localhost/d
/full/filesystem/path
指的是实际的路径如d:
我的配置
Alias /d d:
Alias /e e:
Alias /f f:
重启apache,这样就可以基本访问我的所有分区了。
</directory>
Allowoverride All
<directory>
需要改为All默认是none