Building 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地址
650) this.width=650; "title=" clip_image001 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image001 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ya7jsansaaal31x1zlu911.png "width=" 244 "height=" "/>"
[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
650) this.width=650; "title=" clip_image003 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image003 "src=" http://s3.51cto.com/wyfs02/M02/86/4F/ Wkiom1e7ya-ykqx4aaac4iapkno666.jpg "width=" 244 "height=" 161 "/>
[email protected] ~]# vim/etc/udev/rules.d/70-persistent-net.rules # #删除eth0行 and change eth1 to Eth0
650) this.width=650; "title=" clip_image004 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image004 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7ybkioxyxaaaggo-bvlo990.png "width=" 244 "height=" 123 "/>
[email protected] ~]# cat/etc/sysconfig/network # #设置主机的FQDN
Networking=yes
hostname=www.linuxfan.cn
: Wq
650) this.width=650; "title=" clip_image006 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image006 "src=" http://s3.51cto.com/wyfs02/M02/86/4F/ Wkiom1e7ybuslhfdaaausf9r3r0078.jpg "width=" 244 "height=" Wuyi "/>
[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; "title=" clip_image008 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image008 "src=" http://s3.51cto.com/wyfs02/M00/86/4F/ Wkiom1e7ybzjd73laaalndipcjg267.jpg "width=" 244 "height=" 139 "/>
[email protected] ~]# Vim/var/named/chroot/var/named/192.168.100.arpa
In PTR Www.linuxfan.cn.
: Wq
650) this.width=650; "title=" clip_image010 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image010 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7ycdbgymiaaaobqudv08726.jpg "width=" 244 "height="/>
/etc/init.d/named restart
650) this.width=650; "title=" clip_image012 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image012 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7ycdgemibaaands21e88352.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; "title=" clip_image014 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image014 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ychiubsyaaaw25cryk8370.jpg "width=" 244 "height=" 139 "/>
[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/
650) this.width=650; "title=" clip_image016 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image016 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ycorxlqbaaao6syoqyw503.jpg "width=" 244 "height="/>
Lftp ftp.linuxfan.cn:/tools> Get httpd-2.2.17.tar.gz
6597991 bytes Transferred
650) this.width=650; "title=" clip_image018 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image018 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7ycotoxovaaaodryfbsy831.jpg "width=" 244 "height="/>
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; "title=" clip_image020 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image020 "src=" http://s3.51cto.com/wyfs02/M02/86/4F/ Wkiom1e7ycecngtdaaaywengpmq404.jpg "width=" 244 "height=" Wuyi "/>
2) Unzip and Install:
Mount/dev/cdrom/mnt
650) this.width=650; "title=" clip_image022 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image022 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7ycfzzw4kaaazdj60xnc277.jpg "width=" 244 "height=" "/>"
Yum-y Install Openssl-devel # #安装openssl-devel provides HTTPS support
650) this.width=650; "title=" clip_image024 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image024 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ycmciaoqaaap_adqiau416.jpg "width=" 244 "height=" 118 "/>
[email protected] ~]# Tar zxvf httpd-2.2.17.tar.gz-c/usr/src/
650) this.width=650; "title=" clip_image026 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image026 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7ycrdsb9oaaaxnz4491u875.jpg "width=" 244 "height="/>
[email protected] ~]# cd/usr/src/httpd-2.2.17/
650) this.width=650; "title=" clip_image028 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image028 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ycyge0ktaaas4300xko746.jpg "width=" 244 "height="/>
[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; "title=" clip_image030 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image030 "src=" http://s3.51cto.com/wyfs02/M00/86/4E/ Wkiol1e7yddgrlaeaaaf9rdblra242.jpg "width=" 244 "height="/>
[[email protected] httpd-2.2.17]# Echo $? # #返回0为成功
0
650) this.width=650; "title=" clip_image032 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image032 "src=" http://s3.51cto.com/wyfs02/M02/86/4F/ Wkiom1e7yddid2d8aaavmfzbsve508.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; "title=" clip_image034 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image034 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7ydgsdotdaaaxqz4aodm785.jpg "width=" 244 "height="/>3. post-installation optimization and tuning:
[email protected] httpd]# ln-s/usr/local/httpd/bin/*/usr/local/bin/# #优化执行命令的路径
CD/USR/LOCAL/HTTPD Enter
[email protected] httpd]# CP bin/apachectl/etc/init.d/httpd
650) this.width=650; "title=" clip_image036 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image036 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7ydkixjyyaaaciksmm9w452.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
650) this.width=650; "title=" clip_image038 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image038 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ydkrbsmiaaak34mzefw687.jpg "width=" 244 "height=" "/>"
# description:a Scripts for Apache httpd deamon!
650) this.width=650; "title=" clip_image040 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image040 "src=" http://s3.51cto.com/wyfs02/M00/86/4F/ Wkiom1e7ydoarfkcaaag9azatm8686.jpg "width=" 244 "height=" "/>"
$HTTPD-k $ARGV &&echo "HTTPD is $ARGV complete." # #第82行
650) this.width=650; "title=" clip_image042 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image042 "src=" http://s3.51cto.com/wyfs02/M00/86/4E/ Wkiol1e7ydbck4n-aaal3jxawxu661.jpg "width=" 244 "height=" "/>
: Wq
[[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; "title=" clip_image044 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image044 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7ydbrs9ifaaatfrbr5qm413.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; "title=" clip_image046 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image046 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7ydjylquvaaayy_9ezes858.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] # #修改管理员的邮箱
650) this.width=650; "title=" clip_image048 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image048 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7ydjgjys3aaauly7mwiq711.jpg "width=" 244 "height=" "/>"
98 ServerName www.linuxfan.cn:80 # #添加网站的FQDN
650) this.width=650; "title=" clip_image050 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image050 "src=" http://s3.51cto.com/wyfs02/M00/86/4E/ Wkiol1e7ydyydvs3aaavteejdg8697.jpg "width=" 244 "height="/>
: Wq
[email protected] httpd]#/etc/init.d/httpd Start # #启动服务
HTTPD is start Complete.
650) this.width=650; "title=" clip_image052 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image052 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7ydyyldc7aaagfyo_k0a540.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; "title=" clip_image054 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image054 "src=" http://s3.51cto.com/wyfs02/M02/86/4E/ Wkiol1e7yd2sitlbaaa0u_y58m4206.jpg "width=" 244 "height=" 101 "/>
[email protected] httpd]# netstat-utpln |grep httpd # #查看监听
TCP 0 0::: +:::* LISTEN 73341/httpd
650) this.width=650; "title=" clip_image056 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image056 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7yd3sqhhqaaarv5gxi8s211.jpg "width=" 244 "height="/>
5. Access and Test:
[[email protected] ~]# yum-y Install ELinks # #在192.168.100.100 for testing
650) this.width=650; "title=" clip_image058 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image058 "src=" http://s3.51cto.com/wyfs02/M00/86/4F/ Wkiom1e7yd6antleaaajpi11w0c405.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; "title=" clip_image060 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image060 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7yegcerjlaaawz8qca54951.jpg "width=" 244 "height=" "/>"
[email protected] ~]# elinks--dump http://www.linuxfan.cn # #成功完成实验
It works!
650) this.width=650; "title=" clip_image062 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image062 "src=" http://s3.51cto.com/wyfs02/M01/86/4F/ Wkiom1e7yehzdoyjaaauubf87no287.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; "title=" clip_image063 "style=" border-left-0px; border-right-width:0px; background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image063 "src=" http://s3.51cto.com/wyfs02/M01/86/4E/ Wkiol1e7yelw-mrpaabmbupv-qm419.png "width=" 299 "height=" 162 "/>
Build a Web server experiment