Install apache+php+jsp+mysql_ security settings under Windows2003

Source: Internet
Author: User
Tags file info ini stmt
Install Apache+php+jsp+mysql under Windows2003
First, PHP

Current version 4.3
1. Will php.ini-dist rem be php.ini,copy to winnt,copy Php4ts.dll to Winnt/system32, no need to copy or change other settings.

2. Php. Ini:

Register_globals = Off--> on
Extension=php_gd.dll remove annotations and start GD library
Extension_dir =./--> c:\php\extensions

---------------------------------

Second, the installation of Apache

Currently installed version 2.0.43
Configure httpd.conf files in the Conf directory

#安装apache模块方式添加:
LoadModule Php4_module C:/php/sapi/php4apache2.dll
AddType application/x-httpd-php. php
AddType application/x-httpd-php. php3
#Alias/www/"C:/Documents and settings/administrator/www/" (virtual directory, custom)

#安装cgi方式添加:
scriptalias/php/"c:/php/"
AddType application/x-httpd-php4. php
AddType APPLICATION/X-HTTPD-PHP4. php3
Action application/x-httpd-php4 "/php/php.exe"

#增加默认启动文档:
DirectoryIndex index.html increased to:
DirectoryIndex index.html index.htm index.php index.php3

#让apache2默认中文显示
#添加:
AddLanguage ZH-CN. cn
DefaultLanguage ZH-CN
#修改:
Adddefaultcharset iso-8859-1---> Adddefaultcharset GB2312
###########################################

Test file info.php:

?
Phpinfo ()
?>

Enter http://localhost/info.php in the browser


---------------------------------------------

Third, MySQL installation

1. The default installation path is: C:\mysql

2. Run C:\mysql\bin\winmysqladmin, enter username, password

If you do not have this service: Open the Run input c:\mysql\bin\mysqld-nt.exe–install. Then open the Administrative Tools-> Service, locate the MySQL service, and start it. Restart Windows2000.

====================================================================
If you do not need a JSP, install to this completion.
The following starts installing the JSP ====================================================================

Iv. installation of related software

1. Download a JDK (j2sdk-1_4_0-win.exe), assuming the installation is C:\J2SDK.

2, download resin for Windows version (2.1.6 version),
Address: http://www.caucho.com/download/, solution ... Resin\bin\httpd-install ", perform" C:\Resin\bin\httpd-remove "at the command line if you want to remove the Resin service from the system service.

3, download JDBC for MySQL
File name is Mm.mysql-2.0.14-bin.jar
Copy to C:\Resin\lib directory (for JSP to support MySQL).
----------------------------

V. Configure environment variables

My Computer right mouse button-> Properties-> advanced-> environment variable-> system variable bar

1, Java_home
Click "New ...", the variable Name column fills in "Java_home", the Variable Value column fills in "C:\j2sdk", click "OK".

2, Resin_home
Creates a new variable "Resin_home" with a value of "C:\resin".

3, CLASSPATH
In the system variable column find Classpath, click "Edit ...", if there is no this variable, click "New ...", after the value of the variable plus c:\j2sdk\lib\tools.jar;c:\j2sdk\lib\dt.jar; ", click OK."


Test Service:
Execution: http://localhost:8080 can see some environment variables for the current resin server.
---------------------------

Six, configure Apache bundle resin,

Execute C:\resin\bin\setup.exe
Selecting the Apache2 service automatically adds the content required for the C:\Apache\conf\httpd.conf file.


or open C:\Apache\conf\httpd.conf, add at the end
LoadModule caucho_module "C:/resin/libexec/apache-2.0/mod_caucho.dll"
<ifmodule mod_caucho.c>
Cauchoconfigfile "C:/resin/conf/resin.conf"
<Location/caucho-status>
SetHandler Caucho-status
</Location>
</IfModule>

Modify Resin configuration file c:\Resin\conf\Resin.conf
Find this line:<doc-dir>doc</doc-dir>
Change into:<doc-dir>c:/apache2/htdocs</doc-dir>

--------------------------


Create a new file test.jsp in the C:\Apache\htdocs\ directory, which reads as follows:

2+2=<=2+2>

Run http://localhost/test.jsp display in browser: 2+2=4
Description Apache+resin configuration complete.

-------------------------

To test the MySQL connection:


Suppose the MySQL database species to build a database MySQL, table name is User
Create a new file test-mysql.jsp in the C:\Apache\htdocs\ directory, which reads as follows:

<% @page language= "java" import= "java.sql.*" contenttype= "text/html"; charset=gb2312 "%>
<%
String ls_username = "root"; Database user Name
String Ls_password = "xxxxxx"; Password
String ls_server = "localhost";
String ls_dbname = "MySQL"; Database name
Connection con = null;
Try
{
Registering JDBC Connection drivers
Class.forName ("Org.gjt.mm.mysql.Driver");
Establishing a connection to the database
con = drivermanager.getconnection ("jdbc:mysql://" +ls_server+ "/" +ls_dbname,ls_username,ls_password);
}
catch (Exception e)
{
System.out.println (E.tostring ());
}
%>

<title> Test Database Connection </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" text= "#000000" >
<%
int li_count = 0;
String ls_sql = "SELECT count (*) from user"; Name of data table

Try
{
Statement Stmt = Con.createstatement ();
ResultSet rs = stmt.executequery (ls_sql);
if (Rs.next ())
Li_count = Rs.getint (1);
if (Rs!= null)
Rs.close ();
if (Stmt!= null)
Stmt.close ();

}
catch (Exception e)
{
Out.println ("<br>2" + e.tostring () + "<br>");
}
OUT.PRINTLN ("Total" + Li_count +) record <p> Test success! ");
%>
</body>
<%
Try
{
if (Con!= null)
Con.close ();
}
catch (SQLException Sqle)
{
System.out.println (Sqle.tostring ());
}
%>
If the access test.jsp can access the database, it is OK.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.