Apache服务器配置--Linux

相关包:

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地址为[email protected],网页的编码类型采用GB2312,所有网站资源都存放在/var/www/html目录下,并将Apache的根目录设置为/etc/httpd目录。

编辑主配置文件httpd.conf

vim /etc/httpd/conf/httpd.conf    //编辑主配置文件

ServerRoot "/etc/httpd"             //设置Apache的主目录

Timeout 120                             //设置请求超时

Listen 80                                  //设置监听端口

ServerAdmin [email protected]          //设置管理员邮箱

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 [email protected]               //设置管理员邮箱

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 [email protected]

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 [email protected]                  //设置管理员邮箱

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 [email protected]

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 [email protected]                             //设置管理员邮箱

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 [email protected]

ErrorLog  logs/port8090-error_log

CustomLog  logs/port8090-access_log common

</Virtualhost>

时间: 2024-08-07 04:31:36

Apache服务器配置--Linux的相关文章

Apache服务器配置-2

服务器IP地址为:192.168.124.222 目标: 在浏览器中输入 192.168.124.222/private,能够成功访问到所配置的主页面. 在浏览器中输入"192.168.124.222/private"如下所示: 我主页面如下: Apache服务器配置-2,布布扣,bubuko.com

Mac下Apache服务器配置

Mac下Apache服务器配置 一.Apache服务器 1. 使用最广的 Web 服务器 2. Mac自带,只需要修改几个配置就可以,简单,快捷 3. 有些特殊的服务器功能,Apache都能很好的支持 目的:让有一个自己专属的测试环境 二.准备工作 1.设置用户密码 2.MAC 10.10及以上 三.配置服务器(此过程会用到vim命令,建议先了解一下) 1.常见命令 sudo apachectl -v //一般来说Mac系统都会自带Apache环境,此命令的用处是查看当前系统的Apache版本

转载 Apache服务器配置之个人主页

Apache服务器配置之个人主页 如果你有心留意一些提供服务器托管的网站,你会发现这些网站都提供一些个人主页空 间的服务.也许,你很羡慕他们,以为这是一个很了不起的技术.其实,只要学习,你也可以完成这个项目. 下面,我们就将开始学习怎么样来实现www服务的这一功能.个人主页空间,说白了就是开启一个硬盘空间给网络用户,供用户上传网页并可以访问该网页.对于apache来讲,需要开启一下参数和相关的个人目录区块: #UserDir public_html 找到这行,并将前面的注释符号"#"去

MAC下 Apache服务器配置

今天做了一个注册登录提交的页面,后续操作需要用到后端的知识 php+Mysql,之前只是有些了解,现在开始具体操作了,首先从配置环境开始.查了好几篇文档与博客,了解了挺多知识. Mac下Apache服务器配置 在Mac系统下配置php运行环境 原文地址:https://www.cnblogs.com/knuzy/p/9249116.html

linux下Apache服务器配置虚拟域名

在看laravel的某一个入门教程的时候,作者写道: 将网站根目录配置为 learnlaravel5/public. 本身而言,linux下Apache的根目录设置为/var/www/html,而laravel设置的访问目录是learnlaravel5/public.直接放在根目录下面,则访问打时候需要输入一长串,太麻烦.所以想着也配置下,跟作者似的,输入个www.nine.com也能访问. 1. 修改httpd.conf 可以直接在Apache配置文件的结尾添加如下代码,给Apache添加虚拟

linux apache服务器配置虚拟主机

楼主用的是阿里云 配置虚拟主机需要在 /alidata/vhosts/default.conf文件中加以下内容 <VirtualHost *:80> DocumentRoot /alidata/www/default/baby ServerName www.nixiaofeng.xyz ServerAlias www.nixiaofeng.xyz <Directory "/alidata/www/default/baby">     Options Indexe

squid代理服务器配置 linux

squid 配置 linux squid是linux下的一款代理服务器软件,他可以共享网络 ,加快访问速度,节约通信带宽,同时防止内部主机受到攻击,限制用户访问,完善网络管理 rpm -qa|grep squid yum install squid squid-2.6.STABLE21-3.el5 cd /etc/squid/ [[email protected] squid]# lscachemgr.conf  mib.txt            msntauth.conf         

CentOS 下的apache服务器配置与管理

一.WEB服务器与Apache1.web服务器与网址 2.Apache的历史 3.补充http://www.netcraft.com/可以查看apache服务器的市场占有率同时必须注意的是ngnix,正处于强势增长的上升时期,大有和apache一争天下的感觉,真是后生可畏~~~ 二.Apache服务器的管理命令1.命令启动:service httpd start/stop/restart/reload/condrestart/status/configtest/graceful/help2.脚本

部署bugzilla(bugzilla+apache+mysql+linux)

工作原因,需要部署bugzilla.在此,容我新造个轮子.官方轮子:https://bugzilla.readthedocs.org/en/latest/installing/quick-start.html 一.准备工作 所需文件: bugzilla    版本bugzilla-5.0.2,传送门:https://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-5.0.2.tar.gz bugzilla模块依赖(非必要,如果gd模块不成功,需