close

 

phpservermon 官方網站 : http://www.phpservermonitor.org/

我是下載 phpservermon-v3.1.1.tar.gz

下載 https://codeload.github.com/schmunk42/docker-phpservermon/zip/master 解壓縮到固定目錄

我是放在 D:\docker\

修改一些檔案 ...適合自己使用.......人家用 linux ...我的是 win10 要手動執行

 

D:\docker\php-fpm\Dockfile

FROM phundament/php:5.6-fpm-dev
RUN mkdir -p /var/www/public
COPY ./phpinfo.php /var/www/public/phpinfo.php
COPY ./phpservermon-3.1.1.tar.gz /
COPY ./adminer.php /
COPY ./up.php /var/www/public/
COPY ./adminer.php /var/www/public/
COPY ./psm_id.sql.tar /var/www/public/
RUN tar -zxvf /phpservermon-3.1.1.tar.gz -C /var/www/public/ --strip-components=2
RUN rm /phpservermon-3.1.1.tar.gz
COPY ./psm_config.php /var/www/public/config.php
RUN chown -R www-data:www-data /var/www/public
RUN chmod -R 755 /var/www/public
COPY ./php-fpm.conf /etc/php5/fpm/php-fpm.conf
COPY ./www.conf /etc/php5/fpm/pool.d/www.conf
COPY ./php.ini /etc/php5/fpm/php.ini
COPY ./etc-cron.d-tab-for-phpfpm.txt /etc/cron.d/phpservermon
RUN chown root:root /etc/cron.d/phpservermon
RUN chmod 600 /etc/cron.d/phpservermon
EXPOSE 9000
VOLUME /var/www/public

 

新加的file  :  D:\docker\php-fpm\up.php (其中有改時差 12 小時 ...不要照抄吧!)

為啥加這個請參考 :  http://echochio.pixnet.net/blog/post/44426329 這外網機器去監控內網用的

<?php
$dbhost = $_SERVER['MYSQLPSM_PORT_3306_TCP_ADDR'];
$dbname = $_SERVER['MYSQLPSM_ENV_MYSQL_DATABASE'];
$dbuser = $_SERVER['MYSQLPSM_ENV_MYSQL_USER'];
$dbpswd = $_SERVER['MYSQLPSM_ENV_MYSQL_PASSWORD'];

  try {

    $db = new PDO("mysql:host=".$dbhost.";dbname=".$dbname,$dbuser,$dbpswd);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
    $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
    $db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND,'SET NAMES UTF8');

  } catch (PDOException $e) {
    throw new PDOException("Error  : " .$e->getMessage());
  }

$id_key=$_GET['id'];

$sql = "SELECT id,name FROM psm_id where id_key='".$id_key."'";
$sth = $db->prepare($sql);
$sth->execute();
$row_count = $sth->rowCount();
if ($row_count ==  "") {
echo " Error !!";
} else {
$sth->setFetchMode(PDO::FETCH_ASSOC);
$result = $sth->fetchAll();
// print_r ($result);
$id = $result[0]['id'];
$name = $result[0]['name'];
$llabel= $name." ".$_GET['Info'];
$sql = "UPDATE psm_servers SET error = '',label = '".$llabel."' ,rtime=1 ,warning_threshold_counter = 0,status = true ,last_online =  NOW() + INTERVAL 12 hour  WHERE  server_id = ".$id ;
$sth2 = $db->prepare($sql);
$sth2 ->execute();
echo "OK !!"; 
 }
unset ($db);

 

D:\docker\php-fpm\adminer.php

去下載 https://github.com/vrana/adminer/releases/download/v4.2.5/adminer-4.2.5-en.php

官網在 https://www.adminer.org/ 

這樣改 mysql 方便多了

 

D:\docker\php-fpm\psm_id.sql.tar .......這是備份的資料 .....如果沒有就手動建立空的也可 ... 只是到時候匯入方便

CREATE TABLE IF NOT EXISTS `psm_id` (
  `id` varchar(4) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  `id_key` varchar(20) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  `name` varchar(30) NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `psm_id` (`id`, `id_key`, `name`) VALUES
('21', '8uY6jvCS7qntJySz9GSa', 'SEO3'),
('22', 'qqTYvvqjq55KSPpHQLmA', 'SEO2'),
('23', 'QNFhfZqmUcUXCkfVxj7M', 'SEO1');

資料庫的帳密在 D:\docker\docker-compose.yml  ......先修改一下 .....

檔案都準備好了 ....

就開始 

D:\docker>docker pull raddiscentis/php-fpm:0.0.1

D:\docker>docker pull nginx:1.9.2

D:\docker>docker pull mysql:5.7.7

D:\docker>docker build -t chio/php-fpm-psm:0.0.0 ./php-fpm 

D:\docker>docker-compose up -d

看一下 docker ps -a 已執行了 .....

看一下 Web ...輸入一些基本資料 就進去了

 

管理 SQL 用 adminer.php ( 資料庫的帳密在 D:\docker\docker-compose.yml (如要修改請在編譯前修改) )

 

匯入 SQL 後 ....

 

至於 Docker mysql 的 IP .... 我是猜的 .....哈哈 #$%^&*()_ 哪有可能 !!!!

D:\docker>docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                            NAMES
2b376a4ea773        nginx:1.9.2         "nginx -g 'daemon off"   2 hours ago         Up 2 hours          443/tcp, 0.0.0.0:28684->80/tcp   docker_web_1
69a3f3309d9c        docker_php          "/root/run-phundament"   2 hours ago         Up 2 hours          9000/tcp                         docker_php_1
c8a6d017f96c        mysql:5.7.7         "/entrypoint.sh mysql"   2 hours ago         Up 2 hours          3306/tcp                         docker_db_1

D:\docker>docker exec -it c8a6d017f96c bash
root@c8a6d017f96c:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN qlen 1
    link/ipip 0.0.0.0 brd 0.0.0.0
3: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN qlen 1
    link/gre 0.0.0.0 brd 0.0.0.0
4: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
5: ip_vti0@NONE: <NOARP> mtu 1428 qdisc noop state DOWN qlen 1
    link/ipip 0.0.0.0 brd 0.0.0.0
6: ip6_vti0@NONE: <NOARP> mtu 1500 qdisc noop state DOWN qlen 1
    link/tunnel6 :: brd ::
7: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0
8: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN qlen 1
    link/tunnel6 :: brd ::
9: ip6gre0@NONE: <NOARP> mtu 1448 qdisc noop state DOWN qlen 1
    link/[823] 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
540: eth0@if541: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.2/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:2/64 scope link
       valid_lft forever preferred_lft forever
root@c8a6d017f96c:/# c8a6d017f96c

 

arrow
arrow
    創作者介紹
    創作者 echochio 的頭像
    echochio

    echochio

    echochio 發表在 痞客邦 留言(0) 人氣()