2018_10_28_03.md 11 KB

SERVES

配置 ftp 服务器

安装 vsftp

sudo apt-get update
sudo apt-get install vsftpd

创建 ftp 文件夹

sudo mkdir  *ftp文件夹*

更改文件夹权限

sudo  chmod -R 777 *ftp文件夹*

创建 FTP 用户

# 创建用户并指定目录
sudo useradd -d *ftp文件夹*/ 用户名
# 设置ftp用户的密码
sudo passwd ftp用户名

设置相关配置

sudo vim /etc/vsftpd.conf
# 添加如下内容
userlist_deny=NO
userlist_enable=YES
# 允许登录的用户
userlist_file=/etc/allowed_users
seccomp_sandbox=NO
# 允许访问的文件夹
local_root=*ftp文件夹*
local_enable=YES
write_enable=YES
# 使用utf8
utf8_filesystem=YES

修改 /etc/pam.d/vsftpd

sudo vim /etc/pam.d/vsftpd
# 在auth required pam_shells.so前加#

操作命令

# 启动停止重启服务
sudo /etc/init.d/vsftpd start
sudo /etc/init.d/vsftpd stop
sudo /etc/init.d/vsftpd restart
# 查看服务状态
service vsftpd status

访问 ftp 服务器

# bash 访问
sudo ftp 127.0.0.1
# 浏览器访问
ftp://127.0.0.1
# 或者
ftp//localhost

注意点

# a).服务器需要设置安全策略组权限
# b).ftp文件夹注意设置权限

参考

最简单靠谱的 vsftpd 安装指南(Ubuntu16.04)
Ubuntu 16.04 安装 ftp 服务器传输文件

nginx

说明

安装 nginx,是为了方便安装 wordpress; 所以在安装过程中,将 nginx 的站点路径设置指向 wordPress 所在目录。

安装 nginx

sudo apt-get install nginx

配置 nginx

# 进入编辑模式
sudo vim /etc/nginx/sites-available/default
# 将default中内容改为以下内容
  # include snippets/snakeoil.conf;
  root /var/www/html;
  # Add index.php to the list if you are using PHP
  # index index.html index.htm index.nginx-debian.html;
   index index.php
   location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      #
      #       # With php7.0-cgi alone:
      #       fastcgi_pass 127.0.0.1:9000;
      #       # With php7.0-fpm:
      fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
# 保存退出

运行 nginx

# 配置快捷启动方式
sudo vim /etc/init.d/nginx //创建启动脚本
sudo chmod a+x /etc/init.d/nginx //增加执行权限
# 启动-停止-重启
sudo /etc/init.d/nginx start //启动
sudo /etc/init.d/nginx stop //停止
sudo /etc/init.d/nginx restart //重启

参考文章

Ubuntu 下 Nginx 安装

查看 nginx 进程:nginx 的进程由主进程和工作进程组成

ps -ef|grep nginx

启动 nginx

service nginx start
# 平滑启动nginx
kill -HUP `cat /var/run/nginx.pid`
# or
nginx -s reload

停止 nginx

# 完美停止nginx
kill -TERM `cat /var/run/nginx.pid`
# or
kill -INT `cat /var/run/nginx.pid`
# 完美停止工作进程
kill -WINCH `cat /var/run/nginx.pid`
# 强制停止nginx
pkill -9 nginx
# 停止nginx的命令
nginx -s stop

检查对 nginx.conf 文件的修改是否正确

nginx -t -c /etc/nginx/nginx.conf
或者
nginx -t

查看 nginx 的版本信息

nginx -v

mysql

安装 mysql

# 检查系统是否已经安装mysql
which mysql  # /user/bin/mysql
# 安装mysql # 安装时根据安装提示设置相关mysql
sudo apt-get install mysql-server mysql-client
# 测试是否安装成功
sudo netstat -tap | grep mysql
# 登录mysql
mysql -u root -p
# 设置密码
mysqladmin -u root password "new_password";

登录

mysql -u 用户名 -p
Enter password: 输入密码

操控数据库

以下命令需要登录mysql之后,才能执行
# 显示所有数据库
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| WP                 |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

# 创建数据库
create database 数据库名
# 删除数据库
drop database 数据库名

登录

mysql -u 用户名 -p => 回车 => 输入密码

创建数据库

create database 库名;

导入备份数据

source 数据路径;

参考

MySQL 教程 >Ubuntu 16.04 mysql 安装配置

