ubuntu2004筆記

 01.啟用ufw

ufw enable

ufw allow from xxx.xxx.xxx.xxx (填上自己連入的IP)


02.系統升級

apt update

apt dist-upgrade


03.修改主機名稱(通常預設為IP,我會習慣改成方便管理的名稱)

vi /etc/hostname


reboot


04.順便設定ssh免密碼登入

本機端執行  ssh-keygen -t rsa


cat .ssh/id_rsa.pub  


遠端主機 .ssh/authorized_keys 貼上cat複製的內容


05.

add-apt-repository ppa:ondrej/php

add-apt-repository ppa:ondrej/nginx


apt update



apt install nginx mysql-server mysql-client php7.3-fpm php7.3-mysql php7.3-gd php7.3-xml php7.3-mbstring php7.3-zip php7.3-curl php7.3-apcu unzip vim php5.6-fpm php5.6-mysql php5.6-gd php5.6-xml php5.6-mbstring php5.6-zip php5.6-curl php5.6-apcu


06.開通ufw連線

ufw allow 80/tcp

ufw allow 'Nginx HTTP'

ufw allow 'Nginx HTTPS'


07.設定mysql密碼 ( yourpassword 要換成自己的密碼 )

mysql -u root

DROP USER 'root'@'localhost';

CREATE USER 'root'@'localhost' IDENTIFIED BY '';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';

FLUSH PRIVILEGES;

PS.修改密碼SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');會報錯,所以這裡有更新


vi .my.cnf

[client]

password = xxxx


PS.如果要降版本可以參考 https://techexpert.tips/mysql/installing-mysql-5-7-ubuntu-20-04/


08.安裝drush

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

composer global require drush/drush:8.3.5

alias drush='/usr/bin/php ~/.config/composer/vendor/drush/drush/drush.php'

drush init

PS.alias drush='/usr/bin/php ~/.composer/vendor/drush/drush/drush.php'  <= 這段也有可能是這樣,就依照當時安裝的路徑找一下



08.安裝SSL使用 certbot

apt install certbot python3-certbot-nginx

certbot --nginx

PS.Ubuntu2004有內建,不用ppa加來源


接下來就照後面的筆記執行即可

https://liaozi.blogspot.com/2020/06/2020vps-ubuntu-1804-lts.html


留言

熱門文章