环境说明: 宿主系统: Centos7
字母 | 代表 | 端口 |
---|---|---|
L | Centos6.9 | \ |
N | nginx | 80 443 |
A | apache2.2 | 8080 |
P | php5.6 或者PHP7 | 5600 7000 |
centos7安装 略
# wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/CentOS7.x_system_init_shell_mini.sh
修改hostname和端口
# sh CentOS7.x_system_init_shell_mini.sh
# fdisk -l
# fdisk /dev/vdb
...
Command (m for help): n
Select (default p): p
Command (m for help): wq
格式化:
# mkfs.ext4 /dev/vdb1
# vi /etc/fstab
添加:
/dev/vdb1 /home ext4 defaults 0 0
# mount -a
wget -q -O - https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/create_dir.sh | bash -sh
# wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/3-CentOS7.x_Vsftp.sh
修改参数
# sh 3-CentOS7.x_Vsftp.sh
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/CentOS6_7_intall_docker.sh
sh CentOS6_7_intall_docker.sh
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/run-aliyun-openresty.sh
需要修改是否连接PHPfpm-和数据库
sh run-aliyun-openresty.sh
#启动容器 --link链接mysql容器
********************************************
docker run -itd --name=openresty \
--restart always \
--link centos6_httpd_php56 \
-p 80:80 \
-p 443:443 \
-v /data/docker/openresty/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
-v /data/docker/openresty/conf.d:/etc/nginx/conf.d \
-v /data/wwwroot/:/data/wwwroot/ \
-v /etc/localtime:/etc/localtime \
registry.cn-shenzhen.aliyuncs.com/funet8/openresty
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/run-aliyun-nginx.sh
sh run-aliyun-nginx.sh
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/run-aliyun-apache.sh
sh run-aliyun-apache.sh
********************************************
docker run -itd --name centos6_httpd_php56 \
--restart always \
-p 8080:8080 \
-v /data/docker/httpd/httpd.conf:/etc/httpd/conf/httpd.conf \
-v /data/docker/httpd/php.ini:/etc/php.ini \
-v /data/docker/httpd/conf.d/:/etc/httpd/conf.d/ \
-v /data/wwwroot/:/data/wwwroot/ \
registry.cn-shenzhen.aliyuncs.com/funet8/centos6.9-httpd-php:v5.7
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/run-aliyun-mysql.sh
sh run-aliyun-mysql.sh
docker run -itd --name mysql \
--restart always \
-p 61950:3306 \
-v /data/docker/mysql_conf/my.cnf:/etc/my.cnf \
-v /data/docker/mysql_conf/mysql_slowQuery.log:/var/log/mysql/mysql_slowQuery.log \
-v /data/docker/mysql_docker:/var/lib/mysql \
registry.cn-shenzhen.aliyuncs.com/funet8/centos6.9-mariadb:v1
端口:7300
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/CentOS7_Install_PHP7.3_PHPFPM.sh
sh CentOS7_Install_PHP7.3_PHPFPM.sh
cd /data/conf/shell/
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/cut_log_nginx_docker.sh
chmod +x /data/conf/shell/cut_log_nginx_docker.sh
echo '00 00 * * * root /data/conf/shell/cut_log_nginx_docker.sh' >> /etc/crontab
systemctl restart crond
###权限问题的总结
#在宿主上查看www用户的ID
cat /etc/passwd |grep www
www:x:1001:1001::/home/www:/sbin/nologin
#进入docker虚拟机
docker exec -it centos6_httpd_php56 /bin/bash
usermod -u 1001 www && groupmod -g 1001 www
#将所需要的目录更改权限
ll /data/wwwroot/web/
这是由于来自守护进程的错误响应,而致使外部连接失败。解决的办法就是将其docker进程 kill掉,然后再 清空掉iptables下nat表下的所有链(规则) 。最后,将 docker的网桥删除,并重启docker服务
wget https://raw.githubusercontent.com/funet8/centos6_LANP_dockerfile/master/shell/docker_net.sh
sh docker_net.sh