linux 配置http服务,Linux配置HTTP服务【实验】

实验名称:配置http服务并运用

实验过程:

步骤1:基本环境

一台linux服务器,一台linux主机,一台windows主机

将两台主机的hostS文件添加一条 192.268.4.253www.tarena.com以便实验

步骤2:安装http软件包,

[root@dc ~]# yum -y install httpd

。。。

Installed:

httpd.x86_64 0:2.2.3-74.el5

Complete!

[root@dc ~]#

启动服务并设为开机启动

步骤3:让网页可以被访问

[root@dc ~]# service httpd start

启动 httpd:httpd: apr_sockaddr_info_get() failed for dc

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

[确定]

[root@dc ~]# chkconfig httpd on

[root@dc ~]#

访问发现时一个红帽的广告页面,其实就等于没访问到,下面为网站添加默认主页并设置一些内容

[root@dc ~]# vim /var/www/html/index.html

[root@dc ~]# cat /var/www/html/index.html

this is a page

[root@dc ~]#

测试发现可以访问

步骤4:限制一些用户访问

332     Order allow,deny

333     #Allow from all

334     allow from 192.168.4.1

这样就只允许192.168.4.1用户访问了,重启服务我们可以测试一下,发现其他Ip访问仍是错误页面

步骤5:为authdir添加所有人可以访问

同时我们还可以添加某一个页面允许所有人访问

进入配置文件

338     Order deny,allow

339

保存退出重启服务

[root@dc ~]# vim /etc/httpd/conf/httpd.conf

[root@dc ~]# mkdir /var/www/html/authdir

[root@dc ~]# cp /var/www/html/index.html /var/www/html/authdir/

[root@dc ~]# echo this is authdir > /var/www/html/authdir/index.html

[root@dc ~]#

测试

发现时可以的

步骤6:HTTP的用户授权

很多时候我们管理员需要用浏览器登入后台,这样就需要为登入的用户设置密码,下面设置

首先修改配置文件

337

338     Order deny,allow

339     authname "input password!"

340     authtype basic

341     authuserfile /etc/httpd/.vuser

342     require valid-user

343

存退重启服务并创建密码

[root@dc ~]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:httpd: apr_sockaddr_info_get() failed for dc

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

[确定]

[root@dc ~]# vim /etc/httpd/conf/httpd.conf

[root@dc ~]# htpasswd -c /etc/httpd/.user admin

New password:

Re-type new password:

Adding password for user admin

[root@dc ~]#

测试,输入用户名密码可以登入

步骤7:HTTP目录别名

客户端访问http://www.tarena.com/sina时可以访 问/var/www/html/sina.com/bbs下的网页

这个超简单,创建好目录和文件,为配置文件添加一条命令就好

[root@dc ~]# mkdir -p /var/www/html/sina.com/bbs

[root@dc ~]# cp /var/www/html/index.html /var/www/html/sina.com/bbs/

[root@dc ~]# echo this is sina > /var/www/html/sina.com/bbs/index.html

[root@dc ~]# echo alias /sina /var/www/html/sina.com/bbs >>/etc/httpd/conf/httpd.conf

[root@dc ~]# service httpd restart

测试发现可用

实验三

实验名称:部署Awstats统计Http访问日志

[root@dc src]# ls

aria2-1.17.1  debug         kernels               webmin-1.630

awstats-7.1   httpd-2.2.25  vmware-tools-distrib

[root@dc src]# history4

1059  tar zxvf awstats-7.1.tar.gz -C /usr/src

1060  cd /usr/src

1061  ls

1062  history4

[root@dc src]#

这样就把包解压到了指定目录下面进行安装

[root@dc src]# mv awstats-7.1/ /usr/local/awstats

[root@dc src]# cd /usr/local/awstats/tools/

[root@dc tools]# ./awstats_configure.pl

。。。

[root@dc tools]# vim /etc/awstats/awstats.www.tarena.com.conf

打开配置文件

51 LogFile="/var/log/httpd/access_log"

存退

[root@dc tools]# ./awstats_updateall.pl now

[root@dc tools]# crontab -e

*/5 * * * */usr/local/awstats/tools/awstats_updateall.pl now

[root@dc tools]# service crond restart

停止 crond:                                               [确定]

启动 crond:                                               [确定]

[root@dc tools]# chkconfig crond on

[root@dc tools]#

第三步的时候出现这样的错误,Error: Couldn't open server log file "/var/log/httpd/mylog.log" :没有那个文件或目录

Setup ('/etc/awstats/awstats.httpd.conf' file, web server or permissions) may be wrong.

创建之,导入之,,发现可用,我也不知道对不对

实验名称:更改默认进程管理方式为worker模式

[root@dc sbin]# cd /usr/sbin

[root@dc sbin]# mv httpd httpd.prework

[root@dc sbin]# mv httpd.worker httpd

[root@dc sbin]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:httpd: apr_sockaddr_info_get() failed for dc

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

[确定]

[root@dc sbin]#

[root@dc sbin]# httpd -l

Compiled in modules:

core.c

worker.c

http_core.c

mod_so.c

[root@dc sbin]#

实验完成,都不许需要测试,结果显示。

实验结果:这个服务比较常用,同样秒杀之,,多说几句,配置的时候总会出现这样活着那样的错误,别想着重装,也别想着一步到位,试验期间错了就大胆的改这样才能积累经验工作中少犯错,也别考虑改的对不对,反正做出来就好嘛

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值