2014/06/16

RHEL 7 yum repository 安裝 Apache + PHP 網站服務

自從 RHEL 7 Release 之後,要測試及安裝軟體都變得很麻煩,剛剛就自己重製了一份 yum 的儲存庫來使用,至少在 CENTOS 7 正式版出來前先這樣撐著用巴。
建立方式可以參考之前的 RHEL5 的作法,到 7 版方式雷同。

請到你的 /etc/yum.repos.d/ 目錄下,建立一個 local.repo 檔案。
[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d 
[root@localhost yum.repos.d]# nano local.repo
[rhel7-server]
name = rhel7 server DVD 64bit
baseurl = http://mt.jangmt.com/rhel7/RHEL-7.0Server.x86_64/
enabled = 1
gpgcheck = 0 
[rhel7-support]
name = rhel7 support DVD 64bit
baseurl = http://mt.jangmt.com/rhel7/Supp-7.0RHEL-7Server.x86_64/
enabled = 1
gpgcheck = 0

裝好後安裝個 apache + PHP 服務在 RHEL7 上面巴。

因為 CENTOS7 已經正式出現了,所以可以直接使用 CENTOS7 的 REPO 當作系統的軟體來源:

目前系統 CentOS 7 的主要 REPO 檔案如下:
[root@mtchang yum.repos.d]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

如果沒問題就可以直接安裝了。

apache 安裝
[root@localhost ~]# yum -y install httpd httpd-devel httpd-manual

檢查 php 是否有安裝 ,如果沒有請使用 yum 安裝下列套件
[root@localhost ~]# yum -y install php-mysql php-mbstring \
php-soap php-xml php-mcrypt php-pear php-cli php-devel php-gd

啟動 apache 現在已經改成 systemctl 指令來控制了。
[root@localhost ~]# /bin/systemctl restart  httpd.service

測試... http://localhost/



這個版本已經變更為 Apache 2.4 了,如果你沒有出現這個畫面我猜可能是預設開啟的防火牆擋住了,先暫時用圖形界面把它關掉就好了。指令要關掉有點麻煩,用圖形比較快。

補充說明:
EPEL7 也有出現了,可以直接到 https://fedoraproject.org/wiki/EPEL 這個網站抓取 rpm 安裝 REPO設定。裝完後應該長的類似如下:

[root@mtchang yum.repos.d]# cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

沒有留言: