创建一个"ftp"用户(如果还不存在的话),/var/ftp/就是FTP的根目录,
可换成其它的。
# mkdir /var/ftp/
# useradd -d /var/ftp ftp
#chown root /var/ftp
#chmod go -w /var/ftp
(三) 安装VSFTPD及其配置、执行和帮助文件。
#cd ~/downloads
#tar xzvf vsftpd-2.0.1.tar.gz
#cd vsftpd-2.0.1
#make
#mkdir /usr/local/man/man5
#mkdir /usr/local/man/man8
#make install
#cp vsftpd.conf /etc
(四) 编辑/etc/vsftpd.conf,在文件最后面加入行:listen=YES
若要求开机自动启动vsFTPd,就在/etc/rc.d/rc.local中加入:
/usr/local/sbin/vsftpd &
(五) 测试vsftpd
# /usr/local/sbin/vsftpd &
如果能够启动,
测试一下:
ftp 127.0.0.1
Connected to localhost (127.0.0.1).
220 (vsFTPd 1.1.1)
Name (localhost:chris): ftp
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127.0.0.1)
150 Here comes the directory listing.
226 Directory send OK.
ftp> quit
OK,证明ftp服务器是安装好了的。
3.6 配置Apache
Apache安装成功后,在conf子目录下会生成一个配置文件:httpd.conf是Apache设置文件中的主文件,httpd程序启动时会先读取httpd.conf。
以下是我配置的部分设置:
# Do NOT add a slash at the end of the directory path.
DocumentRoot "/usr/local/tomcat/webapps/ROOT"
MaxClients 150
服务器的最大连接数,如果连接达到150,那么再有连接到来,系统就会出现等待情况。
KeepAliveTimeout 15
是允许用户保持连接5秒内有效,如果用户在15秒内点击其他页面不需要重新建立联结
ErrorLog:
这个命令是指定当WWW Server运转过程中发生问题时错误信息存放到哪个日志文件。默认是logs/mytestweb.log
# 设置默认页面,中间用空格分开
DirectoryIndex index.html index.jsp index.xtp index.php index.php3
第四章 综合测试
4.1 测试JSP连接MYSQL
在/usr/local/tomcat/webapps(tomcat的DocumentRoot默认目录)下建立子目录test,复制目录(目录就是Windows下的文件夹)usr/local/tomcat/webapps/ROOT/WEB-INF到新建的test目录下。 在test目录下新建index.jsp文件:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html><title>Redhat AS 3下测试JSP页面(Tomcat+MySQL)</title><body> <%Class.forName("org.gjt.mm.mysql.Driver").newInstance(); String url =
"jdbc:mysql://localhost:3306/mysql?user=root&password=&useUnicode=true&characterEncoding=GB2312";
Connection conn= DriverManager.getConnection(url);
Statement stmt
=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from user";
ResultSet rs=stmt.executeQuery(sql); %>
<table><tr>
<td>您的第一个字段内容为:</td>
<td>您的第二个字段内容为:</td>
</tr> <%while(rs.next()) {%><tr>
<td><%=rs.getString(1)%> </td>
<td> <%=rs.getString(2)%> </td>
</tr> <%}%> </table>
<%out.print("Tomcat+JDK+mySQL完整测试,恭喜你,Tomcat操作数据库操作成功!");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
在浏览器上输入:http//localhost:8080/test 如果出现“Tomcat+JDK+mySQL完整测试,恭喜你,Tomcat操作数据库操作成功!”则说明测试成功。
4.2 测试PHP操作MySQL数据库
(一) 首先创建用户信息
CREATE TABLE T_UserInfo (
c_name varchar(255) not null default "anonymous",
c_usermail varchar(255) not null,
c_userurl varchar(255), c_sitename varchar(255),
primary key c_usermail
);
(二) 创建前台HTML文件(test.html):
<form enctype="multipart/form-data" action="test.php" method="post"> <tr>
<td vAlign="top" width="251" height="31"><small>您的姓名:
</small></td>
<td width="462" height="31"><small><input name="name"
size="37"> </small></td>
</tr><br>
<tr>
<td vAlign="top" width="251" height="30"><small>您的电子邮
件:</small></td>
<td width="462" height="30"><small><input name="usermail"
size="37"></small></td>
</tr>
<tr><br>
<td vAlign="top" width="251" height="25"><small>
您的网站地址:</small></td>
<td width="462" height="25"><small><small><input