On this page

一台服务器搭建多个网站

  1. 创建云服务器
  2. 连接云服务器
    1. ssh-keygen命令生成密钥
    2. ssh-copy-id 自动上传公钥
    3. 关闭密码登录
    4. 使用 mosh 提高连接速度
  3. 创建LNMP环境
    1. Docker 安装
    2. 下载LNMP配置文件
    3. 使用Docker安装LNMP环境
    4. 搭建wordpress博客网站
    5. 搭建flarum论坛
    6. 搭建Halo博客

wordpress 中文版本

wget https://cn.wordpress.org/latest-zh_CN.tar.gz

安装 Composer (composer.phar)

sha256
9a18e1a3aadbcb94c1bafd6c4a98ff931f4b43a456ef48575130466e19f05dd6

wget https://getcomposer.org/download/2.6.5/composer.phar
wget https://getcomposer.org/download/2.6.5/composer.phar.sha256sum

docker Halo blog 配置文件

wget  https://github.com/codewhynet/docker-halo-blog/archive/refs/heads/master.zip
    1  clear
    2  vim /etc/ssh/sshd_config.d/50-cloud-init.conf 
    3  service ssh restart
    4  sudo apt install mosh
    5  ufw allow 60000:60009/udp 
    6  exit
    7  # Add Docker's official GPG key:
    8  sudo apt-get update
    9  sudo apt-get install ca-certificates curl gnupg
   10  sudo install -m 0755 -d /etc/apt/keyrings
   11  curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
   12  sudo chmod a+r /etc/apt/keyrings/docker.gpg
   13  # Add the repository to Apt sources:
   14  echo   "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" |   sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   15  sudo apt-get update	
   16  sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
   17  clear
   18  docker ps
   19  wget  https://github.com/codewhynet/docker-lnmp/archive/refs/heads/main.zip
   20  mkdir /home/_docker_site
   21  cd /home/_docker_site/
   22  ls
   23  unzip ~/main.zip 
   24  ls
   25  mv docker-lnmp-main/docker_lnmp
   26  mv docker-lnmp-main docker_lnmp
   27  ls
   28  clear
   29  ls
   30  cd docker_lnmp/
   31  ls
   32  bash docker_lnmp.sh 
   33  docker ps
   34   docker exec -it docker_lnmp-8.1-fpm-1  docker-php-ext-install mysqli  pdo_mysql
   35  docker ps
   36  docker restart docker_lnmp-8.1-fpm-1
   37  mkdir data/www_site/www.phpmyadm.web
   38  cd data/www_site/www.phpmyadm.web/
   39  ls
   40  wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
   41  unzip phpMyAdmin-5.2.1-all-languages.zip 
   42  ls
   43  mv *.zip ~/
   44  ls
   45  mv phpMyAdmin-5.2.1-all-languages/ phpMyAdmin
   46  ls
   47  ls phpMyAdmin/
   48  cd phpMyAdmin/
   49  cp config.sample.inc.php config.inc.php 
   50  nvim config.inc.php 
   51  cd ../../
   52  ls
   53  cd ..
   54  ls
   55  cd ..
   56  ls
   57  cd config/nginx/
   58  ls
   59  cd conf.d/
   60  ls
   61  nvim www.phpmyadmin.web.conf
   62  cat www.phpmyadmin.web.conf 
   63  docker ps
   64  docker restart docker_lnmp-nginx-1
   65      docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
   66  ls
   67  cd ../../
   68  ls
   69  cd ..
   70  ls
   71  mkdir data/www_site/www.phpmyadm.web/phpMyAdmin/tmp
   72  chown www-data data/www_site/www.phpmyadm.web/phpMyAdmin/tmp
   73  nvim ~/db.txt
   74  cat ~/db.txt 
   75  ls
   76  cd
   77  wget https://cn.wordpress.org/latest-zh_CN.tar.gz
   78  cd /home/_docker_site/docker_lnmp/data/www_site/
   79  ls
   80  mkdir www.wp.web
   81  cd www.wp.web/
   82  tar xvf ~/latest-zh_CN.tar.gz 
   83  ls
   84  ls
   85  cd wordpress/
   86  ls
   87  pwd
   88  ls
   89  nvim wp-config.php
   90  ls
   91  ls
   92  cd ..
   93  ls
   94  cd ..
   95  mkdir bin
   96  cd bin/
   97  ls
   98  wget https://getcomposer.org/download/2.6.5/composer.phar
   99  docker ps
  100  docker exec -it docker_lnmp-8.1-fpm-1  bash
  101  ls
  102  docker ps
  103  docker  restart docker_lnmp-8.1-fpm-1
  104  ls
  105  cd ..
  106  ls
  107  chown -R www-data:www-data www.flarum.web/src/
  108  cat ~/db.txt 
  109  docker ps
  110  ls
  111  cd ..
  112  ls
  113  cd ..
  114  ls
  115  nvim docker-compose.yaml 
  116  docker compose up -d
  117  ls
  118  nvim config/nginx/conf.d/www.halo.blog.web.conf 
  119  docker ps
  120  docker restart docker_lnmp-nginx-1
  121  ls
  122  cat config/nginx/conf.d/www.halo.blog.web.conf 
  123  ls
  124  cat config/nginx/conf.d/www.wp.conf 
  125      docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
  126  cd
  127  ls
    1  clear
    2  vim /etc/ssh/sshd_config.d/50-cloud-init.conf 
    3  service ssh restart
    4  sudo apt install mosh
    5  ufw allow 60000:60009/udp 
    6  exit
    7  ls
    8  cd /home/_docker_site/
    9  ls
   10  cd docker_lnmp/
   11  ls
   12  cd config/nginx/
   13  ls
   14  cd conf.d/
   15  ls
   16  cp default.conf www.wp.web.conf
   17  ls
   18  nvim www.wp.web.conf 
   19  ls
   20  docker ps
   21  docker restart docker_lnmp-nginx-1
   22  cat www.wp.web.conf 
   23  cat ~/db.txt 
   24  docker ps
   25  cd
   26  ls
   27  wget wget  https://github.com/codewhynet/wordpress-codewhy-security/archive/refs/heads/master.zip
   28  mv master.zip wp-security.zip
   29  unzip wp-security.zip 
   30  rsync -avP wordpress-codewhy-security-master/nginx/conf.d/   /home/_docker_site/docker_lnmp/config/nginx/conf.d/
   31  rsync -avP wordpress-codewhy-security-master/wp/codewhy-security/   /home/_docker_site/docker_lnmp/data/www_site/www.wp.web/wordpress/codewhy-security/
   32  cd /home/_docker_site/docker_lnmp/config/nginx/conf.d/
   33  ls
   34  mv www.wp.web.conf /tmp/
   35  ls
   36  ln -s sites-available/www.wp.conf ./
   37  ls
   38  nvim www.wp.conf 
   39  docker ps
   40  docker restart docker_lnmp-nginx-1
   41  cat www.wp.conf 
   42  ls
   43  ls -lha
   44  nvim www.flarum.web.conf
   45  docker ps
   46  docker restart docker_lnmp-nginx-1
   47  cat www.flarum.web.conf 
   48  docker ps
   49  cd

    1  clear
    2  vim /etc/ssh/sshd_config.d/50-cloud-init.conf 
    3  service ssh restart
    4  sudo apt install mosh
    5  ufw allow 60000:60009/udp 
    6  exit
    7  ls
    8  mkdir lamp_soft
    9  mv *.zip lamp_soft/
   10  ls
   11  mv latest-zh_CN.tar.gz lamp_soft/
   12  ls
   13  mv wordpress-codewhy-security-master/ lamp_soft/
   14  ls
   15  wget  https://github.com/codewhynet/docker-halo-blog/archive/refs/heads/master.zip
   16  unzip master.zip 
   17  rsync -avP docker-halo-blog-master/src/config/nginx/conf.d/   /home/_docker_site/docker_lnmp/config/nginx/conf.d/
   18  rsync -avP docker-halo-blog-master/src/data/www_site/halo_blog_web/   /home/_docker_site/docker_lnmp/data/www_site/halo_blog_web/
   19  nvim /home/_docker_site/docker_lnmp/data/www_site/halo_blog_web/application.yaml 
   20  ls
   21  cat docker-halo-blog-master/src/docker-compose.yaml 
    1  apt update
    2  apt install git unzip 7zip
    3  apt install zlib1g-dev libzip-dev
    4  docker-php-ext-install zip
    5  apt-get install -y         libfreetype6-dev         libjpeg62-turbo-dev         libpng-dev 
    6  docker-php-ext-configure gd --with-freetype --with-jpeg 
    7  docker-php-ext-install   gd
    8  ls
    9  cd /home/_www_home/www_site/
   10  ls
   11  mkdir -p www.flarum.web/src
   12  cd www.flarum.web/src/
   13  ls
   14  chmod +x ../../bin/composer.phar 
   15  ../../bin/composer.phar  create-project flarum/flarum .
   16  ../../bin/composer.phar  require flarum-lang/chinese-simplified
   17  ls
   18  exit
   19  ls
   20  cd
   21  cd /home/_www_home/www_site/
   22  ls