欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

linux及git记录

程序员文章站 2022-03-28 19:37:42
...

清空Github上某个文件的历史

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch app/img/*' --prune-empty --tag-name-filter cat -- --all

git push origin master --force

rm -rf .git/refs/original/

git reflog expire --expire=now --all

git gc --prune=now

git gc --aggressive --prune=now

使用 iconv 对大文件编码转换 GB2312 - UTF8

iconv -f gb2312 -t utf-8//IGNORE av-ed2k-合集.data > 日语教学.txtwc -l 日语教学.txt av-ed2k-合集.data

Nginx 上限制单 IP 单位时间的请求数,以及单 IP 的并发连接数

http {

limit_req_zone $binary_remote_addr zone=one:10m rate=8r/s;

server {
    location /search/ {
        limit_req zone=one burst=5;
    }

使用 Nginx 限制页面访问权限

sudo apt-get install apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd myusername
server {
  listen       80;
  server_name  ip_address;

  location /backend {
      root   /var/www/sunzhongwei.com;
      index  index.html index.htm;

      auth_basic "Restricted";                                
      auth_basic_user_file /etc/nginx/.htpasswd;  
  }
}

sudo /etc/init.d/nginx reload

命令行登陆github

ssh-keygen -t rsa -C "邮件"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/MZero/.ssh/id_rsa):

登陆github。点击右上角的 Account Settings—>SSH and GPG keys —> new SSH key
$ ssh -T git@github.com
若有You’ve successfully authenticated提示,说明成功了

git pull/push项目的时候总是提示要输入用户名密码的解决方案

git config --global credential.helper store

服务器设置允许mysql远程登录

vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
service iptables restart
grant all on aaa.* to "root"@xx .yy.zz.cc identified by "123";
flush privileges;
grant all on aaa.* to "root"@"%" identified by "123";

ssh 配置秘钥登录

ssh-keygen -t rsa -C "you@homestead"

$ sudo vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizeKeyFile ~/.ssh/authorized_keys
service sshd restart
将公钥文件的内容追加到 ~/.ssh/authorized_keys 文件中,并且将文件权限置成 600
chmod 600 ~/.ssh/authorized_keys

$ vim .bash_profile
alias c14='ssh [username]@[server_ip] (-i ~/.ssh/[私钥文件])'
$ source .bash_profile
$ c14

Nginx 报 502 的解决思路

nginx报错,查看nginx日志排错
nginx报502 bad gate way一般是因为没有配置好php-fpm
修改nginx或者php-fpm配置文件之后重启生效

nginx 添加 https 和 http2 模块支持

curl https://nginx.org/download/ng... |\
tar xzf - && cd nginx-* # get latest nginx & extract it
./configure [old_config_arguments] --with-http_ssl_module --with-http_v2_module # 前面 [old_config_arguments] 可以从 nginx -V 里 copy
make
sudo make install
listen 443 ssl http2;
ssl_certificate /home/*/ssl/chained.pem;
ssl_certificate_key /home/*/ssl/domain.key;
ssl_dhparam /home/*/ssl/dhparams.pem;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+ 3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets on;
add_header Strict-Transport-Security max-age=31536000;
service reload nginx

pphpmyadmin 缺少 mcrypt 扩展

sudo apt-get install php-mcrypt libmcrypt libmcrypt-devel
sudo ln -s /etc/php5/mods-available/mcrypt.ini 20-mcrypt.ini
sudo service apache2 restart

curl命令查看请求响应时间方法

curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"n" http://www.36nu.com

0.014::0.015::0.018::0.019::1516256.00

用github来展示你的前端页面

创建项目新建gh-pages分支 通过 http://(user_name|org_name).g... 访问
一种更加简便的方式来实现:将代码上传至仓库后在settings里配置下GitHub Pages为你想展示的分支就行了

相关标签: git github linux