编译安装LAMP之安装apache2

安装说明

这里我选择版本号为2.4.16的apache

apache2所有版本下载站点

请确保系统已经安装了编译工具

$ 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
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值