Linux下Apache服务器配置

相关包:
httpd-2.2.3-29.e15.i386.rpm                 //主程序包
httpd-devel-2.2.3-29.e15.i386.rpm        //开发程序包
httpd-manual-2.2.3-29.e15.i386.rpm     //手册文档
system-config-httpd-1.3.3.3-1.e15.noarch.rpm   //配置工具
注:安装时会出现依赖包问题,可用YUM安装来解决
   启用时需要配置防火墙来放行
 
开机自动加载:
chkconfig --level 3 httpd on 
 
配置实例:
例1:部门内搭建一台WEB服务器,采用的IP地址和端口为192.168.0.3:80,首页采用index.html文件。管理员E- mail地址为root@sales.com,网页的编码类型采用GB2312,所有网站资源都存放在/var/www/html目录下,并将 Apache的根目录设置为/etc/httpd目录。
编辑主配置文件httpd.conf
vim /etc/httpd/conf/httpd.conf    //编辑主配置文件
ServerRoot "/etc/httpd"             //设置Apache的主目录
Timeout 120                             //设置请求超时
Listen 80                                  //设置监听端口
ServerAdmin root@sales.com          //设置管理员邮箱
ServerName 192.168.0.3:80           //设置主机或IP
DocumentRoot "/var/www/html"      //设置Apache文档目录
DirectoryIndex index.html               //设置主页文件
AddDefaultCharset GB2312            //设置网站编码
编辑主页文件用作测试:
cd /var/www/html
echo "This is web test sample.">>index.html
chmod 705 index.html
重新加载服务:
service httpd restar
 
例2:假设Apache服务器具有192.168.0.2和19.16.0.3两个地址,然后配置Apache,把多个网站绑定在不同的IP地址上,访问服务器上不同的IP地址,就可以看到不同的网站。
(基于IP)
mkdir /var/www/ip1   /var/www/ip2           //创建两个主目录
编辑httpd.conf文件:
<Virtualhost 192.168.0.2>                      //设置虚拟主机的IP
   DocumentRoot /var/www/ip1                //设置虚拟主机的主目录
   DirectoryIndex index.html                    //设置主页文件
   ServerAdmin root@sales.com               //设置管理员邮箱
   ErrorLog  logs/ip1-error_log                 //设置错误日志的存放位置
   CustomLog  logs/ip1-access_log common       //设置访问日志的存放位置
</Virtualhost>
<Virtualhost 192.168.0.3>                      //设置相应的IP
   DocumentRoot /var/www/ip2
   DirectoryIndex index.html
   ServerAdmin root@sales.com
   ErrorLog  logs/ip2-error_log
   CustomLog  logs/ip2-access_log common
</Virtualhost>
 
(基于域名)
mkdir /var/www/smile   /var/www/long         //创建两个主目录
编辑httpd.conf文件:
<Virtualhost 192.168.0.3>                         //设置虚拟主机的IP
   DocumentRoot /var/www/smile                //设置虚拟主机的主目录
   DirectoryIndex index.html                       //设置主页文件
   ServerName www.smile.com                    //设置虚拟主机完全域名
   ServerAdmin root@sales.com                  //设置管理员邮箱
   ErrorLog  logs/smile-error_log                 //设置错误日志的存放位置
   CustomLog  logs/smile-access_log common     //设置访问日志的存放位置
</Virtualhost>
<Virtualhost 192.168.0.3>
   DocumentRoot /var/www/long
   DirectoryIndex index.html
   ServerName www.smile.com                     //设置虚拟主机完全域名
   ServerAdmin root@sales.com
   ErrorLog  logs/long-error_log
   CustomLog  logs/long-access_log common
</Virtualhost>
 
(基于端口)
mkdir /var/www/port8080   /var/www/port8090        //创建两个主目录
编辑httpd.conf文件:
Listen 8080
Listen 8090
<Virtualhost 192.168.0.3:8080>                            //设置相应的端口
   DocumentRoot /var/www/port8080                     //设置虚拟主机的主目录
   DirectoryIndex index.html                                  //设置主页文件
   ServerAdmin root@sales.com                             //设置管理员邮箱
   ErrorLog  logs/port8080-error_log                     //设置错误日志的存放位置
   CustomLog  logs/port8080-access_log common  //设置访问日志的存放位置
</Virtualhost>
<Virtualhost 192.168.0.3:8090>                          //设置相应的端口
   DocumentRoot /var/www/port8090
   DirectoryIndex index.html
   ServerAdmin root@sales.com
   ErrorLog  logs/port8090-error_log
   CustomLog  logs/port8090-access_log common
</Virtualhost>
 

[Linux]Linux下Apache服务器配置的更多相关文章

  1. Linux下Apache服务器配置

    Linux下Apache服务器配置 相关包: httpd-2.2.3-29.e15.i386.rpm                 //主程序包 httpd-devel-2.2.3-29.e15.i ...

  2. MAC下 Apache服务器配置

    今天做了一个注册登录提交的页面,后续操作需要用到后端的知识 php+Mysql,之前只是有些了解,现在开始具体操作了,首先从配置环境开始.查了好几篇文档与博客,了解了挺多知识. Mac下Apache服 ...

  3. 【linux】下Apache无法启动(8080端口被占用)

    Linux下8080端口被占用,apache无法启动. 打开终端输入netstat -lnp|grep 8080 发现竟然是tcp6 占用里,因此ipv6启用占用了端口. 1.打开/etc/sysct ...

  4. Linux系统下 Apache+PHP 环境安装搭建

    一.安装Apache2.2.221.到官网下载  http://httpd.apache.org/download.cgi ,选择相应的版本 可以先下载到windows系统中,上传到linux, 也可 ...

  5. linux环境下Apache+Tomcat集群配置

    写在前面 apache配置多个tomcat,实现请求分流,多个tomcat服务均衡负载,增加服务的可靠性.最近研究了一下,遇到许多问题,记录一下,方便以后查阅,不喜欢apache,nginx也是可以做 ...

  6. Linux环境下Apache ActiveMQ 基本安装

    原文链接:https://www.jianshu.com/p/1c017088aa95 在linux上安装mq,并映射到外网.1.Apache ActiveMQ安装基本条件请参考链接:2.下载Apac ...

  7. linux系统下apache服务的启动、停止、重启命令

    本文章简单的介绍了关于linux下在利用命令来操作apache的基本操作如启动.停止.重启等操作,对入门者不错的选择.本文假设你的apahce安装目录为 usr local apache2,这些方法适 ...

  8. Linux环境下Apache反向代理金蝶中间件Apusic集群

    操作系统:RedHat Enterprise Linux 5.6 文档参考:<金蝶Apusic应用服务器 帮助手册| IX. Apusic Http Server使用指南> 一.金蝶中间件 ...

  9. 基于Linux系统下Apache服务器的安装部署

    企业中常用的web服务,用来提供http://(超文本传输协议). web系统是客户端/服务器模式的,所以应该有服务器和客户端里两个部分.常用的服务器程序时Apache,常用的客户端程序是浏览器.ww ...

随机推荐

  1. 第 8 章 容器网络 - 054 - 准备 macvlan 环境

    准备 macvlan 环境 macvlan 本身是 linux kernel 模块,其功能是允许在同一个物理网卡上配置多个 MAC 地址,即多个 interface,每个 interface 可以配置 ...

  2. Top 命令解析

    TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止.比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系统中C ...

  3. every day a practice —— morning(3)

    "WeChat does not store any chat histories. They are stored only on users' phones, computers or ...

  4. 记 linux 下面初次使用的convert 工具完成拼长图功能

    今天,遇到了一个需要把大量图片合并到一个长图的功能.本来找了各种图片处理界顶顶大佬.. “PS(手动一张张 的加).光影魔术手(批处理功能没有看到拼图功能).美图秀秀(可以有个拼图,限制30张,而且需 ...

  5. Zabbix安装(debian,centos)

    lnmp和lamp架构搭建一键安装脚本下载地址:https://lnmp.org/download.html  https://github.com/teddysun/lamp/tree/master ...

  6. codeforces587a//Duff and Weight Lifting// Codeforces Round #326 (Div. 1)

    题意:一数列an,如果存在一个k,有2^(ai)+2^(aj)+......=2^k成立,那么一次能拿走ai,aj这些全部.问最少拿的次数. 太简单. 乱码 //#pragma comment(lin ...

  7. 51Nod-1441 士兵的数字游戏

    题目要求是求出a!/b!(a>=b)的结果,让其不断做除法,最多能做多少次.这个问题首先可以转化为求a!中所有质因子个数-b!中所有质因子个数.以前做过一道快速求某个阶乘对一个素数的因子个数的题 ...

  8. android -------- ConstraintLayout介绍 (一)

    ConstraintLayout 翻译为 约束布局,也有人把它称作 增强型的相对布局,由 2016 年 Google I/O 推出. 扁平式的布局方式,无任何嵌套,减少布局的层级,优化渲染性能.从支持 ...

  9. android------Eclipse Memory Analyzer (MAT)

    简单介绍 MAT(Memory Analyzer Tool),一个基于Eclipse的内存分析工具,是一个快速.功能丰富的JAVA heap分析工具,它可以帮助我们查找内存泄漏和减少内存消耗. 使用内 ...

  10. 模拟curl函数

    只要需要调用微信的网址,就需要模拟curl请求 $tokenUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_cr ...