Linux 中 Apache 的常用配置命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 中 Apache 的常用配置命令相关的知识,希望对你有一定的参考价值。

一 Apache的配置安装
1.安装前卸载rpm包
rpm -e httpd --nodeps
2.编译安装4步骤:
(1)tar zxf httpd-2.2.17.tar.gz -C /usr/src/
(2)cd /usr/src/httpd-2.2.17
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
(3)make && make install
3.优化路径
ln -s /usr/local/httpd/bin/* /usr/local/bin/
4.添加系统服务
(1)cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
(2)vim /etc/init.d/httpd

chkconfig: 35 85 15

    # description: Startup script for the Apache HTTP Server

(3)chkconfig --add httpd
5.apache访问日志
/usr/local/httpd/logs/access_log

二 Apache的虚拟主机
1.启用基于域名的虚拟主机
vim /usr/local/httpd/conf/httpd.conf
定位到388行,去除“#”号
conf/extra/httpd-vhosts.conf
2.配置虚拟主机文件
vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
NameVirtualHost :80
<VirtualHost
>
DocumentRoot /var/www/html/benetcom
ServerName www.benet.com
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/html/accpcom
ServerName www.accp.com
</VirtualHost>
3.重启配置文件
/usr/local/httpd/bin/apachectl restart

以上是关于Linux 中 Apache 的常用配置命令的主要内容,如果未能解决你的问题,请参考以下文章

Linux的常用命令

Linux Apache httpd服务常用命令

linux 常用命令

linux下apache解析不了php文件

Apache RocketMQ在linux上的常用命令

Linux学习笔记-常用命令