安装说明
这里我选择版本号为2.4.16的apache
请确保系统已经安装了编译工具
$ sudo apt-get install g++ gcc automake autoconf libtool make
1. 试安装apache2
$ wget http://archive.apache.org/dist/httpd/httpd-2.4.16.tar.gz
$ tar -zxvf httpd-2.4.16.tar.gz
$ cd httpd-2.4.16
$ ./configure --enable-so
2. 安装依赖-APR
Error
:这里你可能会遇到这样的错误
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
解决方法:
$ wget http://archive.apache.org/dist/apr/apr-1.4.6.tar.gz
$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.zip
$ tar -zxf apr-1.4.6.tar.gz
$ cd apr-1.4.6
$ ./configure --prefix=/usr/local/apr
$ make
$ sudo make install
完成后再去apache目录执行
$ ./configure --enable-so
3. 安装依赖-APR-util
Error
:这里你可能会遇到这样的错误
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
setting CFLAGS to " -g -O2 -pthread"
setting CPPFLAGS to " -D_REENTRANT -D_GNU_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
解决方法:
$ wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
$ tar -zxf apr-util-1.6.1.tar.gz
$ cd apr-util-1.6.1
$ ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
$ make
$ sudo make install
4. 安装依赖-pcre
然后重复执行前面安装apache的操作,根据错误提示安装相应的依赖
还会提示没有pcre的错误
解决方法:
$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz
$ tar -zxf pcre-8.42.tar.gz
$ cd pcre-8.42
$ ./configure --prefix=/usr/local/pcre
$ make
$ sudo make install
到这里依赖就全部安装好了。
5. 安装apache
$ cd /tmp/httpd-2.4.16
$ ./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
$ make
$ sudo make install
6. 开启apache服务
到这里,apache算是编译安装成功了
$ sudo /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 255.255.255.0 Set the 'ServerName' directive globally to suppress this message
在地址栏输入提示的ip即可查看运行结果!
IT WORKS!
7. 设置开机自启
$ sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
$ sudo update-rc.d -f httpd defaults