apache(一)

1.linux下apache安装

######不安装依赖会报错
######checking for APR... no
######configure: error: APR not found . Please read the documentation
 
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
tar -xzvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make && make install
 
wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
tar -xzvf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
make && make install
#####编译apr-util时报错:make[1]: *** [xml/apr_xml.lo] Error 1
#####解决方法:yum -y install expat-devel
 
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
unzip pcre-8.10.zip
cd pcre-8.10
./configure --prefix=/usr/local/pcre
make && make install
####编译过程报错:make[1]: *** [pcrecpp.lo] Error 1
####说明缺少安装gcc-c++库,安装即可
####安装命令:yum -y install gcc-c++
####重新configure,make && make install通过
 
2.安装apache
wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
tar -zxvf httpd-2.4.33.tar.gz
mv httpd-2.4.33 apache
cd apache
./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ --with-mpm=worker
make && make install
 
--with-mpm=worker 用来制定work模式,如果不指定,默认prefork模式。具体模式是什么意思见apache(二)
 
 
3.配置
cd /usr/local/apache
1)vim conf/httpd.conf  
#配置“Listen”和“ServerName”属性;
Listen 80
ServerName localhost
 
2)./bin/apachectl configtest
#执行配置测试
Syntax OK
 
4. 启动httpd
/usr/local/apache/bin/apachectl start | stop | restart
或者:
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
/etc/init.d/httpd start
 
5.验证
浏览器输入localhost,页面显示it works!

猜你喜欢

转载自www.cnblogs.com/xiaowei89426/p/9074085.html