欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php开发环境配置记录

程序员文章站 2023-04-07 12:41:50
【apache安装】 复制代码 代码如下: httpd.exe -k install -n "apache2.2.15" httpd.exe -k start -n "ap...
【apache安装】
复制代码 代码如下:

httpd.exe -k install -n "apache2.2.15"
httpd.exe -k start -n "apache2.2.15"

【apache卸载】
复制代码 代码如下:

httpd.exe -k stop -n "apache2.2.15"
httpd.exe -k uninstall -n "apache2.2.15"

【httpd.conf配置关键】
复制代码 代码如下:

serverroot "d:/apm/apache2.2.15"
listen 80
# 压缩发送给客户端的内容 gzip支持
#loadmodule deflate_module modules/mod_deflate.so
# loadmodule cgi_module modules/mod_cgi.so
# fastcgi
loadmodule fcgid_module modules/mod_fcgid.so
loadmodule rewrite_module modules/mod_rewrite.so
documentroot "d:/apm/apache2.2.15/htdocs"
# 支持 php 脚本
# fastcgi模式将此行注释
# 直接在虚拟主机中可配置每个站点使用不同版本的php 或者不同的cgi
#include conf/extra/httpd-php.conf
# fancy directory listings 华丽的目录清单
include conf/extra/httpd-autoindex.conf
# virtual hosts 虚拟主机
#include conf/extra/httpd-vhosts.conf
# fastcgi模式虚拟主机
include conf/extra/httpd-vhosts-fcgid.conf
# various default settings 页脚显示版本信息accessfilename .htaccess
include conf/extra/httpd-default.conf

【httpd-php.conf参考】
复制代码 代码如下:

#
# 查找 /apm/php-5.2.12-win32 替换
#
setenv phprc "/apm/php-5.2.12-win32"
setenv tmp "/tmp"
# unsetenv perl5lib
# 加载dll省去在path中添加php路径
#loadfile "/apm/php-5.2.12-win32/libpq.dll"
loadfile "/apm/php-5.2.12-win32/libmysql.dll"
loadfile "/apm/php-5.2.12-win32/libmcrypt.dll"
loadfile "/apm/php-5.2.12-win32/libmhash.dll"
loadfile "/apm/php-5.2.12-win32/libeay32.dll"
loadfile /apm/php-5.2.12-win32/ssleay32.dll
#
# php-module setup
#
loadfile "/apm/php-5.2.12-win32/php5ts.dll"
loadmodule php5_module "/apm/php-5.2.12-win32/php5apache2_2.dll"
sethandler application/x-httpd-php
sethandler application/x-httpd-php-source
# load php.ini file dir
phpinidir "/apm/php-5.2.12-win32"
addtype text/html .php .phps

【httpd-vhosts.conf参考】
复制代码 代码如下:

namevirtualhost *:80
#文档目录
documentroot "/vhosts/localhost"
#名字 如www.php.net
servername localhost
#别名 如php.net
serveralias 127.0.0.1
#错误日志文件
errorlog "logs/dummy-host.localhost-error_log"
#目录访问规则
options indexes followsymlinks
allowoverride all
order allow,deny
allow from all
#目录索引文件
directoryindex index.html index.htm index.php
[html]
【httpd-vhosts-fcgid.conf参考】
[code]
#fcgidinitialenv phprc "/apm/php5210"
#fcgidinitialenv path "/apm/php5210;c:/windows/system32;c:/windows;c:/windows/system32/wbem;"
#fcgidinitialenv systemroot "c:/windows"
#fcgidinitialenv systemdrive "c:"
#fcgidinitialenv temp "c:/windows/temp"
#fcgidinitialenv tmp "c:/windows/temp"
#fcgidinitialenv windir "c:/windows"
fcgidiotimeout 64
fcgidconnecttimeout 16
fcgidmaxrequestsperprocess 500
namevirtualhost *:80
documentroot "/vhosts/localhost"
servername localhost
serveralias 127.0.0.1
errorlog "logs/dummy-host.localhost-error_log"
options indexes followsymlinks execcgi
#options +execcgi
allowoverride all
#addhandler fcgid-script .php
#fcgiwrapper /apm/php5210/php-cgi.exe .php
#"
addhandler fcgid-script .php
fcgidwrapper "/apm/php-5.2.13-nts-win32/php-cgi.exe" .php
#fcgidwrapper "/apm/php-5.3.2-nts-win32-vc6-x86/php-cgi.exe" .php
#
order allow,deny
allow from all
directoryindex index.html index.htm index.php

【mysql安装】
复制代码 代码如下:

mysqld-nt.exe --install mysql5.0.45-community-nt --defaults-file=d:\apm\mysql5.0.45\my.ini
net start mysql5.0.45-community-nt

【mysql卸载】
复制代码 代码如下:

