1 下載需要的安裝包
1 apr-1.5.2.tar.gz [下載鏈接](http://apr.apache.org/)
2 apr-util-1.5.4.tar.gz [下載鏈接](http://apr.apache.org/)
3 pcre-8.40.tar [下載地址](https://sourceforge.net/projects/pcre/files/)
4 httpd-2.4.25.tar.gz [下載地址](http://httpd.apache.org/)
2 解壓
1 先在/usr/local目錄下創建這四個目錄:
apache2
apr
apr-util
pcre
2 將httpd-2.4.25.tar.gz放到/usr/local/apache2
並解壓到當前文件夾下
tar -zxvf httpd-2.4.25.tar.gz
apr-1.5.2.tar.gz放到/usr/local/apr
並解壓到當前文件夾下
tar -zxvf apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz放到/usr/local/apr-util
並解壓到當前文件夾下
tar -zxvf apr-util-1.5.4.tar.gz
pcre-8.40.tar放到/usr/local/pcre
並解壓到當前文件夾下
tar -xvf pcre-8.40.tar
3 安裝
1 安裝apr:
到/usr/local/apr/apr-1.5.2目錄下依次執行如下命令:
./configure --prefix=/usr/local/apr
make
make install
2 接下來安裝apr-util:
到/usr/local/apr-util/apr-util-1.5.4目錄下依次執行如下命令:
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
make
make install
3 接下來安裝pcre:
到/usr/local/pcre/pcre-8.40目錄下依次執行如下命令:
./configure --prefix=/usr/local/pcre
make
make install
4 最後安裝apache:
到/usr/local/apache2/httpd-2.4.25目錄下依次執行如下命令:
./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
4 修改 httpd.conf文件
進入到/usr/local/apache2/conf下,vi httpd.conf編輯該文件,找到”#ServerName www.example.com:80“,在其下面一行添加”ServerName localhost:80“,然後保存退出 然後啓動apache。
•啓動Apache:/usr/local/apache2/bin/apachectl -k start
•停止Apache:/usr/local/apache2/bin/apachectl -k stop
•重啓Apache:/usr/local/apache2/bin/apachectl -k restart
雲服務器,訪問地址爲:http://IP:端口號
如果自己買了域名 可以直接使用域名鏈接 http://www.Sico2Sico.org
本地服務器 訪問地址爲:http://localhost:端口號
5 如果你是買的阿里雲服務器 那麼現在還是訪問不了的
還需要設置
阿里雲—》控制檯—》安全組—》配置規則—》添加新的規則
鏈接成功的話 會出現 it work 一個index.html的網頁
網頁是放在這個根目錄下的 /usr/local/apache2/htdocs
打開/usr/local/apache2/conf/httpd.conf文件,找到下面這行
DocumentRoot “/usr/local/apache2/htdocs”
後續更新 php配置