其實,網(wǎng)上這塊的部署文章非常多 。隨便搜索,都有 。
這篇文章,老徐幫大家挑選幾個比較重點的過程 & 命令 。
1. 有些linux 版本中已經(jīng)預(yù)置了有Apache,并且已經(jīng)是服務(wù)了,所有首先檢查系統(tǒng)中是否已經(jīng)存在httpd的服務(wù)
1)先檢查服務(wù)器 上是否已經(jīng)啟動了此服務(wù) 。
命令如下
ps -ef|grep httpd
2)查看linux系統(tǒng)服務(wù)中有沒有httpd
chkconfig --list | grep httpd
3)如果有服務(wù)存在,那么需要先關(guān)閉httpd服務(wù)自啟動
命令 chkconfig httpd off
4)停止httpd服務(wù)
命令 service httpd stop
5)再次查看,是否有進程存在
命令 ps -ef|grep httpd
6)如果有進程存在,關(guān)閉進程
命令 kill -9 pid
- 卸載httpd
1)先檢查安裝包 的名字
命令 rpm -qa|grep httpd
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester]~# rpm -qa|grep httpd
httpd-2.2.15-69.el6.centos.x86_64
httpd-tools-2.2.15-69.el6.centos.x86_64</pre>
2)根據(jù)安裝包名字刪除包
rpm -e httpd-tools-2.2.15-69.el6.centos.x86_64
rpm -e httpd-2.2.15-69.el6.centos.x86_64
3)刪除httpd.conf文件
<pre class="prettyprint" style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">#先檢查文件在哪
find / -name httpd.conf
查出之后根據(jù)路徑逐一刪除
rm /xxx/xxx/httpd.conf</pre>
3. 準(zhǔn)備事項已完成,剩下的就是常規(guī)安裝了 。
注:我們通過yum的方式,在線安裝,非常簡單 。
1)檢查是否存在httpd包
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[www@istester ~]$ yum list httpd
Loaded plugins: security
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 28 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.2 MB 00:00
Available Packages
httpd.x86_64 2.2.15-69.el6.centos base</pre>
2、安裝Apache
yum install httpd
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Total 20 MB/s | 932 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 1/4
Updating : httpd-tools-2.2.15-69.el6.centos.x86_64 2/4
Installing : httpd-2.2.15-69.el6.centos.x86_64 3/4
Cleanup : httpd-tools-2.2.15-53.el6.centos.x86_64 4/4
Verifying : httpd-tools-2.2.15-69.el6.centos.x86_64 1/4
Verifying : httpd-2.2.15-69.el6.centos.x86_64 2/4
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/4
Verifying : httpd-tools-2.2.15-53.el6.centos.x86_64 4/4
Installed:
httpd.x86_64 0:2.2.15-69.el6.centos
Dependency Installed:
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
Dependency Updated:
httpd-tools.x86_64 0:2.2.15-69.el6.centos
Complete!</pre>
安裝過程,不用理會,如果看到如上提示,說明安裝成功了。
3、設(shè)置Apache服務(wù)的啟動級別
chkconfig --levels 235 httpd on
Apache是一個服務(wù),所以,可以通過設(shè)置服務(wù)的啟動級別來讓它啟動。
4、啟動服務(wù)
兩種方式,
1)如下 /etc/init.d/httpd start
2)如下
service httpd start
5、查看服務(wù)是否正常啟動
兩種方式,
1)查看服務(wù)狀態(tài)
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester www]# service httpd status
httpd (pid 10339) is running...</pre>
2)查看進程
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester www]# ps -ef|grep httpd | grep -v grep
root 10339 1 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10341 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10342 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10343 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10344 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10345 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10346 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10347 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10348 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd</pre>
補充,
1)停止服務(wù)
service httpd stop
2)重啟服務(wù)
service httpd restart
6、安裝之后的說明:
1)驗證是否安裝成功
現(xiàn)在打開http://ip 地址,看看有沒有Apache的默認(rèn)頁面出來了?如果有就對了。
2)安裝目錄說明
Apache默認(rèn)將網(wǎng)站的根目錄指向/var/www/html
默認(rèn)的主配置文件是/etc/httpd/conf/httpd.conf
配置存儲在的/etc/httpd/conf.d/目錄
End
文 / IDO老徐