傻瓜式哦~保证只要版本对的上,必成功
一步一步执行下面语句,执行完之后就好使了!!!
wget https://dlcdn.apache.org/httpd/httpd-2.4.57.tar.gz
wget https://dlcdn.apache.org//apr/apr-1.7.4.tar.gz
wget https://dlcdn.apache.org//apr/apr-util-1.6.3.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
tar -zxvf httpd-2.4.57.tar.gz
tar -zxvf apr-1.7.4.tar.gz
tar -zxvf apr-util-1.6.3.tar.gz
tar -zxvf pcre-8.45.tar.gz
sudo apt-get install make
sudo apt-get install libexpat1-dev
sudo apt-get install build-essential
1.
cd apr-1.7.4/
./configure --prefix=/usr/local/apr/apr-1.7.4
sudo make
sudo make install
sudo nano /etc/ld.so.conf
/usr/local/apr/apr-1.7.4/lib
sudo ldconfig
2.
cd apr-util-1.6.3/
./configure --prefix=/usr/local/apr/util/apr-util-1.6.3 --with-apr=/usr/local/apr/apr-1.7.4
sudo make
sudo make install
sudo nano /etc/ld.so.conf
/usr/local/apr/util/apr-util/apr-util-1.6.3/lib
sudo ldconfig
3.
cd pcre-8.45/
./configure --prefix=/usr/local/pcre --with-apr-util=/usr/local/apr/util/apr-util-1.6.3 --with-apr=/usr/local/apr/apr-1.7.4
sudo make
sudo make install
sudo nano /etc/ld.so.conf
/usr/local/apr/pcre/lib
sudo ldconfig
4.
cd httpd-2.4.57/
./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=most --enable-proxy-balancer=shared --enable-proxy-http=sahred --enable-proxy-ajp --enable-rewrite --with-apr=/usr/local/apr/apr-1.7.4 --with-apr-util=/usr/local/apr/util/apr-util-1.6.3 --with-pcre=/usr/local/pcre/bin/pcre-config
sudo make
如果报错了,那么就是上面任何一步出错了,回到对应操作重新开始试试
sudo make install
5.
sudo nano /usr/local/apache/conf/httpd.conf
ServerName 127.0.0.1:80
上面ip想写啥写啥。
sudo cp /usr/local/apache/bin/apachectl /usr/bin
sudo apachectl start
可以去访问啦
6.
sudo ufw allow 80
sudo apachectl restart
7.
cd /usr/local/apache/htdocs
sudo nano index.html
以后要配置默认访问页面可以都存在当前目录下
8.需要将默认访问页面设置成自己的只需要进行如下操作
sudo nano /usr/local/apache/conf/httpd.conf
<IfModule dir_module>
DirectoryIndex index.html #将这里的index.html文件改成自己的文件名
</IfModule>