Apache基础

来自linux中国网wiki
跳到导航 跳到搜索

troubleshooting

apache,[warn] _default_ VirtualHost overlap on port 80, the first has precedence


[root@us www]# /etc/init.d/httpd restart
停止 httpd: [确定]
正在启动 httpd:[Tue Apr 28 15:01:02 2015] [warn] _default_ VirtualHost overlap on port 80, the first has precedence

[warn] _default_ VirtualHost overlap on port 80, the first has precedence
是因为第一个虚拟主机配置已经占用了80端口,所以将会沿用第一虚拟主机的配置。所以不管你第二个,或者第n个虚拟主机怎么配置,都会沿用第一个虚拟主机的配置,即出现的都是第一个站点的内容。

解决的办法就是将#NameVirtualHost *:80前的注释去掉。 变成

NameVirtualHost *:80

这样子,再重启apache就能解决问题了。。

apache 403


apache 403 Directory 之间 加

Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

全景如下

Options Indexes FollowSymLinks
AllowOverride None
Require all granted  #add this one
Order allow,deny
Allow from all

httpd.pid overwritten -- Unclean shutdown of previous Apache run

相关的人员在日常维护中,使用root用户启动apache,导致httpd.pid文件的属主变成了root,导致后来使用wacos用户启动apache时,Apache会尝试写httpd.pid以便记录自己的pid进程号,但是由于httpd.pid目前的属主是root使用wacos用户修改httpd.pid文件肯定会失败。

https://www.fuwuqizhijia.com/apache/201311/3102.html

install

官方安装文档

cd /data/lamp/;
tar xvf apr-util-1.4.1.tar.bz2 && cd apr-util-1.4.1 &&
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config && make -j4 && make install && cd ..
cd /data/lamp/;
tar vxf apr-iconv-1.2.1.tar.bz2 && cd apr-iconv-1.2.1&&
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr/bin/apr-1-config && make -j$cpunu && make install && cd ..
cd /data/lamp/;
tar xvf pcre-8.21.tar.bz2  && cd pcre-8.21 &&
./configure  && make -j$cpunu && make install &&  cd ..
cd /data/lamp/;
tar xvf zlib-1.2.7.tar.bz2 &&  cd zlib-1.2.7
CFLAGS="-O3 -fPIC" ./configure
make -j$cpunu && make install &&  cd ..
cd /data/lamp/;
tar -vxf httpd-2.4.3.tar.bz2  && cd httpd-2.4.3
#http://space.itpub.net/8117479/viewspace-707949
mv ../apr-util-1.4.1 apr-util
mv ../apr-1.4.6  apr
mv apr* srclib/
mkdir -p /usr/local/apache2 #创建安装目录
#./configure --enable-modules=all --enable-mods-shared=all --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-echo --enable-example --enable-case-filter --enable-ext-filter --enable-charset-lite --enable-logio --enable-mime-magic --enable-expires --enable-headers --enable-usertrack --enable-unique-id --enable-version --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp --enable-proxy-ajp --enable-proxy-balancer --enable-ssl --enable-static-htpasswd --enable-static-ab --enable-http --enable-dav --enable-info --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-mpm=prefork
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-included-apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-ssl --enable-so --enable-deflate=shared --enable-expires=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support &&
make -j$cpunu && make install
cd /data/lamp/;
#./configure --help 里面没有这个哦 --with-apr-iconv=/usr/local/apr-iconv 

#/usr/local/apache2/bin/apachectl -k start #启动
#/usr/local/apache2/bin/apachectl start
#/usr/local/apache2/bin/apachectl --configtest

#http://www.centospub.com/make/apache.html
#socle
#vi /usr/local/apache2/conf/httpd.conf
#http.conf里注释掉mod_dir.so 

#ServerName www.a.com:80

#网站目录
#cd /usr/local/apache2/htdocs/
 
#http://bbs.csdn.net/topics/390100492
#vi /usr/local/apache2/conf/httpd.conf #编辑配置文件
#找到:#ServerName www.example.com:80
#修改为:ServerName www.localhost.com.cn:80
#找到:DirectoryIndex index.html
#修改为:DirectoryIndex index.html index.php
#找到:Options Indexes FollowSymLinks
#修改为:Options FollowSymLinks #不显示目录结构
#找到:AllowOverride None
#修改为:AllowOverride All #开启apache支持伪静态,有两处都做修改
#LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释,开启apache支持伪静


#这几行 自己选择要不要
#vi /etc/profile #添加apache服务系统环境变量
#在最后添加下面这一行
#export PATH=$PATH:/usr/local/apache2/bin
#cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd #把apache加入到系统服務
#vi /etc/init.d/httpd
#在#!/bin/sh下面添加以下两行
#chkconfig:2345 10 90
#descrption:Activates/Deactivates Apache Web Server
#chown daemon.daemon -R /var/www #更改目录所有者
chmod -R 700 /var/www -R #更改apache网站目录权限
#chkconfig httpd on #设置开机启动
#service httpd restart

see also

http://linux.vbird.org/linux_server/0360apache.php#www_basic_basic

CentOS下LAMP网站架构之Apache性能调优篇

CentOS 7.2 配置Apache服务(httpd)--上篇

centos7 部署Apache服务器

[Apache]架设Apache服务器


Centos7 Apache配置虚拟主机的三种方式

svn源码安装-结合apache

centos6.8源码安装apache2.4


关于Apache mod_rewrite php 伪静态 实现URL重写和防盗链功能

apache+Keepalived实现站点高可用

使用Apache架设代理服务器


CentOS 7安装配置Apache HTTP Server