當前時間 2019-10-24-10:53:12html
製做本地yum源apache
我用的VMware Workstationvim
系統環境: CentOS 7.5服務器
首先咱們先要掛載系統鏡像tcp
[root@laopa ~]#mount /dev/sr0 /media/ceshi
執行這條命令以前,先要確保你的/media/下 有ceshi 這個目錄 (建立目錄我就很少說了mkdir)
[root@laopa ~]#df ---查看有無掛載條目
[root@laopa ~]#rm -rf /etc/yum.repos.d/*
![搭建yum源 刪掉/etc/yum.repos.d/內的文件](http://static.javashuo.com/static/loading.gif)
在配置新yum倉庫的時候,咱們先刪除以前的配置文件
刪好以後,cd 到yum.repos.d/ 這個目錄裏建立一個配置文件 [root@laopa ~]#touch ceshi.repo //配置文件可爲*.repo [root@laopa ~]#vim ceshi.repo //編寫這個配置文件
[CentOS7.5]
name=CentOS7.5-ISO
baseurl=file:///media/ceshi --掛載鏡像的地址
enabled=1 ----開啓此倉庫 若爲0 關閉
gpgcheck=0 ----關閉校驗功能 若爲1 開啓測試
![搭建yum 配置yum](http://static.javashuo.com/static/loading.gif)
檢查yum 可否能夠使用 : yum repolist
![檢查yum 檢查yum](http://static.javashuo.com/static/loading.gif)
到這一步 , 咱們的本地yum源就搭建完成了!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------url
開始編譯安裝httpdspa
首先 httpd 須要依賴於 apr 和 apr-utilcode
因此 要先編譯安裝 apr 與 apr-utilhtm
下載系統環境依賴包:
# yum -y install pcre pcre-devel zlib zlib-devel apr-devel apr-util-devel
實現準備好這三個文件,並上傳到你的Linux 服務器上
tar -jxf apr-1.6.3.tar.bz2 tar -jxf apr-util-1.6.1.tar.bz2 tar -zxf httpd-2.4.41.tar.gz 解壓這些文件
![解壓文件 解壓文件](http://static.javashuo.com/static/loading.gif)
[root@laopa ~]#cd apr-1.6.3/ ---進入apr-1.6.3 目錄下 [root@laopa ~]#./configure --prefix=/usr/local/apr
---配置這個安裝包.並指明安裝到/usr/local/apr 目錄下 [root@laopa ~]#make && make install ----編譯並安裝
![檢查報錯 檢查報錯](http://static.javashuo.com/static/loading.gif)
能夠輸入 echo $? 檢查有無報錯
而後開始安裝apr-util
進入apr-util 文件夾 輸入./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
///配置apr-util 並指明安裝到/usr/local/apr-util 目錄下 指出他依賴文件apr 在哪一個目錄 配置完成以後 make && make install
繼續安裝httpd
進入解壓出來的httpd文件夾 ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
配置httpd文件 並指明安裝到/usr/local/httpd 目錄下 並指出他的依賴文件 apr 與 apr-util 都在哪一個目錄 而後編譯與安裝 make && make install
到這一步,httpd 就安裝好了
若是要啓動他的網頁服務
進入安裝到的httpd文件目錄
httpd/bin/ 裏 安裝好以後: httpd 文件夾裏 htdocs是放網頁文件的 , /usr/local/httpd/bin/ 目錄裏 apachectl 是啓動網頁服務的
在httpd/bin/ 裏 輸入
./apachectl -k start --啓動命令 ./apachectl -k stop --中止命令
![運行httpd 運行httpd](http://static.javashuo.com/static/loading.gif)
已經運行httpd 了
能夠輸入netstat -tanlp檢測80端口是否up
這裏咱們是編譯成功的
注:
若是到這步 還不能訪問網頁的同窗
請關閉Linux 的防火牆!
systemctl stop firewalld.service
------------------------------------------
下面是在線yum源安裝httpd
首先保證你的虛擬機能夠連通外網,設置參考https://www.cnblogs.com/laopa/p/WL.html
過程就尤爲簡單了,直接安裝httpd
安裝好以後
rpm -ql httpd ---檢查在哪一個目錄
這裏是在/var/www/html 這裏的
進入這個目錄
建立一個html文件 , touch index.html
編寫他 vi index.html
測試頁面編輯好以後保存退出
開啓httpd服務 , servic
若是不能訪問,直接關閉防火牆或放行80端口
關閉防火牆: # service firewalld stop
放行端口: # iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT
完