Linux下安装Apache服务器

毅然决然的放弃了xampp,搞起apache,还挺复杂,直接安装httpd-2.4.4,会先后报出

1、configure: error: APR not found. Please read the documentation.

2、configure: error: APR-util not found. Please read the documentation

3、configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

4、configure: error: You need a C++ compiler for C++ support

这个四个错误,好吧,容我慢慢道来:

一、准备工作:

apache:httpd-2.4.4.tar.gz

依赖包:apr-1.46.tar.gz、apr-util-1.5.1.tar.gz(下载地址:http://apr.apache.org/download.cgi)、
pcre-8.32.tar.gz(下载地址:http://www.pcre.org

二、安装:

1、安装apr

#tar -zxvf apr-1.46.tar.gz

#./configure --prefix=/usr/local/apr
#make

#make install

2、安装apr-util

#tar -zxvf apr-util-1.5.1.tar.gz

#./configure --with-apr=/usr/local/apr
#make

#make install

3、安装pcre

#tar -zxvf pcre-8.32.tar.gz

#./configure --prefix=/usr/local/pcre(此处出现configure: error: You need a C++ compiler for C++ support

#sudo apt-get install g++)

#make

#make install

4、安装apache

#tar -zxvf httpd-2.4.4.tar.gz

#./configure --prefix=/usr/local/apache --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/ --with-pcre=/usr/local/pcre/

#make

#make install

三、配置

gedit /usr/local/apache/conf/httpd.conf
在“#ServerName www.example.com:80”下面添加一行如下:
ServerName localhost:80

启动

/usr/local/apache/bin/apachectl start

这里可能会出现error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory这样的错误,解决方法是:

# ln -s /usr/local/lib/libpcre.so.1 /lib

打开浏览器,输入localhost,显示"It works!",完工。

相关推荐