Ubuntu设置静态IP
Ubuntu 16.04
bash
vim /etc/network/interfaces
修改配置文件
```
//codefile:/etc/network/interfaces
The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.200 # local IP Address
gateway 192.168.0.1
netmask 255.255.255.0
dns-nameservers 8.8.8.8 # specify dns ...
一些难记的Linux命令
显示所有进程信息,连同命令行: ps -ef
杀死进程(等同于Ctrl+C): kill -s 2 pid
根据进程名获取PID:ps -ef | grep name | grep -v grep | awk '{print $2}'
设置变量:pid=$(ps -ef | grep name | grep -v grep | awk '{print $2}')
杀死指定进程:kill -s 2 $pid
查看systemctl日志
bash
journalctl -u service-name.service
如无内容返回,检查system...
Nginx Location语法
URI匹配方式
1.前缀匹配
无修饰符: 前缀匹配
=: 精确匹配
^~: 前缀匹配,与无修饰符的区别是不再匹配正则表达式
2.正则表达式匹配
~*: 大小写不敏感
~: 大小写敏感
匹配优先级(顺序)
1.首先按照最长匹配原则校验前缀匹配方式的location。
如果匹配到的location带有修饰符^~或=,则不再进行第二步匹配,直接应用该location。
如果匹配到location暂时先记下来,继续进行第二步。
2.然后按配置文件里的顺序依次校验正则表达式匹配方式的location。
如果匹配到location就停止继...
CSS样式
图片指定宽长比
```html
```
padding-top计算百分比的基数是容器的width,示例中宽高比为4:3
percentage: The size of the padding as a percentage, relative to the inline size (width in a horizontal language, defined by writing-mode) of the containing block. Must be nonnegative.
css
.image {
...
正则表达式
转义字符
. $ ^ { [ ( | ) * + ? \
字符匹配
[character_group] 匹配 character_group中的任何单个字符。
[^character_group] 匹配不在character_group中的任意单个字符匹配。
[first-last] 匹配从first到last的范围中的任意单个字符匹配。
. 匹配除\n之外的任意单个字符。
\w 匹配任何单词字符,等同于[A-Za-z0-9_]。
\W 匹配任何非单词字符。
\s 匹配任何空白字符。
\S 匹配任何非空白字符。
\d 匹配任何十进制数字。
\D 匹配不是十...
MySQL安装
Ubuntu下安装
bash
sudo apt-get install mysql-server
登录MYSQL
根用户登录
bash
mysql -u root -p
指定用户名密码登录
bash
mysql --user=user_name --password=your_password
创建用户
bash
CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'user_name'@'%' IDENTIFIED BY 'password';
创建数据...
Ubuntu下安装Elasticsearch
JAVA安装
安装JAVA SDK
bash
sudo apt-get update
sudo apt-get install default-jdk
设置JAVA_HOME环境变量
bash
sudo vim /etc/environment
添加以下内容
//codefile:/etc/environment
JAVA_HOME="/usr/lib/jvm/[YOUR_JAVA_VERSION]"
刷新配置
bash
source /etc/environment
Elasticsearch安装
官网下载deb包...
Git简单命令说明
config
git config --local user.name "tongqijie"
git config --local user.email "tongqijie@hotmail.com"
git config credential.helper store
git config --local --unset user.password
git config --local advice.detachedHead false
git config --local http.sslVerify false
pull
git pull
pus...
Ubuntu下Gitlab安装、备份、恢复
安装
bash
sudo dpkg -i gitlab-ce_9.2.5-ce.0_amd64.deb
sudo gitlab-ctl reconfigure
备份
bash
sudo gitlab-rake gitlab:backup:create
默认备份文件位置: /var/opt/gitlab/backups
备份配置文件及密匙: /etc/gitlab/gitlab.rb、/etc/gitlab/gitlab-secrets.json
恢复
bash
sudo cp gitlab.rb /etc/gitlab/gitla...
Nginx设置IP白名单
修改配置文件
```nginx
//codefile:/etc/nginx/sites-enabled/example.conf
http {
...
allow xx.xx.xx.xx;
allow xx.xx.xx.xx;
deny all;
...
}
server {
...
allow xx.xx.xx.xx;
allow xx.xx.xx.xx;
deny all;
...
}
location / {
allow xx.xx.xx.xx;
allow xx.xx.x...