Chapter One experiment (i): build a Web server
1. Use the parent disk link to clone the virtual machine and modify the basic parameters such as Ip:
Clone the virtual machine, name the Web server, and modify the Following:
IP A # #查看MAC地址
[email protected] ~]# Vi/etc/sysconfig/network-scripts/ifcfg-eth0 # #确保MAC地址与eth1一致
Device=eth0
hwaddr=00:0c:29:88:f9:43
Type=ethernet
Onboot=yes
Nm_controlled=no
Bootproto=static
ipaddr=192.168.100.150
netmask=255.255.255.0
gateway=192.168.100.100
dns1=192.168.100.100
: Wq
[email protected] ~]# vim/etc/udev/rules.d/70-persistent-net.rules # #删除eth0行 and change eth1 to Eth0
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image002[4] "border=" 0 "alt=" clip_image002[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9kf7bx4lgaaaskjz96y4160.jpg "width=" 244 "height="/>
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image004[4] "border=" 0 "alt=" clip_image004[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5c/wkiol1e9kf-w1r-caaabi9djtsg816.jpg "width=" 244 "height=" "/>"
[email protected] ~]# cat/etc/sysconfig/network # #设置主机的FQDN
Networking=yes
hostname=www.linuxfan.cn
: Wq
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image006[4] "border=" 0 "alt=" clip_image006[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5c/wkiol1e9kf_sajlraaanz83s5ho375.jpg "width=" 244 "height=" "/>"
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image008[4] "border=" 0 "alt=" clip_image008[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5c/wkiol1e9kgdgymqaaaalaelqq7w957.jpg "width=" 244 "height="/>
[email protected] ~]# reboot
Log on to 192.168.100.100 to add the DNS resolution for the Host:
[email protected] ~]# Vim/var/named/chroot/var/named/linuxfan.cn.zone
www in A 192.168.100.150
: Wq
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image010[4] "border=" 0 "alt=" clip_image010[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5d/wkiom1e9kghhe0o4aaa4rbb3ubk179.jpg "width=" 244 "height=" 178 "/>
[email protected] ~]# Vim/var/named/chroot/var/named/192.168.100.arpa
In PTR Www.linuxfan.cn.
: Wq
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image012[4] "border=" 0 "alt=" clip_image012[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5d/wkiom1e9kgkauyvlaaaqmvuthp4894.jpg "width=" 244 "height=" 156 "/>
/etc/init.d/named restart
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image014[4] "border=" 0 "alt=" clip_image014[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9kgka573xaaauowg75ag483.jpg "width=" 244 "height="/>
[email protected] ~]# nslookup
> Server 192.168.100.100
Default server:192.168.100.100
address:192.168.100.100#53
> www.linuxfan.cn
server:192.168.100.100
address:192.168.100.100#53
Name:www.linuxfan.cn
address:192.168.100.150
> Exit
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image016[4] "border=" 0 "alt=" clip_image016[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5c/wkiol1e9kgobvf3zaaadw_-yk_u850.jpg "width=" 244 "height=" "/>
[email protected] ~]#
2. Download the SOFTWARE and Install: login 192.168.100.100
1) Download httpd
[email protected] ~]# lftp ftp.linuxfan.cn
Lftp ftp.linuxfan.cn:~> CD tools/
Lftp ftp.linuxfan.cn:/tools> Get httpd-2.2.17.tar.gz
6597991 bytes Transferred
Lftp ftp.linuxfan.cn:/tools> bye
[[email protected] ~]# ls httpd-2.2.17.tar.gz
Httpd-2.2.17.tar.gz
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image018[4] "border=" 0 "alt=" clip_image018[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5d/wkiom1e9kgtsv2boaaaljrmx-im161.jpg "width=" 244 "height="/>
2) Unzip and Install:
Mount/dev/cdrom/mnt
Yum-y Install Openssl-devel # #安装openssl-devel provides HTTPS support
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image020[4] "border=" 0 "alt=" clip_image020[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5c/wkiol1e9kgwieqsbaaaq3sprhx4643.jpg "width=" 244 "height=" 108 "/>
[email protected] ~]# Tar zxvf httpd-2.2.17.tar.gz-c/usr/src/
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image022[4] "border=" 0 "alt=" clip_image022[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5d/wkiom1e9kgwwxz6gaaadgbe1jpc391.jpg "width=" 244 "height="/>
[email protected] ~]# cd/usr/src/httpd-2.2.17/
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image024[4] "border=" 0 "alt=" clip_image024[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9kgajk_g8aaawvbwqp-e812.jpg "width=" 244 "height=" 119 "/>
[email protected] httpd-2.2.17]#/configure--prefix=/usr/local/httpd--enable-so--enable-rewrite--enable-cgi-- Enable-ssl && make &&make Install
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image026[4] "border=" 0 "alt=" clip_image026[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5c/wkiol1e9kgewddjdaaautayc1cw494.jpg "width=" 244 "height=" 102 "/>
[[email protected] httpd-2.2.17]# Echo $? # #返回0为成功
0
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image028[4] "border=" 0 "alt=" clip_image028[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5c/wkiol1e9kgjavwr0aaapttukeue552.jpg "width=" 244 "height="/>
[email protected] httpd-2.2.17]# ls/usr/local/httpd/# #安装成功
Bin Cgi-bin error icons lib man modules
Build conf htdocs include logs manual
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image030[4] "border=" 0 "alt=" clip_image030[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5c/wkiol1e9kgijazb7aaaxkefgevs409.jpg "width=" 244 "height="/>
3. post-installation optimization and Adjustment:
[email protected] httpd]# ln-s/usr/local/httpd/bin/*/usr/local/bin/# #优化执行命令的路径
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image032[4] "border=" 0 "alt=" clip_image032[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5d/wkiom1e9kgmj4rkqaaasqpsv338276.jpg "width=" 244 "height=" "/>"
[email protected] httpd]# cp/usr/local/bin/apachectl/etc/init.d/httpd
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image034[4] "border=" 0 "alt=" clip_image034[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5d/wkiom1e9kgnbzuobaaar6wlht-y845.jpg "width=" 244 "height="/>
[[email protected] httpd]# vim/etc/init.d/httpd # #在开始位置修改bash和添加chkconfig和description; modifying line 82nd implements friendly hints when executing commands
#!/bin/bash # #声明shell为bash
# chkconfig:35 # #在3和5运行级别开机启动, boot start sequence is 85, shutdown sequence is 15
# description:a Scripts for Apache httpd deamon!
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image036[4] "border=" 0 "alt=" clip_image036[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5d/wkiom1e9kgrjk1pqaaahxpacejo495.jpg "width=" 244 "height=" "/>"
$HTTPD-k $ARGV &&echo "HTTPD is $ARGV complete." # #第82行
: Wq
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image038[4] "border=" 0 "alt=" clip_image038[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5c/wkiol1e9kgudgmvgaaapbmlfbvw997.jpg "width=" 244 "height=" 106 "/>
[[email protected] httpd]# ls-l/etc/init.d/httpd # #确认文件有执行权限, if not using the command "chmod +x/etc/init.d/httpd" authorization
-rwxr-xr-x 1 root root 3496 January 1 02:59/etc/init.d/httpd
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image040[4] "border=" 0 "alt=" clip_image040[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9kguamofzaaaqdmehu8i506.jpg "width=" 244 "height=" "/>"
[email protected] httpd]# Chkconfig--add httpd
[email protected] httpd]# chkconfig--list httpd
httpd 0: off 1: off 2: off 3: enable 4: off 5: enable 6: off
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image042[4] "border=" 0 "alt=" clip_image042[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5d/wkiom1e9kgywb0m_aaaxy6gq06e838.jpg "width=" 244 "height=" "/>
4. Modify the configuration file and start the Service:
[email protected] httpd]# vim/usr/local/httpd/conf/httpd.conf
: Set Nu # #打印出行号
ServerAdmin [email protected] # #修改管理员的邮箱
98 ServerName www.linuxfan.cn:80 # #添加网站的FQDN
: Wq
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image044[4] "border=" 0 "alt=" clip_image044[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5d/wkiom1e9kg2x2mjbaaa9aucw3ys868.jpg "width=" 244 "height=" 138 "/>
[email protected] httpd]#/etc/init.d/httpd Start # #启动服务
HTTPD is start Complete.
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image046[4] "border=" 0 "alt=" clip_image046[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9kg2y0nq4aaavlwm6fle924.jpg "width=" 244 "height=" "/>"
[[email protected] httpd]# ps aux |grep httpd # #查看进程
Root 73341 0.0 0.5 54808 2520? Ss 03:21 0:00/usr/local/httpd/bin/httpd-k Start
Daemon 73342 0.0 0.4 54944 2000? S 03:21 0:00/usr/local/httpd/bin/httpd-k Start
Daemon 73343 0.0 0.4 54944 2000? S 03:21 0:00/usr/local/httpd/bin/httpd-k Start
Daemon 73344 0.0 0.4 54944 2000? S 03:21 0:00/usr/local/httpd/bin/httpd-k Start
Daemon 73345 0.0 0.4 54944 2000? S 03:21 0:00/usr/local/httpd/bin/httpd-k Start
Daemon 73346 0.0 0.4 54944 2000? S 03:21 0:00/usr/local/httpd/bin/httpd-k Start
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image048[4] "border=" 0 "alt=" clip_image048[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5d/wkiom1e9kg7hnhf-aabjlrwyjfg302.jpg "width=" 244 "height=" 157 "/>
[email protected] httpd]# netstat-utpln |grep httpd # #查看监听
TCP 0 0::: +:::* LISTEN 73341/httpd
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image050[4] "border=" 0 "alt=" clip_image050[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5d/wkiom1e9kg-dsfotaaavnunv9fm469.jpg "width=" 244 "height=" "/>"
5. Access and Test:
[[email protected] ~]# yum-y Install ELinks # #在192.168.100.100 for testing
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image052[4] "border=" 0 "alt=" clip_image052[4] "src=" http://s3.51cto.com/wyfs02/M00/86 /5c/wkiol1e9kg-jwuglaaaeylcws0m588.jpg "width=" 244 "height="/>
[email protected] ~]# vi/etc/resolv.conf
; Generated By/sbin/dhclient-script
NameServer 192.168.100.100 # #添加DNS服务器
NameServer 192.168.1.1 # #不必修改, This DNS server automatically obtains the DNS server for the bridge adapter to be able to get on the public network
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image054[4] "border=" 0 "alt=" clip_image054[4] "src=" http://s3.51cto.com/wyfs02/M01/86 /5d/wkiom1e9khdtvflyaaas7ytc0ca309.jpg "width=" 244 "height="/>
[email protected] ~]# elinks--dump http://www.linuxfan.cn # #成功完成实验
It works!
650) this.width=650; "style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image056[4] "border=" 0 "alt=" clip_image056[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9khgj3w-eaaaswpx1edo640.jpg "width=" 244 "height="/>
Windows hosts use IE or Chrome (google), Firefox (firefox) and other browsers to Access:
http://www.linuxfan.cn
650) this.width=650; "style=" background-image:none; border-right-0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image058[4] "border=" 0 "alt=" clip_image058[4] "src=" http://s3.51cto.com/wyfs02/M02/86 /5d/wkiom1e9khhcfc45aaas8fiii7m523.jpg "width=" 244 "height=" "/>"
Building a Web server