Apache 的安装与实践

Apache 的安装

命令:
          yum install -y httpd
          yum install -y elinks    # elinks 在命令行网页的显示
          service  httpd start    # 启动服务器
          chkconfig  httpd on

         netstat  -antup  | grep  :80     # 查看80端口
         wc -l /etc/httpd/conf/httpd.conf     #查看这个配置文件有多少行

修改配置文件:
 vim /etc/httpd/conf/httpd.conf
          用Ctrl+g 切换到配置文件的最后进行修改
          <Virtualhost       *:80>
Documentroot  /www/docs/dummy-host.example.com   #web 服务器的路径
  Servernameroot dummy-host.example.com  # web网址
Errorlog  logs/dummy-host.example.com #错误日志的存放路径
 </Virtualhost>
修改完配置文件后保存退出    :wq
service httpd restart #启动配置文件

域名解析:
vim /etc/hosts      #进入配置文件进行域名解析
   192.168.0.1    www.baidu.com
网页内容的写入:
echo   (写入的内容) > /var/www/html/index.html

设置网卡子接口或者虚拟网卡:
ifconfig

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0  #添加一块子网卡

vim /etc/sysconfig/network-scripts/ifcfg-eth0:0       #进入子网卡的文件进行IP网关的配置
DEVICE="eth0:0"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.1.11"
NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"
DNS1="192.168.0.1"


service network restart
ifconfig      #查看Ip


vim /etc/httpd/conf/httpd.conf       #  进入Web文件配置

  <VirtualHost 192.168.0.1:80>
      DocumentRoot /var/www/web1
      ServerName www.baidu.com
      Errorlog logs/www.baidu.com-error_log
      Customlog logs/www.baidu.com_log common
  </VirtualHost>
  <VirtualHost 192.168.0.11:80>
      DocumentRoot /var/www/web2
      ServerName www.souhu.com
  </VirtualHost>

service httpd restart      #启动服务

vim /etc/hosts   #域名解析
192.168.0.1 www.baidu.com
192.168.0.11 www.souhu.com



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值