這篇文章給大家分享的是centos7中升級apache版本的方法,相信大部分人都還沒學會這個技能,為了讓大家學會,給大家總結了以下內容,話不多說,一起往下看吧。
第一步:找出默認軟件庫上的Apache版本
為了查找Centos上軟件庫里的Apache版本,在命令行下輸入以下指令:
yum info httpd
如果你的centos保持著默認的配置的話,你很可能會按到類似的結果:
[root@crosp ~]# yum info httpd Loaded plugins: fastestmirror epel/x86_64/metalink | 19 kB 00:00 epel | 4.3 kB 00:00 (1/3): epel/x86_64/group_gz | 170 kB 00:00 (2/3): epel/x86_64/primary_db | 4.6 MB 00:00 (3/3): epel/x86_64/updateinfo | 780 kB 00:00 Loading mirror speeds from cached hostfile * base: mirrors.ircam.fr * epel: mirrors.ircam.fr * extras: centos.mirror.fr.planethoster.net * updates: centos.mirror.fr.planethoster.net Available Packages Name : httpd Arch : x86_64 Version : 2.4.6 Release : 45.el7.centos.4 Size : 2.7 M Repo : updates/7/x86_64 Summary : Apache HTTP Server URL : http://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
正如你從上面的輸出結果中看到,默認軟件庫中只有2.4.6版本的apache。
注意:
Centos使用 向后修復安全實踐 來將新的軟件修復應用到更早期的版本。所以,默認庫中的早期版本軟件不意味著就更脆弱。不過對于我來說,并不算是個滿足需求的更新。
你可以使用changelog來查看版本更新:
sudo yum install yum-changelog yum changelog httpd
第二步:安裝CodeIT庫
CodeIT的人提供了一個很好的自定義庫。這個庫提供了最新版本的服務器軟件(Apache & Nginx)。
在安裝CodeIT庫之前,你需要開啟 EPEL 。EPEL提供了CodeIT庫需要的依賴。
sudo yum install -y epel-release
最后,我們來安裝CodeIT庫
cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo
接下來,我們再次確認Apache的包版本,你應該會看到類似下面的輸出
[root@crosp ~]# yum info httpd Loaded plugins: changelog, fastestmirror Loading mirror speeds from cached hostfile * base: centos.crazyfrogs.org * epel: mirror.23media.de * extras: mirrors.ircam.fr * updates: centos.mirror.fr.planethoster.net Available Packages Name : httpd Arch : x86_64 Version : 2.4.25 Release : 3.el7.codeit Size : 1.4 M Repo : CodeIT/x86_64 Summary : Apache HTTP Server URL : http://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
第三步:安裝Apache
現在你應該有了安裝最新版apache所需要的所有東西:
yum install httpd
一旦Apache安裝好,我們就可以測試apache是否正常工作:
[root@crosp ~]# systemctl start httpd
輸出應該是類似下圖:
[root@crosp ~]# curl localhost <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Test Page for the Apache HTTP Server on CentOS</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> ...
最后,讓systemctl將Apache設置為開機自啟動:
[root@crosp ~]# systemctl enable httpd
以上就是centos7中升級apache版本的方法,詳細使用情況還需要大家自己親自動手使用過才能領會。如果想了解更多相關內容,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。