linux源码安装apache2,CentOS7编译安装Apache2
在LAMP環(huán)境下對(duì)于服務(wù)的安裝是必不可少的,在linux環(huán)境下安裝軟件也有兩種不同的方式,一種是yum安裝當(dāng)然了不同的linux發(fā)行版本使用略有不同,另一種是通過(guò)編譯安裝,編譯安裝要比yum安裝要可控此,但是要比yum安裝略微麻煩些我們下面這種方式就是通過(guò)編譯安裝的方式安裝Apache2服務(wù)器軟件,如果你覺(jué)得麻煩可以使用類(lèi)似的yum方式哦!
安裝軟件運(yùn)行基礎(chǔ)
apr
下載地址
[root@localhost soft]# wget -i http://www-eu.apache.org/dist//apr/apr-1.6.3.tar.gz
解壓編譯安裝
解壓
[root@localhost soft]# tar -zxf apr-1.6.3.tar.gz && apr-1.6.3
編譯
[root@localhost apr-1.6.3]# ./configure --prefix=/usr/local/apr
安裝
[root@localhost apr-1.6.3]# make && make install
apr-util
下載地址
[root@localhost soft]# wget -i http://www-eu.apache.org/dist//apr/apr-util-1.6.1.tar.gz
解壓編譯安裝
解壓
[root@localhost soft]# tar -zxf apr-util-1.6.1.tar.gz && cd apr-util-1.6.1
編譯
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
安裝
[root@localhost apr-util-1.6.1]# make && make install
pcre
下載地址
[root@localhost soft]# wget -i https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
解壓編譯安裝
解壓
[root@localhost soft]# tar -zxf pcre-8.41.tar.gz && cd pcre-8.41
編譯
[root@localhost pcre-8.41]# ./configure --prefix=/usr/local/pcre
安裝
[root@localhost pcre-8.41]# make && make install
安裝Apache2
下載地址
[root@localhost soft]# wget -i http://www-us.apache.org/dist//httpd/httpd-2.4.29.tar.bz2
解壓編譯安裝
解壓
[root@localhost soft]# tar -jxf httpd-2.4.29.tar.bz2 && cd httpd-2.4.29
編譯
[root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
安裝
[root@localhost httpd-2.4.29]# make && make install
配置Apache2
修改配置文件
[root@localhost soft]# vim /usr/local/apache2/conf/httpd.conf
修改監(jiān)聽(tīng)端口號(hào)
Listen 8088
修改 ServerName
ServerName www.apache-host.dev:8088
修改項(xiàng)目目錄
DocumentRoot "/www/apache-host"
修改項(xiàng)目目錄具體參數(shù)
設(shè)置Apache2為L(zhǎng)inux服務(wù)并實(shí)現(xiàn)開(kāi)機(jī)自啟動(dòng)
添加Apache2配置文件 apachectl 到linux服務(wù)
拷貝文件并重命名
[root@localhost soft]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
將系統(tǒng)配置目錄下的 httpd 添加到 系統(tǒng)服務(wù)
[root@localhost soft]# chkconfig --add httpd
設(shè)置系統(tǒng)服務(wù) httpd 為開(kāi)機(jī)啟動(dòng)
[root@localhost soft]# chkconfig httpd on
檢測(cè)系統(tǒng)服務(wù) httpd 是否啟動(dòng)成功
查看系統(tǒng)服務(wù)狀態(tài)
[root@localhost soft]# chkconfig --list | grep httpd
系統(tǒng)服務(wù)狀態(tài)詳情
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
可見(jiàn)服務(wù)已經(jīng)在 第2 到 第5 運(yùn)行等級(jí)打開(kāi), 說(shuō)明系統(tǒng)服務(wù) httpd 已正常開(kāi)啟開(kāi)機(jī)啟動(dòng)
禁用系統(tǒng)服務(wù) httpd
禁用系統(tǒng)服務(wù)
[root@localhost soft]# chkconfig httpd off
禁用系統(tǒng)服務(wù)狀態(tài)
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
可見(jiàn)服務(wù)已經(jīng)在 第1 到 第6 運(yùn)行等級(jí)關(guān)閉, 說(shuō)明系統(tǒng)服務(wù) httpd 已正常關(guān)閉開(kāi)機(jī)啟動(dòng)功能
開(kāi)啟系統(tǒng)服務(wù)Apache2
[root@localhost soft]# systemctl start httpd.service
查看系統(tǒng)服務(wù)運(yùn)行狀態(tài)
[root@localhost soft]# systemctl status httpd.service
驗(yàn)證是否成功安裝Apache2
通過(guò)curl命令行檢測(cè)是否安裝成功
檢測(cè)
[root@localhost soft]# curl -I "http://127.0.0.1:8088"
結(jié)果
HTTP/1.1 200 OK
Date: Sun, 31 Dec 2017 18:23:24 GMT
Server: Apache/2.4.29 (Unix)
Content-Type: text/html;charset=ISO-8859-1
通過(guò)瀏覽器檢測(cè)是否安裝成功
總結(jié)
以上是生活随笔為你收集整理的linux源码安装apache2,CentOS7编译安装Apache2的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 路由器把密码忘了解决方法没有如何设置路由
- 下一篇: linux 提示符 异常,linux终端