Install WordPress on Ubuntu fast tutorial

Install WordPress on Ubuntu

> apt install nginx

> ufw allow ‘Nginx HTTP’

> apt install mysql-server

> apt install php-fpm php-mysql

> nano /etc/php/7.2/fpm/php.ini

update as `cgi.fix_pathinfo=0`

> systemctl restart php7.2-fpm

> nano /etc/nginx/sites-available/default

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name server_domain_or_IP;
    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock; # your php’s sock runtime path
    }
    location ~ /\.ht {
        deny all;
    }
}

> systemctl reload nginx

Migrate ubuntu to another disk

  1. connect new disk {diskB}
  2. use `fdisk -l` to find current disks info
  3. format {diskB} with `GPT` partition format.
  4. partition {diskB} to have exact partitions as old disk: 
    • / (the root) fileSystem: ex4
    • /boot (for booting files including `grub`) fileSystem: ex2, flags: boot, esp
    • fileSystem: unformatted, mount point: none, flags: bios_grub
  5. mount /boot of {diskB} to point /mnt and install grub
    • > $ sudo grub-install –target=i386-pc –root-directory=/mnt –recheck –debug /dev/sdb
    • mv /mnt/boot/* /mnt/
  6. use `mount {source path} {dest. path, like /mnt}` to mount new partitions and copy all files from the corresponding folders from old disk: cp -rf -a {source path} {dest. path}
    • /bin 系统可执行文件
    • /etc 系统核心配置文件
    • /opt 用户程序文件
    • /root root用户主目录
    • /sbin 系统可执行文件
    • /usr 程序安装目录
    • /var 系统运行目录
    • /boot
  7. create essential empty directories in {diskB}
    • /dev 主要存放与设备(包括外设)有关的文件
    • /proc 正在运行的内核信息映射
    • /sys 硬件设备的驱动程序信息
  8. modify etc/fstab file to mount new /, /boot/ in {diskB} and old disk
    • use `blkid` to check current partitions uuid
    • change fstab:
      • UUID={diskB’s `/` partition uuid}             /           ext4    errors=remount-ro     0       1
      • UUID={diskB’s `/boot` partition uuid}     /boot    ext4    defaults                      0       2
  9. update-grub (if still not work, try to grub-install /dev/{diskB}
  10. reboot!

grub rescue mode if grub directory is not found at booting:

use `ls (hd0,1~9)/{any files like ./grub ./lost+found}` to check what your boot index is.

grub rescue>root=(hd0,{diskB’s boot partition index, `2` for example.})

grub rescue>prefix=/boot/grub

grub rescue>set root=(hd0,2)

grub rescue>set prefix=(hd0,2)/boot/grub

grub rescue>insmod normal

grub rescue>normal // auto enter `normal` mode

// normal mode /////////

grub>linux /vmlinuz-xxx-xxx root=/dev/{diskB} ro

grub>initrd /initrd.img-xxx-xxx

grub>boot