这是官网上给的操作步骤:
Download | $ lynx http://httpd.apache.org/download.cgi |
Extract | $ gzip -d httpd-NN.tar.gz |
Configure | $ ./configure --prefix=PREFIX |
Compile | $ make |
Install | $ make install |
Customize | $ vi PREFIX/conf/httpd.conf |
Test | $ PREFIX/bin/apachectl -k start |
1.在configure时,会提示需要APR and APR-Util
官方网站说:
Make sure you have APR and APR-Util already installed on your system. If you don't, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be sure the directory names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/)
也就是到apr.apache.org下载,解压后放到/srclib/下,并把版本号去掉。
2.在configure时,会提示需要pcre
到这里下载:http://www.pcre.org,
下载后编译安装:
./configure
make
make install
pcre在configure时提示需要c++编译器:sudo apt-get install build-essential
3.在启动apache时,提示找不到libpcre.so.1
先查看httpd的依赖库信息:
ldd httpd
然后搜索libpcre.so.1文件,发现该文件在/usr/local/lib目录下。
那么就在/etc/ld.so.conf.d目录下新建文件libc.conf,将/usr/local/lib目录加到该文件:
/usr/local/lib
接下来执行ldconfig命令:
sudo ldconfig
最后使用ldd命令确认libpcre.so.1是否已找到:
4.配置ServerName,在conf/httpd.conf里。
这时应该可以正常启动了。