HTTPD

安裝httpd

# mkdir /mnt/cdrom/

# mount /dev/cdrom /mnt/cdrom/

mount: /dev/sr0 is write-protected,mounting read-only

# cd /mnt/cdrom/Packages/

# ls httpd*

httpd-2.4.6-17.el7.centos.1.x86_64.rpm

httpd-devel-2.4.6-17.el7.centos.1.x86_64.rpm

httpd-manual-2.4.6-17.el7.centos.1.noarch.rpm

httpd-tools-2.4.6-17.el7.centos.1.x86_64.rpm

 

需要安裝

因爲安裝httpd的時候還需要安裝它的依賴包

# rpm -Uvhhttpd-2.4.6-17.el7.centos.1.x86_64.rpmhttpd-tools-2.4.6-17.el7.centos.1.x86_64.rpm apr-1.4.8-3.el7.x86_64.rpmapr-util-1.5.2-6.el7.x86_64.rpm mailcap-2.1.41-2.el7.noarch.rpm

warning:httpd-2.4.6-17.el7.centos.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key IDf4a80eb5: NOKEY

Preparing...                         ################################# [100%]

Updating / installing...

  1:apr-1.4.8-3.el7                 ################################# [ 20%]

  2:apr-util-1.5.2-6.el7             ################################# [40%]

  3:httpd-tools-2.4.6-17.el7.centos.1################################# [60%]

  4:mailcap-2.1.41-2.el7            ################################# [ 80%]

  5:httpd-2.4.6-17.el7.centos.1     ################################# [100%]

 

 

配置

# 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

 

# cd /etc/httpd/conf

# ls

httpd.conf magic

# cp httpd.conf httpd.conf.origin

# more httpd.conf

查看配置文件  我們需要注意這個配置

DocumentRoot "/var/www/html"

特別注意這個配置

 

<Directory "/var/www">

   AllowOverride None

    #Allow open access:

   Require all granted

</Directory>

這是Apache 2.4的一個新的默認值,拒絕所有的請求!

 

啓動

# systemctl restart httpd.service

設置爲開機自啓

# systemctl enable httpd.service

ln -s'/usr/lib/systemd/system/httpd.service'

'/etc/systemd/system/multi-user.target.wants/httpd.service'

 

Windows計算機上使用瀏覽器訪問http://192.168.188.11/,成功

 

生產WEB站點配置

 

創建兩個網站的目錄結構及測試用頁面文件

# 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/

# mkdir vhost-conf.d

# echo "Includevhost-conf.d/*.conf" >> conf/httpd.conf

 

# vi/etc/httpd/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>

 

 

ZZ***V2上的LVM配置

添加一塊100G的硬盤

 

# fdisk -l

 

Disk /dev/sda: 21.5 GB, 21474836480 bytes,41943040 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: 0x00012974

 

  Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *        2048     1026047      512000  83  Linux

/dev/sda2         1026048    41943039   20458496   8e  Linux LVM

 

Disk /dev/mapper/centos-swap: 2147 MB,2147483648 bytes, 4194304 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 /dev/mapper/centos-root: 18.8 GB,18798870528 bytes, 36716544 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

 

添加100GB的磁盤。讓Linux系統掃描刷新磁盤配置:

# echo "- - -" >/sys/class/scsi_host/host0/scan

# echo "- - -" > /sys/class/scsi_host/host1/scan

# echo "- - -" >/sys/class/scsi_host/host2/scan

 

# fdisk -l

看到新的盤了

Disk /dev/sdb: 107.4 GB, 107374182400bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

 

 

 

LVM配置

 

# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, untilyou decide to write them.

Be careful before using the write command.

 

Device does not contain a recognizedpartition table

Building a new DOS disklabel with diskidentifier 0x9f7e87e9.

 

Command (m for help): n

Partition type:

  p   primary (0 primary, 0extended, 4 free)

  e   extended

Select (default p): p

Partition number (1-4, default 1):

First sector (2048-209715199, default2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G}(2048-209715199, default 209715199):

Using default value 209715199

Partition 1 of type Linux and of size 100GiB is set

 