net stop mysql5.0.45-community-nt
mysqld-nt.exe --remove mysql5.0.45-community-nt

【my.ini参考】
复制代码 代码如下:

[mysqld]
basedir="d:\apm\mysql5.0.45\"
datadir="d:\apm\mysql5.0.45\data\"
tmpdir="d:\apm\mysql5.0.45\tmp\"
# log="d:\apm\mysql5.0.45\tmp\mysql.log"
default-character-set=utf8
port=3306
interactive_timeout=5
wait_timeout=5
skip-locking
skip-innodb
skip-bdb
ft_min_word_len=1
[mysqld]
port=3306
basedir="d:/mysql/"
datadir="d:/mysql/data/"
tmpdir="d:/mysql/tmp/"
default-character-set=utf8
default-storage-engine=myisam
skip-bdb
skip-innodb
skip-locking
key_buffer=16m
max_allowed_packet=1m
table_cache=128
thread_cache=8
join_buffer_size=512k
sort_buffer=512k
record_buffer=512k
max_connections=500
wait_timeout=120
interactive_timeout=120
max_connect_errors=3000
long_query_time=1
max_heap_table_size=16m
tmp_table_size=8m
thread_concurrency=8
myisam_sort_buffer_size=8m
myisam_sort_buffer_size=4m
low_priority_updates=1
ft_min_word_len=1

【php.ini配置参考】
复制代码 代码如下:

output_buffering = on
disable_functions = system,passthru,shell_exec,exec,popen,proc_open
enable_dl = off

upload_tmp_dir = "d:/tmp/uploadtemp/"
session.save_path = "d:/tmp/sessiondata/"
date.timezone = "etc/gmt-8" ;表示的是 gmt+8
mbstring.language = neutral ; set default language to neutral(utf-8) (default)
mbstring.internal_encoding = utf-8 ; set internal encoding to utf-8

cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1

[eaccelerator]
;zend_extension="/apm/ext/eaccelerator_v0_9_6_for_v5_2_13-vc6/eaccelerator.dll"
;zend_extension="/apm/ext/eaccelerator_v1_0_svn412_for_v5_2_13-vc6/eaccelerator.dll"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
;eaccelerator.log_file="/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

[zend]
zend_optimizer.optimization_level=15
zend_optimizer.encoder_loader=0
;zend_extension_ts="/apm/ext/zendoptimizer-3.3.0/lib/optimizer-3.3.0/php-5.2.x/zendoptimizer.dll"
;zend_extension="/apm/ext/zendoptimizer_nts.dll"
;zend_extension="/apm/ext/zendoptimizerplus.dll"

; 下面是使用zendextensionmanager.dll的参考配置
;zend_extension_manager.optimizer_ts="/apm/zend/zendoptimizer-3.3.0/lib/optimizer-3.3.0"
;zend_extension_ts="/apm/zend/zendoptimizer-3.3.0/lib/zendextensionmanager.dll"
;zend_extension_manager.debug_server_ts="/apm/zend/zendoptimizer-3.3.0/lib/zenddebugger-5.2.13-cygwin_nt-i386"
;zend_debugger.expose_remotely=always
;zend_debugger.allow_hosts=127.0.0.1/32
;zend_debugger.allow_tunnel=127.0.0.1/32
[zenddebugger]
; 放到后边可以和zend_optimizer同时加载
;zend_extension_ts="/apm/ext/zenddebugger-5.2.15rc1-cygwin_nt-i386/php-5.2.x/zenddebugger.dll"

[xcache-common]
;zend_extension="d:/apm/ext/xcache-1.3.0-php-5.2.10-nts-win32-vc6-x86/php_xcache.dll"
; extension = php_xcache.dll

[xcache.admin]
xcache.admin.enable_auth = off
xcache.admin.user = "moo"
; xcache.admin.pass = md5($您的密码)
xcache.admin.pass = ""

[xcache]
; 这里的多数选项仅在 ini 里可以修改, 这里列出的都是默认值, 除非另外说明
; select low level shm/allocator scheme implemenation
xcache.shm_scheme = "mmap"
; 禁用: xcache.size=0
; 启用: xcache.size=64m 之类 (任意>0的值) 同时请注意您的系统 mmap 上限
xcache.size = 0
; 建议设置为 cpu 数 (cat /proc/cpuinfo |grep -c processor)
xcache.count = 1
; 只是个参考值, 您可以放心地存储多于此数量的项目(php脚本/变量)
xcache.slots = 8k
; 缓存项目的 ttl, 0=永久
xcache.ttl = 0
; 扫描过期项目的时间间隔, 0=不扫描, 其他值以秒为单位
xcache.gc_interval = 60

; 同上, 只是针对变量缓存设置
xcache.var_size = 1m
xcache.var_count = 1
xcache.var_slots = 8k
; 默认, 允许 ini_set()
xcache.var_ttl = 0
; 最大ttl值
xcache.var_maxttl = 0
xcache.var_gc_interval = 300

