时间:2023-05-30 04:30:01 | 来源:网站运营
时间:2023-05-30 04:30:01 来源:网站运营
教你如何只花1分钟搭建自己的个人网站:docker 真的是十分适合做迁移部署了,采用传统的方法去安装WordPress,经常会有各种各样的环境问题导致安装失败。本文主要描述如何通过 docker 快速搭建一个属于自己的WrodPress。version: "3.3"services: wordpress: image: wordpress:latest ports: - "8000:80" restart: always volumes: - ./wordpress:/var/www/html environment: WORDPRESS_DB_HOST: mysql:3306 WORDPRESS_DB_USER: root WORDPRESS_DB_PASSWORD: "<填上你自己的数据库密码>" WORDPRESS_DB_NAME: wordpress mysql: image: mysql:5.7.26 restart: always ports: - "3306:3306" volumes: - ./mysql-data:/var/lib/mysql #- ./mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf environment: MYSQL_DATABASE: wordpress MYSQL_ROOT_PASSWORD: "<填上你自己的数据库密码,与上面的密码保持一致就可以了>"
2. 启动服务,执行以下命令docker-compose up -d
docker-compose ps
输出结果: Name Command State Ports--------------------------------------------------------------------------------------------------------------------wordpress_mysql_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp,:::3306->3306/tcp, 33060/tcpwordpress_wordpress_1 docker-entrypoint.sh apach ... Up 0.0.0.0:8000->80/tcp,:::8000->80/tcp
这里显示已经启动了两个容器,一个是mysql,一个是wordpress,看State都是 Up,说明已经启动成功了。apt-get update && apt-get install -y nginx
2. 创建配置文件 /etc/nginx/conf.d/www.example.confserver { # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; listen 80; server_name www.example.com; location / { proxy_pass http://192.168.101.43:8000; proxy_set_header HOST $host; proxy_set_header X-Forwarded-Proto $schema; proxy_set_header X-Real-IP $remote_addr; } location ~ //.ht { deny all; }}
3. 应用nginx 配置service nginx restart # 或者热更新配置运行:service nginx reload
关键词: