debian 10 开发环境部署

本地用Vagrant+VirtualBox创建、管理虚拟机,部署与阿里云ECS硬件和软件配置相近的开发环境(LNMP)。

安装 vim

su
apt-get install vim

vim /etc/vim/vimrc
#去掉 syntax on 前的注释,增加:
  set number
  set tabstop=4
  set softtabstop=4
  colorscheme desert

安装 sudo

apt-get install sudo

vim /etc/sudoers 
#增加:
  shagon ALL=(ALL:ALL) NOPASSWD:ALL

ssh配置

vim ~/.ssh/authorized_keys

#禁止 root 远程密码登录
sudo vim /etc/ssh/sshd_config
#增加:
  PermitRootLogin no
  PasswordAuthentication no

定时校准时间

sudo apt-get install ntpdate

crontab -e
#每天 2 点同步时间
  0 2 * * * sudo ntpdate -u ntp.ubuntu.com

禁用 swap

sudo vim /etc/sysctl.conf
#添加:
  vm.swappiness=0

sudo vim /etc/fstab
#将 swap 所在行注释掉

取消开机菜单

sudo vim /etc/default/grub
#修改:
  GRUB_DEFAULT=0
  GRUB_HIDDEN_TIMEOUT=0
  GRUB_HIDDEN_TIMEOUT_QUIET=true
  GRUB_TIMEOUT=0

sudo update-grub

安装 oh-my-zsh

sudo apt-get install zsh
sudo apt-get install git
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
sudo apt-get install autojump

#皮肤配置放入 ~/.oh-my-zsh/themes

vim ~/.zshrc
#修改配置
  ZSH_THEME="shagon"
  DISABLE_AUTO_UPDATE="true"
  plugins=(git autojump)

  alias l='ls -lahF --color=auto'
  alias ll='ls -lhF --color=auto'
  alias ls='ls -GF --color=auto'

安装nginx

sudo apt-get install nginx

sudo vim nginx.conf
#修改 http {} 中内容
  client_max_body_size 1000m;
  server_tokens off;
  proxy_hide_header X-Powered-By;
  gzip_disable "msie6";
  gzip_comp_level 9;
  gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png video/mp4;

  proxy_buffer_size  128k;
  proxy_buffers   32 32k;
  proxy_busy_buffers_size 128k;

安装redis

sudo apt-get install redis-server

#配置纯内存运行
sudo vim /etc/redis/redis.conf

  #save 900 1
  #save 300 10
  #save 60 10000
  maxmemory 1GB
  maxmemory-policy volatile-lru
  appendfsync no

#解决各种报警
sudo vim /etc/sysctl.conf

  net.core.somaxconn=1024
  vm.overcommit_memory = 1
  vm.nr_hugepages=512
  net.ipv4.icmp_echo_ignore_all=1

sudo vim /etc/rc.local

  #!/bin/sh -e
  ulimit -n 65536
  echo never > /sys/kernel/mm/transparent_hugepage/enabled

sudo chmod +x /etc/rc.local
sudo systemctl start rc-local.service

安装 mysql

sudo apt-get install mariadb-server-10.3

#设置账号
MariaDB > set password for root@localhost = password('password');
MariaDB > create user user@localhost identified by 'password';
MariaDB > grant select, insert, update, delete, alter on *.* to user@localhost;

#导出
mysqldump --opt -uroot -p table > table.sql

#导入
mysql -uroot -p table < table.sql

安装 php

sudo apt-get install php7.3 php7.3-fpm php7.3-dev

sudo vim /etc/php/7.3/fpm/php.ini
#修改:
  error_reporting = E_ALL
  display_errors = On
  post_max_size = 2048M
  upload_max_filesize = 2048M
  pdo_mysql.cache_size = 2000

  session.save_handler = redis
  session.save_path = tcp://127.0.0.1:6379

sudo vim /etc/php/7.3/cli/php.ini
#修改:
  short_open_tag = On
  error_reporting = E_ALL
  display_errors = On
  memory_limit = -1

  [opcache]
  opcache.enable=1
  opcache.enable_cli=1
  opcache.memory_consumption=512
  opcache.interned_strings_buffer=8
  opcache.max_accelerated_files=10000
  opcache.max_wasted_percentage=5
  opcache.use_cwd=1
  opcache.validate_timestamps=1
  opcache.revalidate_freq=60
  opcache.revalidate_path=0
  opcache.save_comments=0
  opcache.enable_file_override=0
  opcache.file_cache=/tmp
  opcache.huge_code_pages=1

安装 php 扩展

sudo apt-get install php-redis
sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-mbstring
sudo apt-get install php7.3-curl
sudo apt-get install php7.3-gd
sudo apt-get install php-imagick

#安装 yaf
sudo pecl install yaf
sudo vim /etc/php/7.3/mods-available/yaf.ini
#写入
  extension=yaf.so
  yaf.use_namespace=1
  yaf.environ=develop
  yaf.cache_config=1
  yaf.lowcase_path=1

cd /etc/php/7.3/fpm/conf.d
sudo ln -s ../../mods-available/yaf.ini 10-yaf.ini

#安装分词系统
sudo su
cd /tmp
wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2
tar xvjf scws-1.2.3.tar.bz2
cd scws-1.2.3
./configure --prefix=/usr/local/scws; make; make install
cd /usr/local/scws/etc
wget http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2
tar xvjf scws-dict-chs-utf8.tar.bz2
cd /tmp/scws-1.2.3/phpext
phpize
./configure --with-scws=/usr/local/scws; make; make install

vim /etc/php/7.3/mods-available/scws.ini
#写入
  extension = scws.so
  scws.default.charset = utf8
  scws.default.fpath = /usr/local/scws/etc

cd /etc/php/7.3/fpm/conf.d
ln -s ../../mods-available/scws.ini 20-scws.ini

安装视频处理软件

sudo apt-get install ffmpeg

安装 glup

sudo su
apt-get install npm
npm install npm gulp -g
cd /; mkdir gulp; cd gulp
npm install --save-dev gulp merge-stream gulp-csso gulp-uglify gulp-fontmin gulp-ttf2woff gulp-ttf2woff2
2 月 13 日 傍晚
添加