本人使用的是Apache1.3.28+PHP4.3.2+Mysql4.23.55+phpMyAdmin2.5.0黄金组合,因此以下就说一下学习php以来积累的一些服务器配置方面的应验:(本文以Apache+PHP+Mysql都安装在D盘为例)
一.Apache
安装好你的Apache服务器以后,Apache已能正常工作,但是还不能处理PHP程序,需进一步配置Apache使能处理PHP程序。在Apache安装目录里找到文件httpd.conf,本实验中文件的全路径为d:\Apache\conf\httpd.conf,并用记事本打开httpd.conf,加上如下几句:
[code]
scriptalias /php4/ "D:/php/"
addtype application/x-httpd-php .php .php3
action application/x-httpd-php /php4/php.exe
[/code]
注意各语句中的空格不能少,输入完之后保存文件。
要使上步中的配置生效,需要重新启动Apache,重启有多种方法,最简便的方法就是从开始菜单,如图13,也可以从运行栏里先运行命令net stop apache停止apache,再运行命令net start apache启动apache。如果启动不了,说明上步配置中有错误。
另外,介绍一个本机Apache服务器认证机制
1.首先在你的需要认证 机制的目录下边放一个名称为 .htaccess的文件,一般只有后缀的文件是不能建立的,您可以用一个非常优秀的程序编辑器Edit plus建立,假如你的apache安装在D:盘里,并且你的apache服务器 路径为:
D:\Apache\htdocs,那么这个.htaccess的文件里的 内容就为 :
[code]
AuthUserFile "D:\Apache\bin\pass.txt"
AuthName AnyName
AuthType basic
Require valid-user
[/code]
2.然后,把它放到 任何一个D:\Apache\htdocs的一个 目录下边 ,然后在“开始”——“运行”里打入“cmd”, 然后在
C:\>d:
D:\>cd Apache
D:\Apache>cd bin
D:\Apache\bin>htpasswd.exe
会出现 下列信息:
Usage: htpasswd [-cmdps] passwordfile username
htpasswd -b[cmdps] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password (default).
-d Force CRYPT encryption of the password.
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it. On Windows, TPF and NetWare systems the '-m' flag is used by default. On all other systems, the '-p' flag will probably not work.
3.然后是 :
D:\Apache\bin>htpasswd -m pass.txt chai
New password: ******
Re-type new password: ******
Adding password for user chai
4.然后在D:\Apache\conf目 录下边找到httpd.conf这个文 件在这个文件里找到这样一个关键字“ AllowOverride”看后边的一个 单词是不是All,如果 是不是,就更改为All,然后重新启 动Apache服务器就可以了。然后你就可以在 你的浏览器 里打入你的服务器目录了 ,这样你的认证机制就实现了。
如果是想在自己 在 http上服务器的 数据库空间上,如果有一个数据库管理工具phpMyAdmin,则可以通过修改 phpMyAdmin下边的config.inc.php文件实现,具体的方法是:
在这个文件里找 到
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
然后把它修改为 :
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
这样你的数据库 就可以实现身份验证了。
二.PHP
一般情况下,php很好配置,就是在你的D:\php\php.ini文件有些需要注意的地方: