• apache配置


    配置实例:
    例1:部门内搭建一台WEB服务器,采用的IP地址和端口为192.168.0.3:80,首页采用index.html文件。管理员E- mail地址为root@linuxidc.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@linuxidc.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@linuxidc.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@linuxidc.com
       ErrorLog  logs/ip2-error_log
       CustomLog  logs/ip2-access_log common
    </Virtualhost>
     
    (基于域名)
    mkdir /var/www/linuxidc  /var/www/long         //创建两个主目录
    编辑httpd.conf文件:
    <Virtualhost 192.168.0.3>                         //设置虚拟主机的IP
       DocumentRoot /var/www/linuxidc                //设置虚拟主机的主目录
       DirectoryIndex index.html                       //设置主页文件
       ServerName www.linuxidc.com                    //设置虚拟主机完全域名
       ServerAdmin root@linuxidc.com                  //设置管理员邮箱
       ErrorLog  logs/linuxidc-error_log                 //设置错误日志的存放位置
       CustomLog  logs/linuxidc-access_log common     //设置访问日志的存放位置
    </Virtualhost>
    <Virtualhost 192.168.0.3>
       DocumentRoot /var/www/long
       DirectoryIndex index.html
       ServerName www.linuxidc.com                     //设置虚拟主机完全域名
       ServerAdmin root@linuxidc.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@linuxidc.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@linuxidc.com
       ErrorLog  logs/port8090-error_log
       CustomLog  logs/port8090-access_log common
    </Virtualhost>

    Ubuntu Server 14.04 安装Web服务器(Linux+Apache+MySQL+PHP)  http://www.linuxidc.com/Linux/2015-06/119061.htm

    Linux下安装配置PHP环境(Apache2)  http://www.linuxidc.com/Linux/2015-05/118062.htm

    Ubuntu 13.04 安装 LAMPVsftpdWebminphpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

    CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

    RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

    Linux下Apache虚拟主机的配置  http://www.linuxidc.com/Linux/2016-04/130381.htm

    http://www.linuxidc.com/Linux/2016-06/132025.htm

  • 相关阅读:
    excel处理经纬度
    Bootstrap:弹出框和提示框效果以及代码展示
    c# 多张图片合成一张图片
    webapi------宿主程序
    git安装完设置成中文
    邮件帮助类
    IISHelper操作iis
    删除数组中的重复项
    SQL 、LINQ日前比较
    PostAsync与GetAsync
  • 原文地址:https://www.cnblogs.com/nyfz/p/8351042.html
Copyright © 2020-2023  润新知