linux下安装apache

安装apache服务器

(推荐方法)

安装前清确保已安装gcc、g++

1)安装依赖包apr-1.6.5.tar.gz,下载地址:http://apr.apache.org/download.cgi

tar -xvf apr-1.6.5.tar.gz

cd apr-1.6.5

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

make && make install

2)安装依赖包apr-util-1.6.1.tar.gz,下载地址:http://apr.apache.org/download.cgi

tar -xvf 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

上述问题可能会出现此问题:

通过apt-get install libexpat-dev解决此问题

make && make install

3)安装依赖包pcre-8.42.tar.gz,下载地址:https://sourceforge.net/projects/pcre/files/

tar -xvf pcre-8.42.tar.gz

cd pcre-8.42

./configure --prefix=/usr/local/pcre

4)安装apache

下载apache:http://httpd.apache.org/download.cgi

tar -xvf httpd-2.4.37.tar.gz #解压

cd httpd-2.4.37

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

make && make install

5)测试

•启动Apache:/usr/local/apache2/bin/apachectl start •停止Apache:/usr/local/apache2/bin/apachectl stop •重启Apache:/usr/local/apache2/bin/apachectl restart

将apache添加到服务中(ubuntu适用,其他系统未知):

cp /usr/local/apache/bin/apachectl /etc/init.d/apache

systemctl daemon-reload

如果启动apahce的时候报了这个错误:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

请尝试按照以下方法解决:

nano /usr/local/apache/conf/httpd.conf

#修改ServerName为localhost:80

ServerName localhost:80

如果上述方法不可行,请尝试下列方法:

安装apache2:apt-get install apache2

•启动apache:/etc/init.d/apache2 start 或 service apache2 start

•停止apache:/etc/init.d/apache2 stop 或 service apache2 stop

•重启apache:/etc/init.d/apache2 restart 或 service apache2 restart

转载于:https://my.oschina.net/u/4108765/blog/3059973

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值