溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

docker部署Apache服務(wù)并監(jiān)控

發(fā)布時(shí)間:2020-06-27 15:47:08 來源:網(wǎng)絡(luò) 閱讀:698 作者:ufuhz2008 欄目:軟件技術(shù)

1:基礎(chǔ)容器編譯部署apache

1.1:pull一個(gè)ubuntu 16.04的鏡像

sudo docker pull ubuntu:16.04

1.2:運(yùn)行容器  

sudo docker run -d --name ubuntu -p 80:80 ubuntu:16.04

1.3:安裝ubuntu依賴項(xiàng)

apt update

apt-get install vim

apt-get install net-tools

apt-get install iputils-ping

apt-get install openssh-server

apt-get install openssh-client

apt-get install lrzsz

apt-get install gcc

apt-get install libpcre3 libpcre3-dev

apt-get install make

apt-get install openssl libssl-dev

apt-get install libxml2 libxml2-dev

apt-get install zip unzip

apt-get install libexpat1-dev

apt-get install libnghttp2-dev

1.4:創(chuàng)建安裝目錄

mkdir /etc/apache2

mkdir /etc/apache2/src

cd /etc/apache2/src

1.5:下載源碼并解壓

如果路徑失效,需要去官網(wǎng)下載相應(yīng)的安裝包

wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

wget http://apache.mirrors.lucidnetworks.net//httpd/httpd-2.4.27.tar.gz

wget http://cn2.php.net/distributions/php-7.1.8.tar.gz

tar -xvf apr-1.5.2.tar.gz

tar -xvf apr-util-1.5.4.tar.gz

tar -xvf httpd-2.4.27.tar.gz

tar -xvf php-7.1.8.tar.gz

mv -f apr-1.5.2 httpd-2.4.27/srclib/apr

mv -f apr-util-1.5.4 httpd-2.4.27/srclib/apr-util

1.6:安裝依賴包zlib1g,zlib1g.dev

直接安裝

sudo?apt-get?install?libpcre3?libpcre3-dev??

編譯安裝

在?http://jaist.dl.sourceforge.net/project/pcre/pcre/?下載

得到文件: pcre-8.32.tar.gz

解壓:tar -zxvf pcre-8.32.tar.gz

編譯:

cd?/home/tnuser/hunter/installers/pcre-8.32????

/configure?--prefix=/home/tnuser/pcre/??

?

1.7:安裝依賴包openssl和openssl-devel

直接安裝

apt-get install openssl openssl-devel

?

下載源碼編譯安裝

cd /etc/apache2/src

wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz

tar zxf openssl-1.0.2h.tar.gz

cd openssl-1.0.2h

./config shared zlib

如果提示 because of configuration changes, you MUST do the following before*** building:

則需要在build之前做make depend

make depend

make

make install

mv /usr/bin/openssl /usr/bin/openssl.bak

mv /usr/include/openssl /usr/include/openssl.bak

ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/ssl/include/openssl /usr/include/openssl

echo “/usr/local/ssl/lib” >> /etc/ld.so.conf

ldconfig –v

?

檢測安裝是否成功

openssl version –a

1.8:編譯apache

openssl version -a

mkdir server_root

cd src/httpd-2.4.27 ./configure --prefix=/etc/apache2/server_root --with-included-apr --with-mpm=worker --enable-so --enable-nonportable-atomics=yes --enable-ssl --enable-include --enable-cgi --enable-expires --enable-status --enable-info --enable-rewrite --enable-speling

make

make install

mkdir /etc/apache2/php7

cd /etc/apache2/src/php-7.1.8

./configure --with-apxs2=/etc/apache2/server_root/bin/apxs --prefix=/etc/apache2/php7

make

make test

make install

?

修改httpd.conf文件

vim /etc/apache2/server_root/conf/httpd.conf

在httpd.conf文件中添加:

AddType application/x-httpd-php .php?

AddType application/x-httpd-php-source .phps

去掉httpd.conf里ServerName前面的注釋:?

?

重啟apache服務(wù)

cd /etc/apache2/server_root/bin

./apachectl start

1.9:容器打包

?docker部署Apache服務(wù)并監(jiān)控

2:配置server-status 監(jiān)控apache

2.1:server-status簡介

server-status是Apache查看狀態(tài)的一個(gè)功能模塊,在Apache 1.3.2及以后的版本提供

2.2:打開server-status

vi /etc/apache2/server_root/conf/httpd.conf

去掉LoadModule status_module modules/mod_status.so的注釋

docker部署Apache服務(wù)并監(jiān)控

修改Include 路徑 為 /etc/apache2/server_root/conf/extra/httpd-info.conf

docker部署Apache服務(wù)并監(jiān)控

修改配置如下

vi /etc/apache2/server_root/conf/extra/httpd-info.conf

<Location /server-status>

??? SetHandler server-status

??? Order deny,allow

Allow from all

Allow from 10.20.7.15

</Location>

docker部署Apache服務(wù)并監(jiān)控

去掉ExtendedStatus On 注釋

docker部署Apache服務(wù)并監(jiān)控

vi /etc/apache2/src/httpd-2.4.33

./configure?--enable-module=so --enable-info

docker部署Apache服務(wù)并監(jiān)控

重啟apache

cd /etc/apache2/server_root/bin

./apachectl restart

3:鏡像包部署apache

3.1:拉取鏡像

Docker pull registry.cn-hangzhou.aliyuncs.com/zhufc/apache-status:zhu

3.2:映射80端口

docker run -d --name apache -p 80:80 registry.cn-hangzhou.aliyuncs.com/zhufc/apache-status:zhu

3.3:進(jìn)入容器啟動(dòng)apache

docker exec -it da6a434c99e6 bash

cd /etc/apache2/server_root/bin

./apachectl start

3.4:容器后臺(tái)運(yùn)行

Ctrl+alt+q+p?

3.4:容器后臺(tái)運(yùn)行

Ctrl+alt+q+p?

4:頁面驗(yàn)證apache監(jiān)控

http://10.20.7.15/server-status

docker部署Apache服務(wù)并監(jiān)控

http://10.20.7.15/server-status/phpmyadmin

docker部署Apache服務(wù)并監(jiān)控

docker部署Apache服務(wù)并監(jiān)控

?


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI