摘抄 带php+mysql
引用
带php+mysql
apache安装
1.运行apache_2.0.49-win32-x86-no_ssl.exe,一路点"确定"和"接受"就行,路径选d:\server\apache group\apache2。
此时apache已经安装成功,且已运行,在IE中输入 http://localhost/ 可以看到apache的主页。安装成功!
2.修改httpd.conf
apache的配置文件是httpd.conf,位于apache根目录的下的conf文件夹下
(1).修改默认网站根目录:
在d:\server下建立文件夹www,以此作为网站的根目录
DocumentRoot "D:/server/Apache Group/Apache2/htdocs"
改为DocumentRoot "D:/server/www
(2).修改字符设置
apache解析中文网页时会产生乱码,
修改AddDefaultCharset ISO-8859-1为AddDefaultCharset GB2312
(3).修改默认主页
当访问目录时,apache会自动导入的主页,优先级以先后顺序为准
把DirectoryIndex index.html index.html.var改为
DirectoryIndex index.html index.jsp index.php default.jsp default.php index.html.var
(4).设置错误页面
这样对于你的网站会更安全些,如果没设置,别人在你的网址后随便输入一个路径,会显示404错
误,并且会显示你的服务器版本号,服务器配置一目了然,为了避免这种情况,可以设置错误页面。
当出现404错误,即找不到网页时,把访问者导入到一个错误页面
找到:
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
httpd.conf中的这一部分,#ErrorDocument 404 /missing.html
一行修改为ErrorDocument 404 /error/noFile.htm,其中noFile.htm为d:\server\www\error\下一个错误文件,需
要你自己建立。当发生404错误时,进入noFile.htm页面,可以提示网页没有找到。这样就不可能看到
你的服务器软件信息了。也可以设置其它的错误导向的页面,具体http响应错误编号请查阅相关资料。
重新启动apache,如果没意外,此时已经安装成功,把静态页面放到d:\server\www\error\目录下,看能不能成功解析。
随便输入一个:http://localhost/sdagasgdasasg.htm,看是不是导向你设置的404错误,即noFile.htm错误页面.
php安装
解压php-4.3.3-Win32.zip,到d:\server\php目录下.下配置PHP和Apache,使之能解析php程序。
将d:\server\php\目录中的“php.ini-dist”改名“php.ini”,并复制到C:\windows\system32
(Win2K目录为:C:\winnt\system32)下,在apache的配置文件httpd.conf中下入以下几行,使之
支持php.
ScriptAlias /php/ "d:/server/php/"
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php.exe"
在d:\server\www下建立网页:index.php,内容为:
<html>
<head><title>php测试</title></head>
<?php
phpinfo();
?>
</html>
用文本编辑器编辑好为存为index.php,重新启动apache,在IE中输入 http://localhost/index.php ,如果出现php的
环境变量,说明php,安装成功,如果不能解析<?php phpinfo(); ?>中的部分,则说明没有成功安装。
Tomcat的安装
我用的是jakarta-tomcat-4.1.30.exe安装文件,在windows下一路点"确定"就行了,比较简单,安装目录为d:\server\tomcat
下面设置环境变量:
同jdk的环境变量,添加变量TOMCAT_HOME,值为d:\server\tomcat;增加变量CATALINA_HOME,值为d:\tomcat\server
在path变量中加入d:\server\tomcat\bin
下面启动tomcat,运行tomcat目录下的,bin/startup.bat文件就行啦,出现tomcat运行控制台,tomcat成功启动.
在IE中输入 http://localhost:8080/ ,看到大猫的吧,则tomcat安装成功.
安装MySQL
第一步:解压 mysql-max-3.23.46a-win.zip,运行mysql安装文件,把mysql安装到d:\server\mysql
第二步:在环境变量path中加入 d:\server\mysql\bin
第三步:进入d:\server\mysql\bin目录,运行winmysqladmin,刚会出现对话框,设置mysql用户密码,假设
帐号为:root 密码为:123
第四步:进入dos,进入mysql/bin下,运行以下命令打开mysql
mysqld-nt --standalone
则mysql开启
然后运行:
mysql
如果开启,则出现以下文字:
Welcome to the MySQL monitor. Commonds end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.46-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
注意:此时mysql没有设置密码,为了不让别人进入你的数据库,请为mysql设置密码,具体操作请参阅mysql
的中文说明文档。 至此,mysql安装成功!
六.安装MySQL的驱动类jdbc
解开jdbc驱动包,把里面的org文件夹复制到jsp可以找到的位置就行啦。可以是tomcat的根目录common/classes
文件夹下,也可以是jsp网站class类WEB-INF/class/下。当加载驱动程序时,以便能找到相关的类。或者把jdbc包
的路径加入到classpath变量中。
