linux安装并配置nginx

维基百科 Nginx是异步框架的网页服务器,也可以用作反向代理、负载平衡器和HTTP缓存。 安装 官网:https://www.nginx.com/ 官网安装文档:http://nginx.org/en/docs/install.html 安装完成:http://127.0.0.1/ 管理命令 systemctl restart nginx.service 重启 systemctl status nginx.service 查看运行状态 systemctl start nginx.service 启动 systemctl stop nginx.service 关闭 systemctl enable nginx.service 开机自启 systemctl disable nginx.service 关闭开机自启 默认配置文件 以CentOS/7.3.1611、 nginx/1.12.2为例: 默认配置:/etc/nginx/nginx.conf # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ #user nginx; user root; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-streamo; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; autoindex on; autoindex_exact_size off; autoindex_localtime on; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2 default_server; # listen [::]:443 ssl http2 default_server; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } } 自己新加的conf可以放在cd /etc/nginx/conf.d目录下 ...

January 5, 2020 · 2 min · zhangxiaofeng05

SimpleHTTPServerWithUpload

简介 SimpleHTTPServerWithUpload.py是简单的上传下载的脚本 python2 github地址 https://gist.github.com/UniIsland/3346170 使用方法 方法一 python SimpleHTTPServerWithUpload.py 8050 8050为端口号,不写端口默认为8000 方法二 python -m SimpleHTTPServerWithUpload 8050 8050为端口号,不写端口默认为8000 访问:http://127.0.0.1:8050/ python3 github地址 https://gist.github.com/touilleMan/eb02ea40b93e52604938 使用方法 python SimpleHTTPServerWithUpload.py 端口为8000

January 4, 2020 · 1 min · zhangxiaofeng05

linux使用v2ray作为客户端

安装v2ray 官网: https://www.v2ray.com/ (被墙,如果可以,不明白的多看官网) github地址: https://github.com/v2ray/v2ray-core 在root用户环境下运行 yum 或 apt-get 安装v2ray 或者执行安装脚本bash <(curl -L -s https://install.direct/go.sh) 此脚本会自动安装以下文件: /usr/bin/v2ray/v2ray:V2Ray 程序; /usr/bin/v2ray/v2ctl:V2Ray 工具; /etc/v2ray/config.json:配置文件; /usr/bin/v2ray/geoip.dat:IP 数据文件 /usr/bin/v2ray/geosite.dat:域名数据文件 此脚本会配置自动运行脚本。自动运行脚本会在系统重启之后,自动运行 V2Ray。 脚本运行完成后,你需要: 编辑 /etc/v2ray/config.json 文件来配置你需要的代理方式; config.json { "inbound": { "port": 1080, "protocol": "socks", "domainOverride": ["tls","http"], "settings": { "auth": "noauth" } }, "outbound": { "protocol": "vmess", "settings": { "vnext": [ { "address": "216.244.76.219", "port": 54321, "users": [ { "id": "3cf35a68-ea46-11e9-9cab-003048d37a3c", "alterId": 64, "security": "aes-128-gcm" } ] } ] }, "streamSettings": { "network": "tcp", "security": "aes-128-gcm" } } } 运行 service v2ray start 来启动 V2Ray 进程; 之后可以使用 service v2ray start|stop|status|reload|restart|force-reload 控制 V2Ray 的运行。 或者使用 systemctl status v2ray.service systemctl start v2ray.service systemctl stop v2ray.service systemctl restart v2ray.service 图形客户端(推荐:支持订阅) v2rayN(第三方): https://github.com/2dust/v2rayN/releases/latest Windows,Linux,Mac

January 4, 2020 · 1 min · zhangxiaofeng05

vim安装插件

注意:推荐参考:https://github.com/zhangxiaofeng05/dotfiles 插件管理器(Vundle.vim) 安装 github地址:https://github.com/VundleVim/Vundle.vim (仔细看README.md) clone git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 修改配置文件 vim ~/.vimrc set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' "plugin------------------------" “Plugin '插件名' "看作者的README.md,有示例 "plugin------------------------" " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line Install Plugins Launch vim and run :PluginInstall To install from command line: vim +PluginInstall +qall 安装NERDTree 安装此插件需要安装插件管理器 github地址:https://github.com/preservim/nerdtree (仔细看README.md) ...

January 2, 2020 · 3 min · zhangxiaofeng05

linux安装mariadb并配置phpmyadmin

