Centos 下Apache(httpd) 安装过程
- 2019-03-28 22:46:00
- IDO老徐 原創
- 32499
其实,网上这块的部署文章非常多 。随便搜索,都有 。
这篇文章,老徐帮大家挑选几个比较重点的过程 & 命令 。
1. 有些linux 版本中已經預置了有Apache,並且已經是服務了,所有首先檢查系統中是否已經存在httpd的服務
1)先檢查服務器 上是否已经启动了此服务 。
命令如下
ps -ef|grep httpd
2)查看linux系統服務中有沒有httpd
chkconfig --list | grep httpd
3)如果有服務存在,那麽需要先關閉httpd服務自啓動
命令 chkconfig httpd off
4)停止httpd服務
命令 service httpd stop
5)再次查看,是否有進程存在
命令 ps -ef|grep httpd
6)如果有進程存在,關閉進程
命令 kill -9 pid
2. 卸載httpd
1)先檢查安裝包 的名字
命令 rpm -qa|grep httpd
[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
2)根据安裝包名字删除包
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文件
#先检查文件在哪 find / -name httpd.conf #查出之后根据路径逐一删除 rm /xxx/xxx/httpd.conf
3. 准备事项已完成,剩下的就是常规安装了 。
注:我们通过yum的方式,在线安装,非常简单 。
1)檢查是否存在httpd包
[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
yum install httpd
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!安裝過程,不用理會,如果看到如上提示,說明安裝成功了。
3、設置Apache服務的啓動級別
chkconfig --levels 235 httpd on
Apache是一個服務,所以,可以通過設置服務的啓動級別來讓它啓動。
4、啓動服務
兩種方式,
1)如下
/etc/init.d/httpd start
2)如下
service httpd start
5、查看服務是否正常啓動
兩種方式,
1)查看服務狀態
[root@istester www]# service httpd status httpd (pid 10339) is running...
2)查看進程
[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
補充,
1)停止服務
service httpd stop
2)重啓服務
service httpd restart
6、安裝之後的說明:
1)驗證是否安裝成功
现在打开http://ip 地址,看看有没有Apache的默认页面出来了?如果有就对了。
2)安裝目錄說明
Apache默認將網站的根目錄指向/var/www/html
默認的主配置文件是/etc/httpd/conf/httpd.conf
配置存儲在的/etc/httpd/conf.d/目錄
End
IDO老徐
全网同名,个人IP公衆號
日更10年,每天 1 分钟、解决 1 个问题
職場、副業、輕創業、寫作、個人IP
公衆號、視頻號、小红书、知乎
長按/掃碼,關注IDO老徐
關注回複 401 送你「十年原創资料包」
聯系人: | IDO老徐 |
---|---|
Email: | 957863300@qq.com |
QQ: | 957863300 |
微信: | 957863300 |
微博: | isTester |
網址: | idoxu.com |
地址: | 中国 · 广东 · 深圳 |
來源備注:老徐博客