Command (m for help): p

 

Disk /dev/sdb: 107.4 GB, 107374182400bytes, 209715200 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: 0x9f7e87e9

 

  Device Boot      Start        End      Blocks   Id System

/dev/sdb1            2048   209715199  104856576   83  Linux

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

創建PV

# pvcreate /dev/sdb1

 Physical volume "/dev/sdb1" successfully created

創建VG

# vgcreate DATAVG /dev/sdb1

 Volume group "DATAVG" successfully created

# 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               100.00 GiB

  PESize               4.00 MiB

 Total PE              25599

 Alloc PE / Size       0 / 0

 Free  PE / Size       25599 / 100.00 GiB

  VGUUID              QD993Y-7TyB-h3pd-VHaX-wTyC-5et0-Yx8mgI

 

 

# lvcreate -n LVSMB -L 40G DATAVG

 Logical volume "LVSMB" created

# lvcreate -n LVFTP -L 30G DATAVG

 Logical volume "LVFTP" created

 

查看VG是未使用PE數量

# vgdisplay DATAVG

  ---Volume group ---

  VGName               DATAVG

 System ID

 Format                lvm2

 Metadata Areas        1

 Metadata Sequence No  3

  VGAccess             read/write

  VGStatus             resizable

  MAXLV                0

  CurLV                2

 Open LV               0

  MaxPV                0

  CurPV                1

  ActPV                1

  VGSize               100.00 GiB

  PESize               4.00 MiB

 Total PE              25599

 Alloc PE / Size       17920 /70.00 GiB

 Free  PE / Size       7679 / 30.00 GiB

  VGUUID               xxKwGK-FDbT-elLy-yU7A-gKfj-j3hc-7Cq76o

 

將所有未使用的PE全部分配給最後一個LV

# lvcreate -n LVNFS -l 7679  DATAVG

 Logical volume "LVNFS" created

 

# vgdisplay DATAVG

  ---Volume group ---

  VGName               DATAVG

 System ID

 Format                lvm2

 Metadata Areas        1

 Metadata Sequence No  4

  VGAccess             read/write

  VGStatus             resizable

  MAXLV                0

  CurLV                3

 Open LV               0

  MaxPV                0

  CurPV                1

  ActPV                1

  VGSize               100.00 GiB

  PESize               4.00 MiB

 Total PE              25599

 Alloc PE / Size       25599 /100.00 GiB

 Free  PE / Size       0 / 0       全部使用完了

  VGUUID              xxKwGK-FDbT-elLy-yU7A-gKfj-j3hc-7Cq76o

 

# lvscan

 

 ACTIVE           '/dev/centos_zzsrv1/swap' [2.03 GiB] inherit

 ACTIVE           '/dev/centos_zzsrv1/root' [37.48 GiB] inherit

 ACTIVE           '/dev/DATAVG/LVSMB' [40.00 GiB] inherit

 ACTIVE           '/dev/DATAVG/LVFTP' [30.00 GiB] inherit

 ACTIVE           '/dev/DATAVG/LVNFS' [30.00 GiB] inherit

 

文件系統配置

創建文件

# mkfs.ext4 /dev/DATAVG/LVSMB

# mkfs.ext4 /dev/DATAVG/LVFTP

# mkfs.ext4 /dev/DATAVG/LVNFS

 

 

創建Mount Point

# mkdir /smb

# mkdir /ftp

# mkdir /nfs

 

# vi /etc/fstab

添加

/dev/DATAVG/LVSMB  /smb ext4 defaults  0 0

/dev/DATAVG/LVFTP  /ftp ext4 defaults  0 0

/dev/DATAVG/LVNFS  /nfs ext4 defaults  0 0

 

測試一下

# mount /smb/

# mount /ftp

# mount /nfs

# mount

 

在最後我們會看到

/dev/mapper/DATAVG-LVSMB on /smb type ext4(rw,relatime,data=ordered)

/dev/mapper/DATAVG-LVFTP on /ftp type ext4(rw,relatime,data=ordered)

/dev/mapper/DATAVG-LVNFS on /nfs type ext4(rw,relatime,data=ordered)

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章