首页 > 其他 > 详细

Apache服务器的创建

时间:2014-08-20 14:16:12      阅读:555      评论:0      收藏:0      [点我收藏+]

搭建Apache服务器

1.要求:

ZZSRV1.BIGCLOUD.LOCAL使用Apache来提供Web服务。

此服务器上单独安装180GB的磁盘,使用LVM来进行卷管理:

  • VG名称:DATAVG

  • 使用全部的80GB物理磁盘

  • 创建一个LVLV名称为LV1LV1使用VG的全部空间。

  • LV1文件系统为EXT4Mount Point/wwwroot。要求服务器启动时自动挂载

  • Web服务器上提供两个网站服务/wwwroot/www


域名

Root目录

备注

www.bigcloud.local

/wwwroot/www


crm.bigcloud.local

/wwwroot/crm

仅允许192.168.188.0/24的用户来访问

2.实验步骤:

2.1.磁盘配置

2.1.1添加80G磁盘 

bubuko.com,布布扣

查看一下磁盘信息,增加了sdb

# fdisk -l

 

Disk /dev/sda: 42.9 GB, 42949672960 bytes,83886080 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk label type: dos

Disk identifier: 0x0003c31b

 

  Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *        2048     1026047      512000  83  Linux

/dev/sda2         1026048    83886079   41430016   8e  Linux LVM

 

Disk /dev/sdb: 85.9 GB, 85899345920 bytes,167772160 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

 

 

sdb分区

# fdisk /dev/sdb

 

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): 8e

Changed type of partition ‘Linux raidautodetect‘ to ‘Linux LVM‘

 

# fdisk -l /dev/sdb

 

Disk /dev/sdb: 85.9 GB, 85899345920 bytes,167772160 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk label type: dos

Disk identifier: 0x9fecc949

 

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1            2048   167772159   83885056   8e  Linux LVM

 

创建pv

# pvcreate /dev/sdb1

 Physical volume "/dev/sdb1" successfully created

创建vg--DATAVG

# vgcreate DATAVG /dev/sdb1

 Volume group "DATAVG" successfully created

显示VG信息

# vgdisplay DATAVG

  ---Volume group ---

  VGName               DATAVG

 System ID

 Format                lvm2

 Metadata Areas        1

 Metadata Sequence No  1

  VGAccess             read/write

  VGStatus             resizable

  MAXLV                0

  CurLV                0

 Open LV               0

  MaxPV                0

  CurPV                1

  ActPV                1

  VGSize               80.00 GiB

  PESize               4.00 MiB

 Total PE              20479

 Alloc PE / Size       0 / 0

 Free  PE / Size       20479 / 80.00 GiB

  VGUUID              jwZL5m-TGmN-AGkh-PAxg-OEuZ-soie-l0Cbgk


创建lv--LV1,使用DATAVG的全部空间

# lvcreate -n LV1 -l 20479DATAVG

 Logical volume "LV1" created

展示LV具体信息

# lvdisplay /dev/DATAVG/LV1

  ---Logical volume ---

  LVPath                /dev/DATAVG/LV1

  LVName                LV1

  VGName                DATAVG

  LVUUID               EjNB6O-RD34-c01G-aDQY-n7oP-M7Jv-Y2VG54

  LVWrite Access        read/write

  LVCreation host, time zzsrv1.bigcloud.local, 2014-08-20 19:20:37 +0800

  LVStatus              available

  #open                 0

  LVSize                80.00 GiB

 Current LE             20479

 Segments               1

 Allocation             inherit

 Read ahead sectors     auto

  -currently set to     8192

 Block device           253:2


2.1.2 文件系统配置


格式化lv

# mkfs.ext4 /dev/DATAVG/LV1


创建挂载点/wwwroot

# mkdir /wwwroot


设置为自动挂载

# vi /etc/fstab

在最后添加如下:

/dev/DATAVG/LV1        /wwwroot                 ext4    defaults        0 0


lv挂载

# mount /wwwroot

# mount

会看到如下内容:

/dev/mapper/DATAVG-LV1 on /wwwroot typeext4 (rw,relatime,data=ordered)

 

2.2 安装包

# yum -y install httpd

 

# rpm -qc httpd

/etc/httpd/conf.d/autoindex.conf

/etc/httpd/conf.d/userdir.conf

/etc/httpd/conf.d/welcome.conf

/etc/httpd/conf.modules.d/00-base.conf

/etc/httpd/conf.modules.d/00-dav.conf

/etc/httpd/conf.modules.d/00-lua.conf

/etc/httpd/conf.modules.d/00-mpm.conf

/etc/httpd/conf.modules.d/00-proxy.conf

/etc/httpd/conf.modules.d/00-systemd.conf

/etc/httpd/conf.modules.d/01-cgi.conf

/etc/httpd/conf/httpd.conf

/etc/httpd/conf/magic

/etc/logrotate.d/httpd

/etc/sysconfig/htcacheclean

/etc/sysconfig/httpd


2.3 web服务配置 

# cd /etc/httpd/conf

先对配置文件进行备份

# cp httpd.confhttpd.conf.origin

# ps aux |grep httpd

root     2608  0.0  0.0 112640  968 pts/0    R+   19:33  0:00 grep --color=auto httpd

 

启动httpd服务

# systemctl start httpd

查看进程

# ps aux |grep httpd

root     2611  4.3  0.4 213688 4868 ?        Ss   19:33  0:00 /usr/sbin/http  -DFOREGROUND

apache   2612  0.0  0.2 213688 2856 ?        S    19:33  0:00 /usr/sbin/http  -DFOREGROUND

apache   2613  0.0  0.2 213688 2856 ?        S    19:33  0:00 /usr/sbin/http  -DFOREGROUND

apache   2614  0.0  0.2 213688 2856 ?        S    19:33  0:00 /usr/sbin/http  -DFOREGROUND

apache   2615  0.0  0.2 213688 2856 ?        S    19:33  0:00 /usr/sbin/http  -DFOREGROUND

apache   2616  0.0  0.2 213688 2856 ?        S    19:33  0:00 /usr/sbin/http  -DFOREGROUND

root     2618  0.0  0.0 112640  968 pts/0    R+   19:34  0:00 grep --color=auto httpd


在客户端浏览器上输入IP地址查看:

bubuko.com,布布扣 


创建两个网站的目录和测试页面

# mkdir /wwwroot/www

# echo"www.bigcloud.local" > /wwwroot/www/index.html

# mkdir /wwwroot/crm

# echo"crm.bigcloud.local" > /wwwroot/crm/index.html

 

配置虚拟主机

# cd /etc/httpd

[root@zzsrv1 httpd]# mkdir vhost-conf.d

[root@zzsrv1 httpd]# echo "Includevhost-conf.d/*.conf" >> conf/httpd.conf

[root@zzsrv1 httpd]#  vi vhost-conf.d/vhost-name.conf

添加如下内容

<VirtualHost  *:80>

   ServerName www.bigcloud.local

   DocumentRoot /wwwroot/www/

</VirtualHost>

<Directory  /wwwroot/www/>

    Require all granted

</Directory>

 

<VirtualHost  *:80>

   ServerName crm.bigcloud.local

   DocumentRoot /wwwroot/crm/

</VirtualHost>

<Directory  /wwwroot/crm/>

   Require ip 192.168.188.0/24

</Directory>

修改完后重启httpd服务

# systemctl restart httpd

在客户端浏览器上输入域名查看:

bubuko.com,布布扣

bubuko.com,布布扣

Apache服务器的创建,布布扣,bubuko.com

Apache服务器的创建

原文:http://wanyi.blog.51cto.com/9273880/1542490

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!