sudo apt update && sudo apt upgrade && sudo apt dist-upgrade
B.安裝後設定root 密碼
sudo passwd root
查詢網路狀態 ifconfig -a
C安裝網路卡
https://blog.toright.com/posts/6293/ubuntu-18-04-%E9%80%8F%E9%81%8E-netplan-%E8%A8%AD%E5%AE%9A%E7%B6%B2%E8%B7%AF%E5%8D%A1-ip.html
apache安裝及設定:
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04
Server Configuration
/etc/apache2: The Apache configuration directory. All of the Apache configuration files reside here./etc/apache2/apache2.conf: The main Apache configuration file. This can be modified to make changes to the Apache global configuration. This file is responsible for loading many of the other files in the configuration directory./etc/apache2/ports.conf: This file specifies the ports that Apache will listen on. By default, Apache listens on port 80 and additionally listens on port 443 when a module providing SSL capabilities is enabled./etc/apache2/sites-available/: The directory where per-site virtual hosts can be stored. Apache will not use the configuration files found in this directory unless they are linked to thesites-enableddirectory. Typically, all server block configuration is done in this directory, and then enabled by linking to the other directory with thea2ensitecommand./etc/apache2/sites-enabled/: The directory where enabled per-site virtual hosts are stored. Typically, these are created by linking to configuration files found in thesites-availabledirectory with thea2ensite. Apache reads the configuration files and links found in this directory when it starts or reloads to compile a complete configuration./etc/apache2/conf-available/,/etc/apache2/conf-enabled/: These directories have the same relationship as thesites-availableandsites-enableddirectories, but are used to store configuration fragments that do not belong in a virtual host. Files in theconf-availabledirectory can be enabled with thea2enconfcommand and disabled with thea2disconfcommand./etc/apache2/mods-available/,/etc/apache2/mods-enabled/: These directories contain the available and enabled modules, respectively. Files in ending in.loadcontain fragments to load specific modules, while files ending in.confcontain the configuration for those modules. Modules can be enabled and disabled using thea2enmodanda2dismodcommand.
Activate the virtual host.
- sudo ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/example
Delete the default Nginx server block.
- sudo rm /etc/nginx/sites-enabled/default
安裝Mysql
https://vitux.com/how-to-install-and-configure-mysql-in-ubuntu-18-04-lts/
1.參考: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04
鏈結:
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
$ sudo a2enconf phpmyadmin
https://www.howtoing.com/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp
安裝 php7.2 curl 前:
/etc/apt/sources.list 文件中像下面這樣添加一行
deb http://security.ubuntu.com/ubuntu bionic-security main universe
sudo apt update && sudo apt upgrade && sudo apt dist-upgrade
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04
重啟:
systemctl restart apache2
sudo systemctl start apache2
sudo systemctl reload apache2
Next, let’s test for configuration errors:
sudo apache2ctl configtest
Restart Apache to implement your changes:
sudo systemctl restart apache2
查詢可以安裝的原件
apt-cache search php7.2
apt search php- | less
apt show package_name
apt show php-curl
sudo apt install php-curl
apt show package_name
apt show php-curl
sudo apt install php-curl
防火牆
時間校正
$ sudo timedatectl // 查看目前時區
$ sudo timedatectl set-timezone Asia/Taipei // 設定時區
$ sudo timedatectl set-ntp true // 啟動NTP時間同步
$ vim /etc/systemd/timesyncd.conf // 編輯NTP伺服器清單
[Time]
NTP=tick.stdtime.gov.tw tock.stdtime.gov.tw time.stdtime.gov.tw clock.stdtime.gov.tw watch.stdtime.gov.tw
開啟rewrite
sudo a2enmod rewrite
設定防火牆
https://itw01.com/23BSOE3.html
https://www.peterdavehello.org/2016/01/ubuntu-based-gnulinux-firewall-ufw-essential-config/
https://www.peterdavehello.org/2016/01/ubuntu-based-gnulinux-firewall-ufw-essential-config/
------------------------
調整
sql_mode=""
//8.0
[mysqld]
sql_mode = "NO_AUTO_VALUE_ON_ZERO,ERROR_FOR_DIVISION_BY_ZERO"
參考:
磁碟指令:
df -m
可以看目前系統上的分割區容量資訊,單位是MB
使用的總空間大小,使用"$ du -h --max-depth=1"命令即可。
df -i
可以顯示分割區可存放的檔案數量
df -h 可知道目前硬碟剩餘空間與使用空間
du -h 可知目前此資料夾下所有檔案與資料夾所佔硬碟大小總數
du -s 可知目前此資料夾總共佔用硬碟大小總數,以G為單位
du -sh 可知目前此資料夾總共佔用硬碟大小總數,以G為單位
ls -l可看檔案大小
du -h -d 1 [按 Enter] (列出第一層子資料夾所佔用的空間)
du -h -d 1 [按 Enter] (列出第一層子資料夾所佔用的空間)
刪除30天前的關鍵字
find ./ -mtime +30 -name "u*" | xargs rm -rf
//////////////////////////////////////////////////////
檢查是否有檔案 fd 仍然被開著沒有關掉呢? 可以透過以下指令:
lsof /| grep '(deleted)'
lsof /| grep '(deleted)'
//////////////////////////////////////////////////////
設定使用者群組&權限
mysql max connect 214
https://sibevin.github.io/posts/2016-12-02-174519-mysql-max-connections-always-be-set-with-214
在 /etc/mysql/my.cnf 中加上的max_connections的設定
/etc/mysql/my.cnf[mysqld] max_connections=10000
但在查看實際的設定值仍然是214。
mysql> show global variables like '%max_connecti%';
造成這個問題是有兩個原因,一是系統的「一個process最大可開起的檔案數」的值預設是1024,可以使用 ulimit -a,或是從mysql下面的指令看到這個值:
sudo將下面的設定加入到/etc/security/limits.conf這個檔案。
/etc/security/limits.conf* soft nofile 65536 * hard nofile 65536
當設定完成,可以重啟系統讓設定值生效。第二個原因是在啟動mysql的時候要解除open file的限制,方法是在啟動mysql的service檔裡加上LimitNOFILE=65535的設定:
/lib/systemd/system/mysql.serviceLimitNOFILE=65535
當這兩步做完,重啟mysql之後,就可以看到正確的連線數設定了。
https://sibevin.github.io/posts/2016-12-02-174519-mysql-max-connections-always-be-set-with-214
在 /etc/mysql/my.cnf 中加上的max_connections的設定
/etc/mysql/my.cnf[mysqld] max_connections=10000
sudo將下面的設定加入到/etc/security/limits.conf這個檔案。
/etc/security/limits.conf
* soft nofile 65536 * hard nofile 65536
當設定完成,可以重啟系統讓設定值生效
第二個原因是在啟動mysql的時候要解除open file的限制,方法是在啟動mysql的service檔裡加上LimitNOFILE=65535的設定:
/lib/systemd/system/mysql.service
LimitNOFILE=65535
當這兩步做完,重啟mysql之後,就可以看到正確的連線數設定了。
manba 網路芳鄰
https://websiteforstudents.com/samba-setup-on-ubuntu-16-04-17-10-18-04-with-windows-systems/
sudo ufw allow from 10.10.10.58 to any app samba
更新phpmyadmin
https://devanswers.co/manually-upgrade-phpmyadmin/
定時執行
https://devanswers.co/backup-mysql-databases-linux-command-line/
sudo ufw allow from 10.10.10.58 to any app samba
更新phpmyadmin
https://devanswers.co/manually-upgrade-phpmyadmin/
定時執行
https://devanswers.co/backup-mysql-databases-linux-command-line/
SSH設定
~/.ssh/ (目錄):權限必須為 700 (drwx------)。
~.ssh/authorized_keys (Public Key)
權限必須為 644 (-rw-r--r--)。
擁有者必須屬於本身帳戶才行。
Linux 產生的 Private Key 轉換成 Windows 系統可識別的 *.ppk
Private Key 在 client端, public key 放在server
直接將公鑰資料複製到 server 的 ~/.ssh/authorized_keys
# 重新啟動 SSH 服務(Ubuntu Linux)
service sshd restart
調整一下 /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no