; 仅测试用
xcache.test = off
; /dev/zero 时无效
xcache.readonly_protection = off
; 对于 *nix 系统, xcache.mmap_path 是文件路径而不是目录, (可以不存在 但是必须能创建).
; 如果您期望启用 readonlyprotection, 可以使用类似 "/tmp/xcache"
; 2 个 php 组不会共享同一个 /tmp/xcache
; 对于 win32 系统, xcache.mmap_path=匿名map名字, 不是文件路径. 建议使用 xcache 字眼避免跟其他软件冲突
xcache.mmap_path = "xcache"

; 仅用于 *nix 系统
; 设置为空(禁用) 或者类似 "/tmp/phpcore/"
; 注意该目录应该能被 php 写入文件 (跟 open_basedir 无关)
xcache.coredump_directory = ""

xcache.cacher = on
xcache.stat = on
xcache.optimizer = off

[xcache.coverager]

; 如果 xcache.coveragedump_directory 设置为空则本设置自动为 off
xcache.coverager = off

; 请确保本目录能被 coverage viewer 脚本读取 (注意 open_basedir)
; 依赖于 xcache.coverager=on
xcache.coveragedump_directory = ""

[xdebug]
xdebug.var_display_max_depth = 10
;xdebug.remote_autostart = 1
;xdebug.remote_enable=1
;xdebug.remote_handler=dbgp
;xdebug.remote_host=127.0.0.1
;xdebug.remote_mode=req
;xdebug.idekey=default
;xdebug.remote_log="/xdebug.log"
;xdebug.remote_port=9000
xdebug.auto_trace=off
;xdebug.collect_params=on
;xdebug.collect_return=on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.profiler_enable=off
xdebug.profiler_output_dir="/tmp/xdebug"
;zend_extension_ts="/apm/ext/xdebug/php_xdebug-2.0.5-5.2.dll"
;zend_extension="/apm/ext/xdebug/php_xdebug-2.0.5-5.2-nts.dll"
zend_extension="/apm/ext/xdebug/php_xdebug-2.1.0beta3-5.2-vc6-nts.dll"

【iis isapi】
复制代码 代码如下:

添加环境变量 phprc=d:\php 这个是通知iis读取php.ini文件的路径。
在path中加入 d:\php 能读取相关动态链接库。
添加一个新的web服务扩展 php d:\php\php5isapi.dll
添加应用程序扩展名映射 可执行文件 d:\php\php5isapi.dll 扩展名.php
重启iis php就可以用了。

【iis fastcgi php】
复制代码 代码如下:

这个不用添加环境变量和修改path变量。
先安装fastcgi,安装程序会自动添加
web 服务扩展 - fastcgi handler
c:\windows\system32\inetsrv\fcgiext.dll
并设置为允许。
修改c:\windows\system32\inetsrv\fcgiext.ini
[types]
php=php
[php]
exepath=d:\php\php-cgi.exe
instancemaxrequests=10000
environmentvars=php_fcgi_max_requests:10000
添加应用程序扩展名映射 可执行文件 c:\windows\system32\inetsrv\fcgiext.dll 扩展名.php
重启iis就行了。

【isapi_rewrite 参考】
复制代码 代码如下:

rewriteengine on
rewritebase /

rewritecond %{http_host} ^03188.net [nc]
rewriterule ^(.*)$ http://www.03188.net/$1 [l,r=301]

#### rewritecond %{request_uri} ^[a-z]{3,9}\ /index\.php\ http /
# rewriterule ^index\.(php|htm|html)$ http://www.03188.net/ [r=301,l]

rewriterule ^([a-z]+)/(.*)/(.*)/(.*)\.htm$ index.php?action=$1&option=$2&extent=$3&info=$4 [l]
rewriterule ^([a-z]+)/(.*)/(.*)\.htm$ index.php?action=$1&option=$2&extent=$3&info=$3 [l]
rewriterule ^([a-z]+)/(.*)\.htm$ index.php?action=$1&option=$2 [l]
rewriterule ^([a-z]+)\.htm$ index.php?action=$1 [l]

# rewriterule ^(.*)\.asp$ http://www.03188.net [l,r=301]
# 修改完整模式下被抓取的url使有效
# rewriterule ^index\.php/([a-z]+)/(.*)/(.*)\.htm$ $1/$2/$3\.htm [l,r=301]
# rewriterule ^index\.php/([a-z]+)/(.*)\.htm$ $1/$2\.htm [l,r=301]

# 修改论坛移动后出现no input file specified.
# rewriterule ^bbs/(.*)$ http://bbs.03188.net/$1 [l,r=301]

# 修改人力资源hr
# rewriterule ^hr/(.*)$ http://hr.03188.net/$1 [l,r=301]