安装apache服务器apache
(推荐方法)ubuntu
安装前清确保已安装gcc、g++服务器
1)安装依赖包apr-1.6.5.tar.gz,下载地址:http://apr.apache.org/download.cgidom
tar -xvf apr-1.6.5.tar.gz测试
cd apr-1.6.5this
./configure --prefix=/usr/local/apr.net
make && make installrest
2)安装依赖包apr-util-1.6.1.tar.gz,下载地址:http://apr.apache.org/download.cgiserver
tar -xvf apr-util-1.6.1.tar.gzblog
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