查看CentOS上Apache位置,版本,停止,启动

查看Apache是否被安装:

[root@asg11 ~]# find / -name 'httpd'
/etc/sysconfig/httpd
/etc/httpd
/etc/logrotate.d/httpd
/etc/rc.d/init.d/httpd
/var/run/httpd
/var/log/httpd
/var/lock/subsys/httpd
/usr/sbin/httpd
/usr/lib64/httpd

查看版本查看Apache版本,首先进入httpd所在目录

[root@xxx ~]# cd /etc/httpd
[root@xxx httpd]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Aug 13 2013 17:29:28

停止httpd
[root@xxx httpd]# service httpd stop
Stopping httpd:      [  OK  ]

启动httpd
[root@xxx httpd]# service httpd start
Starting httpd:        [  OK  ]

重启httpd
[root@xxx httpd]# service httpd restart
Stopping httpd:      [  OK  ]
Starting httpd:        [  OK  ]

测试配置
找到配置文件,打开找到默认web目录。
Apache的重要配置文件httpd.conf的位置在/etc/httpd/conf/httpd.conf

我们来写一个php文件(html也可)。我写的是index.php,保存在html目录中。

<?php
echo 'ahha</br>';
echo PHP_VERSION.'</br>';
echo 'http://'.$_SERVER['HTTP_HOST'];
?>

直接访问IP即可

配置域名
#ServerName www.example.com:80
ServerName www.xxx.com

配置web目录(根目录)
#DocumentRoot "/var/www/html"
DocumentRoot "/web"

配置web目录(根目录)
#<Directory "/var/www/html">
<Directory "/web">

配置域名虚拟主机
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
    ServerName www.xxx.com
    DocumentRoot "/web"
</VirtualHost>
 

错误排查

如果确保一切操作正确,但访问时超时或有什么错误,需检查服务器安全组规则端口是否允许

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

马志武

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值