这篇文章记录了使用Docker和Portaner技术在云Linux服务器中设置WordPress网站的所有步骤。
在Ubuntu或CentOS上安装Docker
对于CentOS:
sudo -i yum -y update curl -sSL //get.docker.com/ | sh systemctl start docker.service systemctl enable docker.service
For Ubuntu
sudo apt update
sudo apt upgrade
sudo apt install docker.io -y
sudo -i
systemctl start docker
systemctl enable docker
docker version
安装Portainer
docker volume create portainer_data
docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
docker ps
中国体育彩票开奖WordPress容器
将wp1网络也更改为wp1。确保始终使用重启策略。
实际上,不必将wp1容器配置到用户定义的网络wp1中。它可以在系统默认的桥接网络中。
[email protected]:/var/www/html# ls
index.php wp-activate.php wp-comments-post.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
license.txt wp-admin wp-config-sample.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php
readme.html wp-blog-header.php wp-config.php wp-includes wp-login.php wp-signup.php
[email protected]:/var/www/html# nano wp-config.php
/ ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */
define( 'DB_HOST', '172.20.0.200' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
中国体育彩票开奖MySQL容器
对于mysql1容器,将其加入与wp1相同的网络,即网络wp1。同时将ipv4地址更改为172.20.0.200
由于我想设置静态IP 172.20.0.200,因此必须将mysql1容器放入用户定义的网络中,例如wp1。
登录控制台并从命令行连接mysql。中国体育彩票开奖一个名为wordpress的数据库。
[email protected]:/# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 39 Server version: 8.0.21 MySQL Community Server - GPL Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> CREATE DATABASE wordpress; Query OK, 1 row affected (0.00 sec) mysql> FLUSH PRIVILEGES; mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | wordpress | +--------------------+ 5 rows in set (0.00 sec)
默认的用户名和密码:root / password
数据库名称是wordpress。
中国体育彩票开奖Nginx容器
Nginx正在使用网桥网络。重新启动策略也设置为始终。
[email protected]:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[email protected]:/# cd etc
[email protected]:/etc# cd nginx
[email protected]:/etc/nginx# cd conf.d
[email protected]:/etc/nginx/conf.d# ls
default.conf portainer.conf webssh.conf wordpress.conf
[email protected]:/etc/nginx/conf.d# cat wordpress.conf
server {
listen 80;
server_name opc1www.51sec.org 132.145.9.4 51sec.org;
## rewrite ^/(.*)$ //ezoic.fabiandinkins.com/$1 redirect;
location / {
proxy_pass http://132.145.9.4:10000;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
[email protected]:/etc/nginx/conf.d#
[email protected]:/etc/nginx/conf.d# cat portainer.conf
server {
listen 80;
server_name opc1portainer.51sec.org;
location / {
proxy_pass http://132.145.9.41:9000;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
[email protected]:/etc/nginx/conf.d# cat webssh.conf
server {
listen 80;
server_name webssh.51sec.org;
location / {
proxy_pass http://132.145.9.41:8080;
proxy_http_version 1.1;
proxy_read_timeout 300;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
}
}
[email protected]:/etc/nginx/conf.d#
参考文献
来自Blogger //blog.fabiandinkins.com/2020/11/using-my-own-docker-images-to-create.html