安裝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