mariadb 维基百科 MariaDB是MySQL关系数据库管理系统的一个复刻,由社区开发,有商业支持,旨在继续保持在GNU GPL下开源。MariaDB的开发是由MySQL的一些原始开发者领导的,他们担心甲骨文公司收购MySQL后会有一些隐患。 linux现在默认的MySQL是mariadb。 安装mariadb $ sudo apt-get install mariadb-server mariadb-client 新建用户授权 以root身份输入mariadb,进入mariadb # mariadb > use mysql; # 进入mysql数据库 mysql> CREATE USER 'zhang'@'localhost' IDENTIFIED BY '123456'; # zhang是用户名,123456是密码 mysql> GRANT ALL PRIVILEGES ON *.* TO 'zhang'@'localhost' WITH GRANT OPTION; # 授权 mysql> FLUSH PRIVILEGES; 或者(推荐下边的,可以登录,上边只能本地登录) mysql> CREATE USER 'zhang'@'%' IDENTIFIED BY '123456'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'zhang'@'%' WITH GRANT OPTION; mysql> FLUSH PRIVILEGES; 查看user信息 > select user,host,password from user; 至此,可以用新建的用户登录了。 ...

December 29, 2019 · 6 min · zhangxiaofeng05

Docker

维基百科 https://zh.wikipedia.org/wiki/Docker Docker是一个开放源代码软件项目,让应用程序部署在软件货柜下的工作可以自动化进行,借此在Linux操作系统上,提供一个额外的软件抽象层,以及操作系统层虚拟化的自动管理机制。 docker官网 官网:https://www.docker.com/ 官网安装指南:https://docs.docker.com/install/ docker安装软件比较简单,很适合学习,避免了linux的各种版本安装软件的繁琐。 Docker Hub https://hub.docker.com/ Docker Hub是一个由Docker公司负责维护的公共注册中心,它包含了超过15,000个可用来下载和构建容器的镜像,并且还提供认证、工作组结构、工作流工具(比如webhooks)、构建触发器以及私有工具(比如私有仓库可用于存储你并不想公开分享的镜像)。 举例:docker安装MySQL 官网安装指南:https://hub.docker.com/_/mysql 举例: docker pull mysql:5.7.28 docker run -p 3306:3306 --name mysql5.7 -e MYSQL_ROOT_PASSWORD=password -d mysql:5.7.28 具参数查看官网!!! 举例:docker安装phpmyadmin 官网安装指南:https://hub.docker.com/r/phpmyadmin/phpmyadmin 举例: docker pull phpmyadmin/phpmyadmin docker run --name myadmin -d -e PMA_ARBITRARY=1 -p 6060:80 phpmyadmin/phpmyadmin 此命令安装,登录任意服务器地址端口,空格为分割 pull代理 使用docker pull命令,下载镜像慢, 镜像加速 https://docs.docker.com/docker-hub/image-library/mirror/ 设置代理 https://docs.docker.com/engine/daemon/proxy/ mac Dashboard -> Settings -> Resources -> Proxies 即可使用http代理 Web Server(HTTP) http://127.0.0.1:1081 Secure Web Server(HTTPS) http://127.0.0.1:1081 linux /etc/docker/daemon.json { "proxies": { "http-proxy": "http://127.0.0.1:1080", "https-proxy": "http://127.0.0.1:1080", "no-proxy": "localhost,127.0.0.0/8" } }

December 8, 2019 · 1 min · zhangxiaofeng05

ftp服务器

linux环境 LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.3.1611 (Core) Release: 7.3.1611 Codename: Core 安装 yum install vsftpd systemctl restart vsftpd.service # 重启vsftpd systemctl stop vsftpd.service # 停止vsftpd systemctl start vsftpd.service # 启动vsftpd systemctl status vsftpd.service # 查看vsftpd的状态 匿名配置 服务器配置文件 位置:/etc/vsftpd/vsftpd.conf 坑:从网上购买的服务器(阿里云)要从控制台开放ftp的端口,建议放开全部端口,如果有需要限制,再限制,否则会出现登录失败的问题 防火墙:开放所需端口 匿名设置:配置文件内容 anonymous_enable=YES #允许匿名登录 local_enable=YES write_enable=YES local_umask=022 #匿名上传的默认权限,匿名不能修改生效,只能上传删除 anon_upload_enable=YES #允许匿名上传 anon_mkdir_write_enable=YES anon_other_write_enable=YES dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_file=/var/log/xferlog xferlog_std_format=YES listen=YES listen_ipv6=NO pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES 匿名用户的默认根目录:/var/ftp/pub 需要更改权限:chmod -R 755 /var/ftp/pub 客户端(deepin) 安装: ...

December 1, 2019 · 1 min · zhangxiaofeng05

解决vim粘贴错乱问题

vim打开文件后 1、在视图模式下输入 :set paste 2、按i进入编辑模式 3、粘贴((win)Ctrl+v | Shift+Insert(linux)) 4、关闭粘贴 :set nopaste

November 28, 2019 · 1 min · zhangxiaofeng05

行为型模式-备忘录模式

