安装Apache

yum安装Apache

#yum -y install httpd
检查安装:
#rpm -qa|grep httpd

启动/停止/重新启动/状态
service httpd start
service httpd stop
service httpd restart
service httpd status

配置Apache

启动时,如果提示如下信息:
正在启动 httpd:httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName
编辑/etc/httpd/conf/httpd.conf
找到如下内容:
#ServerName www.example.com:80
更改为
ServerName localhost:80
再重启一下Apache服务即可;

测试安装配置是否成功
http://ip地址
如果出来:Apache 2 Test Page powered by CentOS 说明就OK了

默认安装目录:
/etc/httpd
默认主页目录:
/var/www/html
如果目录中没有index.html,则自行创建,否则显示下面页面内容:
/var/www/error/noindex.html
日志:
/var/log/httpd/

卸载Apache

#rpm -e --nodeps httpd

源码安装Apache

下载Apache安装包:
http://httpd.apache.org/
httpd-2.4.27.tar.gz

安装依赖包:
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz

#tar -zxf apr-1.4.5.tar.gz
#cd apr-1.4.5
#./configure --prefix=/usr/local/apr
#make && make install

#tar -zxf apr-util-1.3.12.tar.gz
#cd apr-util-1.3.12
#./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
#make && make install

#tar -zxf httpd-2.4.27.tar.gz
#cd httpd-2.4.27
#./configure --prefix=/usr/local/apache/ --with-apr-util=/usr/local/apr-util --with-apr-util=/usr/local/apr-util
#make && make install

或:
#./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc/ --with-included-apr --enable-dav --enable-so --enable-deflate=shared --enable-exprires=shared --enable-rewrite=shared && make && make install

如果报错:
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

则去www.apache.org下载apr-和apr-util-
然后cp到httpd安装目录:
#cp -rf apr-1.5.2 /usr/local/src/httpd-2.4.18/srclib/apr
#cp -rf apr-util-1.5.4 /usr/local/src/httpd-2.4.18/srclib/apr-util

开启或关闭

/usr/local/apache/bin/apachectl start | stop |restart
或:/usr/sbin/apachectl
开机启动
#vi /etc/rc.d/rc.local
/usr/local/apache2/bin/apachectl start

配置虚拟主机
添加域名到hosts文件中,
vi /etc/hosts
10.109.100.172 www.sdlx.com

修改httpd.conf文件,添加虚拟主机节点
vi /usr/local/apache2/etc/httpd.conf
yum安装则修改:
vi/etc/httpd/conf/httpd.conf
添加内容:
<VirtualHost 10.109.100.172:80>
DocumentRoot “/usr/local/apache2/htdocs/zabbix”
ServerName www.sdlx.com
<Directory “/usr/local/apache2/htdocs/zabbix” >
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all


<VirtualHost 192.168.56.101:80>
DocumentRoot “/var/www/html”
ServerName www.lx.com
<Directory “/var/www/html” >
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all

修改windows的hosts文件
C:\Windows\System32\drivers\etc\hosts
添加:
192.168.56.101 www.lx.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值