Apache服务器是目前世界上使用最多的Web服务器。它采用三次握手的方式,在HTTP客户端和服务器之间进行数据交换。三个阶段分别是建立会话(双向)、发出请求、服务器应答,客户端浏览器利用通信层的通信协议(通常是TCP),默认端口80,来与服务器建立会话。
配置步?:
1.准备工作,建立两个测试网页 test1.html、test2.html,分别放在/var/www和/home目录下,test1.html对应8888端口,test2.html对应6666端口;
2.连同客户机和服务器;
3.检查是否安装了Apache服务器
# rpm -qa|grep httpd
httpd-2.2.8-1.fc7
说明已经安装了Apache服务器。
4.打开配置文件
(1)设置管理员的email地址
#vi /ect/httpd/conf/httpd.conf,对主配置文件进行修改。
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin root@localhost
(2)指定主文档,即用户连接到目录是默认打开的网页名称
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var test1.html test2.html
(3)建立虚拟主机
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#
DocumentRoot /var/www
DocumentRoot /home
到此,服务器基本配置完成,但在这里仍需做一些前提工作。
#system-config-securitylevel 打开防火墙配置界面,在端口中添加8888和6666端口,保存。
#system-config-selinux打开SElinux Management 界面
选择Select-->Network Port-->添加,弹出Add Network Port界面,在Port Number中填入8888,Protocol选择tcp,确定。同样方法添加6666端口。
5.启动Apache服务器
#service httpd start [确定]
此时在可在客户机的浏览器中输入http:\\172.30.2.211:8888即可浏览网页test1.html
6.关闭Apache服务器
#service httpd stop [确定]
7.重启Apache服务器
#service httpd restart
其他的一些设置(安全设置、管理设置等)仍在学习中。