百度百科 备忘录模式 备忘录模式是一种软件设计模式:在不破坏封闭的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将该对象恢复到原先保存的状态。 基本介绍 备忘录模式(Memento Pattern)又叫做快照模式(Snapshot Pattern)或Token模式,是GoF的23种设计模式之一,属于行为模式。 定义:在不破坏封闭的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将该对象恢复到原先保存的状态。 涉及角色: Originator(发起人):负责创建一个备忘录Memento,用以记录当前时刻自身的内部状态,并可使用备忘录恢复内部状态。Originator可以根据需要决定Memento存储自己的哪些内部状态。 Memento(备忘录):负责存储Originator对象的内部状态,并可以防止Originator以外的其他对象访问备忘录。备忘录有两个接口:Caretaker只能看到备忘录的窄接口,他只能将备忘录传递给其他对象。Originator却可看到备忘录的宽接口,允许它访问返回到先前状态所需要的所有数据。 Caretaker(管理者):负责备忘录Memento,不能对Memento的内容进行访问或者操作。 备忘录模式的优点和缺点 一、 备忘录模式的优点 有时一些发起人对象的内部信息必须保存在发起人对象以外的地方,但是必须要由发起人对象自己读取,这时, 使用备忘录模式可以把复杂的发起人内部信息对其他的对象屏蔽起来,从而可以恰当地保持封装的边界。 本模式简化了发起人类。发起人不再需要管理和保存其内部状态的一个个版本,客户端可以自行管理他们所需 要的这些状态的版本。 二、 备忘录模式的缺点: 如果发起人角色的状态需要完整地存储到备忘录对象中,那么在资源消耗上面备忘录对象会很昂贵。 当负责人角色将一个备忘录 存储起来的时候,负责人可能并不知道这个状态会占用多大的存储空间,从而无法提醒用户一个操作是否很昂贵。 当发起人角色的状态改变的时候,有可能这个协议无效。如果状态改变的成功率不高的话,不如采取“假如”协议模式。 例子 Memento 备忘录存储原发器对象的内部状态。 public class Memento { private String state; public Memento(String state) { this.state = state; } public String getState() { return state; } public void setState(String state) { this.state = state; } } Originator 原发器创建一个备忘录,用以记录当前时刻的内部状态。 使用备忘录恢复内部状态 public class Originator { private String state; public String getState() { return state; } public void setState(String state) { this.state = state; } public Memento createMemento(){ return new Memento(state); } public void setMemento(Memento memento){ state=memento.getState(); } public void showState(){ System.out.println(state); } } Caretaker 负责保存好备忘录。 不能对备忘录的内部进行操作或检查。 ...

August 30, 2019 · 1 min · zhangxiaofeng05

行为型模式-解释器模式

百度百科 Interpreter模式 Interpreter(解释器)模式是一种特殊的设计模式,它建立一个解释器(Interpreter),对于特定的计算机程序设计语言,用来解释预先定义的文法。简单地说,Interpreter模式是一种简单的语法解释器构架。 Interpreter模式,即解释器模式。 解释器模式属于行为模式,Gof是这样定义的:给定一个语言,定义它的文法的一种表示,并定义一个解释器,这个解释器使用该表示来解释语言中的句子。 解释器模式需要解决的是,如果一种特定类型的问题发生的频率足够高,那么可能就值得将该问题的各个实例表述为一个简单语言中的句子。这样就可以构建一个解释器,该解释器通过解释这些句子来解决该问题。 实例应用:正则表达式 例子 AbstractExpression(抽象表达式) 声明一个抽象的解释操作,这个接口为抽象语法树中所有的节点所共享。 public abstract class Expression { abstract void interpret(Context ctx); } TerminalExpression(终结符表达式) 实现与文法中的终结符相关联的解释操作。 一个句子中的每个终结符需要该类的一个实例。 public class SimpleExpression extends Expression { @Override void interpret(Context ctx) { System.out.println("这是普通解析器"); } } NonterminalExpression(非终结符表达式) 为文法中的非终结符实现解释(Interpret)操作。 public class AdvanceExpression extends Expression { @Override void interpret(Context ctx) { System.out.println("这是高级解析器"); } } Context(上下文) 包含解释器之外的一些全局信息。 import java.util.ArrayList; import java.util.List; public class Context { private String content; private List list = new ArrayList(); public String getContent() { return content; } public void setContent(String content) { this.content = content; } public void add(Expression eps){ list.add(eps); } public List getList(){ return list; } } Client(客户) 构建(或被给定)表示该文法定义的语言中某个特定的句子的抽象语法树。 该抽象语法树由NonterminalExpression和TerminalExpression的实例装配而成。调用解释操作。 ...

August 29, 2019 · 1 min · zhangxiaofeng05