实验环境
cat /etc/redhat-release && uname -a
CentOS Linux release 7.8.2003 (Core)
Linux centos7-1 3.10.0-1127.el7.x86_64
systemctl stop firewalld && systemctl disable firewalld
echo SELINUX=disabled > /etc/sysconfig/selinux
cp -pv /etc/sysctl.conf /etc/sysctl.conf.bak
cat >> /etc/sysctl.conf << EOF
> net.ipv4.tcp_syncookies = 1
> net.ipv4.tcp_tw_reuse = 1
> net.ipv4.tcp_tw_recycle = 1
> net.ipv4.tcp_fin_timeout = 10
> net.ipv4.ip_forward= 1
> EOF && sysctl -p
软件安装
yum install -y yum-utils git docker-ce-18.06.3.ce
systemctl daemon-reload
systemctl start docker && systemctl enable chronyd docker
docker --version
Docker version 18.06.3-ce, build 6d37f41
docker pull mysql:5.7
docker pull matomo:latest
docker pull nginx:1.10.2
docker run -itd --name mysql \
-p 3306:3306 --restart=always \
-v /etc/localtime:/etc/localtime \
-v /usr/local/docker/mysql/:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=root123 mysql:5.7
docker logs -f mysql | grep 3306
Version: '5.7.36' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
docker exec -it mysql /bin/bash -c "mysql -uroot -proot123"
mysql> create database matomo default charset 'utf8mb4';
mysql> grant all on ma.* to 'matomo'@'%' identified by 'ma123';
mysql> flush privileges;
docker exec -it mysql /bin/bash -c "mysql -uma -pma123"
mysql>
docker run -itd --name matomo \
-p 80:80 --restart=always \
-v /etc/localtime:/etc/localtime \
-v /usr/local/matomo/:/var/www/html \
--link mysql:mysql matomo
docker run -itd --name nginx \
-p 81:80 --restart=always nginx:1.10.2
netstat -tuplna | grep LISTEN
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 6745/docker-proxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7094/docker-proxy
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 6829/docker-proxy
用户名 admin 密码admin123
docker cp nginx:/usr/share/nginx/html/index.html /root/
cat index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//192.168.10.12/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code --> html文件添加配置
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
docker cp index.html nginx:/usr/share/nginx/html