WordPress

安装 mysql
> 安装 ftp
> 安装 nginx
>ubuntu 16.04 LTS 下 php 环境配置

接下来开始 WP 的安装了 首先下载源代码 wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz

GRUN

编辑

#进入GRUN
sudo vim /etc/default/grub
# 在文件中。将相关内容设置为如下内容
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="acpi=off"

保存修改&配置到系统

sudo update-grup

apci=off

禁用部分设备硬件,提高系统响应速度。特别是使用 HHD 作为系统盘的情况下。效果显著

nomodeset

最新的内核已经把视频模式设置嵌入内核中,所以所有显卡硬件程序的指定时钟和寄存器当图形服务器启动时在内核进行而不是图形设备运行,这使得我们在启动时可以看到不闪的和高分辨率的好看的启动界面,但是,在某些视频卡它不能正常工作而现实黑屏,增加 nomodeset 参数则告诉内核不要加载显卡而用 BIOS 模式直到图形界面运行


The newest kernels have moved the video mode setting into the kernel. So all the programming of the hardware specific clock rates and registers on the video card happen in the kernel rather than in the X driver when the X server starts.. This makes it possible to have high resolution nice looking splash (boot) screens and flicker free transitions from boot splash to login screen. Unfortunately, on some cards this doesnt work properly and you end up with a black screen. Adding the nomodeset parameter instructs the kernel to not load video drivers and use BIOS modes instead until X is loaded.

quiet

内核启动时候简化提示信息

splash

启动的时候使用图形化的进度条代替 init 的字符输出过程

详细代码

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="acpi=on"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

L2TP Client

添加源

sudo add-apt-repository ppa:nm-l2tp/network-manager-l2tp

更新缓存

sudo apt-get update

安装 network-manager-l2tp

sudo apt install network-manager-l2tp

安装 UI

sudo apt install network-manager-l2tp-gnome

配置 配置网关:,,,
设置用户名: ***

docker

前端环境开发

How to use Docker containers for Vue.js applications

win10 运行 linux 容器

资料
Docker-no-Windows-vs-Docker-no-Linux
Docker 配置本地镜像与容器的存储位置
搜索条件:docker OSType

Development mode

docker run --rm -v $(pwd):/src -w /src -p 8080:8080 node:6 bash -c "npm install && npm run dev"

Build for production

docker run --rm -v $(pwd):/src -w /src node:6 bash -c "npm install && npm run build"

Command breakout

--rm tells Docker to delete the container when it is stopped (otherwise you’ll end up with a new container every time you start or build your app).

node:6 is the name of the image.

-v .:/src mounts the current directory (.) at the root of the container in a folder named /src. This is very similar to a virtual drive (Windows) or a virtual disk (Un*x/OSX).

-w /src sets the container’s working directory (where commands will be executed) at the folder we just created.

-p 8080:8080 opens the port 8080 of the container to your local browser (needed by Webpack dev server)

bash -c "..." starts a new bash instance inside the container, useful for such complicated bash commands using an && that may be misinterpreted by your system’s shell.

mongodb

1、添加 MongoDB 公共 GPG 钥匙。

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

2、创建列表文件,官方 ubuntu16.04 安装代码如下:

echo "deb http://repo.mongodb.org/apt/ubuntu\
 xenial/mongodb-org/3.2 multiverse"\
  | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

因为我们要替换国内的镜像,所以这里就不能使用 repo.mongodb.org 作下载地址了。把官方这句替换如下:

echo "deb http://mirrors.aliyun.com/mongodb/apt/ubuntu\
 xenial/mongodb-org/3.2 multiverse"\
  | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

3、重新加载本地包数据库

sudo apt-get update

4、安装 MongoDB

sudo apt-get install -y mongodb-org

5、启动 MongoDB

sudo service mongod start

6、打开 MongoDB

sudo mongo

VPN

检测服务器是否开启 bbr 加速

sysctl net.ipv4.tcp_congestion_control

shadowsocks 使用指南

自定义命令:开启ss服务

sudo ssserver -p 1134 -k 132546tt -m rc4-md5 --user nobody -d start
docker run -d --name=mygogs -p 10022:22 -p 10080:3000 -v /home/feishu/code/MyCode/01-docker/gogs:/data gogs/gogs

docker run --name first-mysql -p 3306:3306 -e MYSQL\_ROOT\_PASSWORD=123456 -d mysql


docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6