Basic Environment 基础环境配置,安装常用 shell 工具。
1 2 3 sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt autoremove -y sudo apt-get install -y zsh vim curl wget cloc unzip zip graphviz tree build-essential make cmake git openssh-server netcat net-tools tmux echo "set -g mouse on" > ~/.tmux.conf
ZSH 安装 zsh,更换默认 shell 为 oh-my-zsh,同时安装语法高亮与自动补全插件,并且更换 zsh 的主题为 bira。
1 2 3 4 5 6 7 8 sudo apt-get update chsh -s $(which zsh) git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrcgit clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom} /plugins/zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom} /plugins/zsh-autosuggestions sed -i 's/plugins=(git)/plugins=(git zsh-syntax-highlighting zsh-autosuggestions)/g' ~/.zshrc sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="bira"/g' ~/.zshrc
V2ray 1 2 sudo bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) sudo vim /usr/local/etc/v2ray/config.json
Web Server Apache2 1 2 sudo apt-get update sudo apt-get install -y apache2
Apache2 Configuration 修改 Apache2 mpm-prefork 模式的并发数量。
1 2 3 4 5 6 sudo sed -i "s/StartServers\s+\d+/StartServers 20/g" /etc/apache2/mods-available/mpm_prefork.conf sudo sed -i "s/MinSpareServers\s+\d+/MinSpareServers 20/g" /etc/apache2/mods-available/mpm_prefork.conf sudo sed -i "s/MaxSpareServers\s+\d+/MaxSpareServers 30/g" /etc/apache2/mods-available/mpm_prefork.conf sudo sed -i "s/MaxClients\s+\d+/MaxClients 500/g" /etc/apache2/mods-available/mpm_prefork.conf sudo sed -i "s/MaxRequestsPerChild\s+\d+/MaxRequestsPerChild 10000/g" /etc/apache2/mods-available/mpm_prefork.conf sudo sed -i "11a\\\tServerLimit 500" /etc/apache2/mods-available/mpm_prefork.conf
开启 URL 重写,设置默认的 ServerName,并重启 Apache。
1 2 3 4 sudo sed -i "s/AllowOverride None/AllowOverride ALL/g" /etc/apache2/apache2.conf sudo a2enmod rewrite echo "ServerName localhost" | sudo tee -a /etc/apache2/apache2.confsudo systemctl restart apache2
Server-Side Languages PHP 1 2 sudo apt-get update sudo apt-get install -y php libapache2-mod-php
Dependency 1 2 sudo apt-get install -y "php-(bcmath|gmp|ldap|simplexml|mysqli|curl|dom|xml|intl|pdo|gd|mysql|json|imap|imagick|sqlite3|zip|soap|mbstring|cgi|fpm|pear)" sudo systemctl restart apache2
Composer 1 2 3 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; sudo php composer-setup.php --install-dir=/usr/bin --filename=composer; rm composer-setup.php
PHP Multi-Version 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 sudo add-apt-repository ppa:ondrej/php && sudo add-apt-repository ppa:ondrej/apache2 sudo apt-get install -y php5.6 php7.4 php8.1 sudo apt-get install -y "php5.6-(bcmath|gmp|ldap|mysqli|curl|dom|xml|intl|pdo|gd|mysql|json|imap|imagick|sqlite3|zip|soap|mbstring|cgi|fpm|pear)" sudo apt-get install -y "php7.4-(bcmath|gmp|ldap|mysqli|curl|dom|xml|intl|pdo|gd|mysql|json|imap|imagick|sqlite3|zip|soap|mbstring|cgi|fpm|pear)" sudo apt-get install -y "php8.1-(bcmath|gmp|ldap|mysqli|curl|dom|xml|intl|pdo|gd|mysql|json|imap|imagick|sqlite3|zip|soap|mbstring|cgi|fpm|pear)" sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt autoremove -y sudo a2dismod php-7.4 sudo a2enmod php-8.1 sudo systemctl restart apache2 sudo update-alternatives --config php
PHP INI Configuration 仅在测试环境下可能会用到的配置,为了便于 debug。
1 2 3 4 5 6 7 8 9 10 11 12 13 sudo sed -i "s/disable_functions = /; disable_functions = /g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/max_execution_time = 30/max_execution_time = 60/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/max_input_time = 60/max_input_time = -1/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/;max_input_vars = 1000/max_input_vars = 3000/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/memory_limit = 128M/memory_limit = 256M/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/display_errors = Off/display_errors = On/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/display_startup_errors = Off/display_startup_errors = On/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/post_max_size = 8M/post_max_size = 32M/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/allow_url_include = Off/allow_url_include = On/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/;mysqli.allow_local_infile = On/mysqli.allow_local_infile = On/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 259200/g" /etc/php/?.?/apache2/php.ini sudo sed -i "s/session.cookie_lifetime = 0/session.cookie_lifetime = 259200/g" /etc/php/?.?/apache2/php.ini sudo systemctl restart apache2
Java 1 2 sudo apt-get update sudo apt-get install -y default-jdk
Python 1 2 sudo apt-get update sudo apt-get install -y python2 python3 python3-pip python3-flask python3-django python3-requests python3-venv
NodeJS 1 2 3 sudo apt-get update curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt-get install -y nodejs
GO 1 2 3 sudo add-apt-repository ppa:longsleep/golang-backports sudo apt-get update sudo apt-get install -y golang-go
Rust 1 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
C/C++ 1 2 sudo apt-get update sudo apt-get install -y gcc g++
Database MySQL 注意安装完成后需要从 /etc/mysql/debian.cnf
中获取默认的 MySQL 用户名和密码,用此用户名密码登录成功后再修改 root 的密码。
1 2 3 4 5 6 7 8 9 10 sudo apt-get update sudo apt-get install -y mysql-server mysql-client sudo cat /etc/mysql/debian.cnf | grep user sudo cat /etc/mysql/debian.cnf | grep password mysql -u xxxx -p mysql> alter user 'root' @'localhost' identified with mysql_native_password by 'root' ;
Redis 1 2 sudo apt-get update sudo apt-get install -y redis
SQLite 1 2 sudo apt-get update sudo apt-get install -y sqlite3
PostgreSQL 1 2 sudo apt-get update sudo apt-get install -y postgresql