1.软文推荐

2.软文推荐

3.软文推荐

 HTTP服务器一般是指网站服务器,是指某类计算机驻留在互联网的程序上,可以处理浏览器等Web客户端的请求并
返回相应的响应,也可以放置网站文件,让全世界浏览;三个最主流的 Web 服务器是Apache、Nginx和IIS。

1、配置IP

[root@localhost~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=static

ONBOOT=yes

HWADDR=00:0c:29:5d:a8:80

IPADDR=192.168.126.133

NETMASK=255.255.255.0

2、配置主机名

[root@localhost~]# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

HOSTNAME=web.gx.com

3、修改hosts文件

[root@localhost~]# cat /etc/hosts

127.0.0.1        localhost.localdomain localhost

::1       localhost6.localdomain6 localhost6

192.168.10.253 web.gx.com    web

[root@localhost~]# service network restart

[root@localhost~]# chkconfig network on

4、软件包的安装

[root@localhost~]# rpm -q httpd

package httpd is not installed

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

5、启动服务

[root@localhost~]# service httpd restart

[root@localhost~]# chkconfig httpd on

试验二:基本HTTP服务器的配置

  Web服务器域名:www.gx.com

  默认首页包括:index.html、index.*

  开启保持连接

  网站用自己的静态网页musicapp测试

服务器操作:

1、备份主配置文件

[root@localhost ~]# cd /etc/httpd/conf

[root@localhost conf]# cp httpd.conf httpd.conf.bak

2、修改主配置文件

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

74 KeepAlive On

265 ServerName www.gx.com:80

391 DirectoryIndex index.html index.php

3、启动服务

[root@localhost ~]# service httpd restart

[root@localhost ~]# chkconfig httpd on

将musicapp文件夹中的文件全部拷贝到/var/www/html/下

4.修改客户端hosts文件

192.168.126.133     www.gx.com

[root@localhost ~]# vim /etc/hosts

5.经测试发现通过本机IP192.168.126.133不能访问,网上查找后删除/etc/httpd/conf.d/welcome.conf

6.打开浏览器访问  http://www.gx.com

3、新建authdir站点,只允许某个IP192.168.126.135访问www.gx.com,允许所有人访问www.gx.com/authdir

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

[root@web ~]# echo “http://www.gx.com/authdir/index.html” > /var/www/html/authdir/index.html

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

337

338     Order allow,deny

339     Allow from all

340

[root@localhost ~]# service httpd restart

在不同客户端测试

[root@localhost ~]# tail /var/log/httpd/error_log

试验四:HTTP的用户授权

  客户端访问http://www.gx.com/authdir需要输入用户名密码验证

1、修改主配置文件

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

337

338     Order allow,deny

339     Allow from all

340     AuthName “Please Input Password!!”

341     AuthType Basic

342     AuthUserFile “/etc/httpd/.vuser”

343     Require valid-user

344

2、创建账户密码

[root@localhost ~]# htpasswd -c /etc/httpd/.vuser admin

New password:

Re-type new password:

Adding password for user admin

3、启动服务测试

[root@localhost ~]# service httpd restart

http://www.gx.com/authdir

实验五:HTTP目录别名

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

1、创建测试站点

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

[root@localhost ~]# cat /var/www/html/baidu.com/bbs/index.html

This is a test Page!!!

This is bbs.baidu.com test Page!!!

2、修改主配置文件

[root@localhost ~]# tail -n 1 /etc/httpd/conf/httpd.conf

Alias /baidu   “/var/www/html/baidu.com/bbs”

3、启动服务测试

[root@web01 ~]# service httpd restart

http://www.gx.com/baidu

实验六:查看默认HTTP使用进程管理方式    更改默认进程管理方式为worker模式

[root@localhost ~]# httpd -l

Compiled in modules:

core.c

prefork.c

http_core.c

mod_so.c

[root@localhost ~]# cd /usr/sbin/

[root@localhost sbin]# mv httpd httpd.prefork

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

[root@localhost sbin]# service httpd restart

[root@localhost sbin]# httpd -l

Compiled in modules:

core.c

worker.c

http_core.c

mod_so.c

试验七:部署Awstats统计Http访问日志

1、安装软件(软件在/usr/src下)

[root@localhost ~]# cd /usr/src/

[root@localhost src]# tar -zxvf awstats-7.1.tar.gz -C /usr/local/

[root@localhost src]# cd /usr/local/

[root@localhost local]# mv awstats-7.1/ awstats

[root@localhost local]# cd awstats/tools/

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

Config file path (‘none’ to skip web server setup):

> /etc/httpd/conf/httpd.conf  //输入apache的主配置文件

—–> Need to create a new config file ?

Do you want me to build a new AWStats config/profile

file (required if first install) [y/N] ? y  //生成awstats的配置文件

Your web site, virtual server or profile name:

> www.gx.com      //输入你的web服务器名字

Default: /etc/awstats

Directory path to store config file(s) (Enter for default):

>

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

Press ENTER to continue…

Press ENTER to finish…

2、修改主配置文件

[root@localhost tools]# vim /etc/awstats/awstats.www.gx.com.conf

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

[root@localhost tools]# mkdir /var/lib/awstats

3、将日志文件导入Awstats

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

[root@localhost tools]# crontab -l

———————————————-

输入该命令出现错误提示no crontab for root

这个问题非常简单,同样在 root 用户下输入 crontab -e 按 Esc 按: wq  回车

在输入 crontab -l 就没有问题了

主要原因是由于这个liunx服务器 第一次使用 crontab ,还没有生成对应的文件导致的,执行了 编辑(crontab -e)后 就生成了这个文件

———————————————-

[root@localhost tools]# service crond restart

[root@localhost tools]# chkconfig crond on

4、验证:

http://www.gx.com/awstats/awstats.pl?config=www.gx.com

补充:

通过html代码实现网页跳转功能

[root@localhost tools]# cat /var/www/html/awstats.html

验证:

http://www.gx.com/awstats.html

实验八:基于域名的虚拟主机

www.baidu.com  192.168.126.133  baidu网站

www.sohu.com  192.168.126.133  sohu网站

1、修改主配置文件新建一个配置文件(虚似主机配置专用)

[root@localhost ~]# vim /etc/httpd/conf.d/virt.conf

NameVirtualHost *:80

DocumentRoot /var/www/baidu

ServerName www.baidu.comE

rrorLog logs/www.baidu.com-error_log

CustomLog logs/www.baidu.com-access_log common

DocumentRoot /var/www/sohu

ServerName www.sohu.com

ErrorLog logs/www.sohu.com-error_log

CustomLog logs/www.sohu.com-access_log common

创建网站目录和文件

[root@localhost ~]# mkdir /var/www/{baidu,sohu}

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

www.baidu.com

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

www.sohu.com

[root@localhost ~]# service httpd restart

验证:先在客户端修改hosts文件

192.168.126.133     www.baidu.com

192.168.126.133     www.sohu.com

实验九:基于端口的虚拟主机

192.168.126.133:8081       baidu网站

192.168.126.133:8082       sohu网站

2、修改主配置文件新建一个配置文件(虚似主机配置专用)

[root@localhost ~]# vim /etc/httpd/conf.d/virt.conf

Listen 8081   //激活端口

Listen 8082

DocumentRoot /var/www/baidu

ServerName 192.168.126.133

ErrorLog logs/www.baidu.com-error_log

CustomLog logs/www.baidu.com-access_log common

DocumentRoot /var/www/sohu

ServerName 192.168.10.253

ErrorLog logs/www.sohu.com-error_log

CustomLog logs/www.sohu.com-access_log common

2、启动服务

[root@localhost ~]# service httpd restart

实验十:配置HTTP支持php

1、安装php

[root@localhost ~]# yum -y install php

[root@localhost ~]# cat /var/www/baidu/test.php

phpinfo();

?>

[root@localhost ~]# service httpd restart

测试:

http://192.168.126.133:8081/test.php

本次http服务器安装教程分享完毕,有疑问的地方可以在评论区留言啊。

以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你!

本文来源:www.lxlinux.net/479.html,若引用不当,请联系修改。

相关文章 8

1

傲游主机:全场8折,德国CU2低延迟大带宽vps,月付60元;香港CN2高防50G防御套餐,月付1 1分钟前

傲游主机最近很长的一段时间都非常低调,除了常规8折外也基本没有提供特别促销方案,不过商家提供相当多包括冷热门地区VPS主机,譬如...

2

二进制显示和处理文件工具:xxd 2分钟前

xxd命令跟hexdump比较相似,都是用来查看二进制文件的内容,不过用起来,xxd命令似乎更顺手一点,下面为大家详细讲解一下xxd命令。 xxd 介...

3

易探云:“夏日炎炎,有你真甜”活动,香港/韩国/美国/深圳云服务器优惠活动 4分钟前

易探云怎么样? 易探云8月份上线“夏日炎炎,有你真甜”活动,降价,降价,给云服务器降价降温了!购买易探云服务器月付送QQ音乐豪华版...

4

特网云:特价服务器热销!美国裸机云仅280元/月起,香港站群服务器,8c-253个ip,2000元/月起 6分钟前

特网云怎么样? 特网云服务器在硬件级别上实现云主机之间的完全隔离;采用高端服务器进行部署,同时采用集中的管理与监控,确保业务稳...

5

Linux终端查看图片具体方法 9分钟前

Linux终端如何查看图像?本篇文章将使用 ImageMagick 和 fim 命令 为大家演示一下Linux终端查看图片具体方法。 如何使用 display 命令从终端查看...

6

阿里云堡垒机一个月多少钱?阿里云堡垒机收费价格(云堡垒机功能包含) 11分钟前

阿里云堡垒机一个月多少钱? 阿里云堡垒机是云盾提供的一个核心系统运维和安全审计管控平台。云盾堡垒机集中了运维身份鉴别、账号管...

7

JVM内存溢出原因和解决方法 12分钟前

应用程序过度使用 finalizer。finalizer 对象不能被 GC 立刻回收。finalizer 由结束队列服务的守护线程调用,有时 finalizer 。 1. Java 堆空间 发生频...

8

kvmloc:香港/日本独立服务器 E3 E5系列,买一送一,月付440元起 15分钟前

kvmloc,成立于2016年。kvmloc和日主机同属一个公司,不过这个平台主要销售独立服务器,机房有日本、香港,价格都比较便宜。,商家主要销...