Building a Web server

Source: Internet
Author: User
Tags install openssl nameserver

1. Environment Readiness:
Using the CTOS1 virtual machine, open and confirm that the IP address is 192.168.100.150, the gateway is 192.168.100.100,dns to 192.168.100.100.
Set host Name:
[Email protected] ~]# Cat/etc/sysconfig/network # #设置主机的FQDN
Networking=yes
hostname=www.linuxfan.cn
: Wq
[email protected] ~]# reboot

Log on to 192.168.100.100 to add the DNS resolution of the host, if it has been added can not be set:
[Email protected] ~]# Vim/var/named/chroot/var/named/linuxfan.cn.zone
www in A 192.168.100.150
: Wq
[Email protected] ~]# Vim/var/named/chroot/var/named/192.168.100.arpa
In PTR www.linuxfan.cn.
: Wq
/etc/init.d/named restart
[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

[Email protected] ~]#
2. Download the software and install: Login 192.168.100.150
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
2) Unzip and install:
Mount/dev/cdrom/mnt
Yum-y Install Openssl-devel # #安装openssl-devel provides HTTPS support
[Email protected] ~]# tar zxvf httpd-2.2.17.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/httpd-2.2.17/
[Email protected] httpd-2.2.17]#/configure--prefix=/usr/local/httpd--enable-so--enable-rewrite--enable-cgi-- Enable-ssl && make &&make Install
[[email protected] httpd-2.2.17]# echo $? # #返回0为成功
0
[Email protected] httpd-2.2.17]# ls/usr/local/httpd/# #安装成功
Bin Cgi-bin error icons lib man modules
Build conf htdocs include logs manual
[Email protected] ~]# CD/USR/LOCAL/HTTPD
3. Post-Installation optimization and adjustment:

[Email protected] httpd]# ln-s/usr/local/httpd/bin/*/usr/local/bin/# #优化执行命令的路径
[Email protected] httpd]# CP/USR/LOCAL/HTTPD/BIN/APACHECTL/ETC/INIT.D/HTTPD
[[email protected] httpd]# VIM/ETC/INIT.D/HTTPD # #在开始位置修改bash和添加chkconfig和description; modifying line 82nd implements friendly hints when executing commands
1 #!/bin/bash # #声明shell为bash
2 # chkconfig:35 # #在3和5运行级别开机启动, boot start sequence is 85, shut down sequence is 15
3 # description:a Scripts for Apache httpd deamon!
$HTTPD-K $ARGV &&echo "HTTPD is $ARGV complete." # #第82行
: 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
[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

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
[Email protected] httpd]#/etc/init.d/httpd start # #启动服务
HTTPD is start complete.
[[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
[Email protected] httpd]# NETSTAT-UTPLN |grep httpd # #查看监听
TCP 0 0::: +:::* LISTEN 73341/httpd

5. Access and test:
[[email protected] ~]# yum-y install ELinks # #在192.168.100.100 for testing
[Email protected] ~]# vi/etc/resolv.conf
; Generated By/sbin/dhclient-script
NameServer 192.168.100.100 # #添加DNS服务器
NameServer 192.168.3.5 # #不必修改, this DNS server automatically obtains the DNS server for the bridge adapter to be able to get on the public network
[Email protected] ~]# elinks--dump http://www.linuxfan.cn # #成功完成实验
It works!
Windows hosts use IE or Chrome (Google), Firefox (Firefox) and other browsers to access:
http://www.linuxfan.cn

This article is from the "11982647" blog, please be sure to keep this source http://11992647.blog.51cto.com/11982647/1869690

Building a Web server

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.