配置linux服务器常用命令

  1. 1. 安装lnmp
  2. 2. 安装composer
  3. 3. 配置 www \ www-data 用户权限
  4. 4. 安装ohmyzsh
  5. 5. 安装配置node环境
  6. 6. 配置git

安装lnmp

1
2
3
4
5
6
7
8
9
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt install -y language-pack-en-base
locale-gen en_US.UTF-8
sudo apt -y install php7.1
sudo apt install -y php7.1-fpm php7.1-mysql php7.1-curl php7.1-xml php7.1-mcrypt php7.1-json php7.1-gd php7.1-mbstring
sudo apt install mysql-server-5.7
sudo apt install nginx
sudo apt install redis-server php-redis

安装composer

1
2
3
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"\nphp composer-setup.php
php -r "unlink('composer-setup.php');"

配置 www \ www-data 用户权限

1
2
3
4
5
sudo -Hu www-data ssh-keygen -t rsa -C "entimm@gmail.com"
sudo chown -R www-data:www-data /var/www/
sudo visudo
sudo passwd www-data
vim /etc/passwd

安装ohmyzsh

1
2
apt install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

安装配置node环境

1
2
3
4
5
curl --silent --location https://deb.nodesource.com/setup_4.x | bash -
apt install -y nodejs
npm install -g gulp
npm install -g bower
echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \\n --cache=$HOME/.npm/.cache/cnpm \\n --disturl=https://npm.taobao.org/dist \\n --userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc

配置git

1
2
git config --global user.name entimm
git config --global user.email entimm@gmial.com