存档在 ‘Linux’ 分类

Do I need to install pip?

2017年11月27日

Installation

Do I need to install pip?

pip is already installed if you’re using Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded from python.org, but you’ll need to upgrade pip.

Additionally, pip will already be installed if you’re working in a Virtual Environment created byvirtualenv or pyvenv.

Installing with get-pip.py

To install pip, securely download get-pip.py[2]

Then run the following:

python get-pip.py

Warning

Be cautious if you’re using a Python install that’s managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.

get-pip.py will also install setuptools [3] and wheel, if they’re not already. setuptools is required to install source distributions. Both are required to be able to build a Wheel Cache (which improves installation speed), although neither are required to install pre-built wheels.

Note

The get-pip.py script is supported on the same python version as pip. For the now unsupported Python 3.2, an alternate script is available here.

get-pip.py options

--no-setuptools
If set, don’t attempt to install setuptools

--no-wheel
If set, don’t attempt to install wheel

Additionally, get-pip.py supports using the pip install options and the general options. Below are some examples:

Install from local copies of pip and setuptools:

python get-pip.py --no-index --find-links=/local/copies

Install to the user site [4]:

python get-pip.py --user

Install behind a proxy:

python get-pip.py --proxy="[user:passwd@]proxy.server:port"

Upgrading pip

On Linux or macOS:

pip install -U pip

On Windows [5]:

python -m pip install -U pip

Python and OS Compatibility

pip works with CPython versions 2.6, 2.7, 3.3, 3.4, 3.5 and also pypy.

This means pip works on the latest patch version of each of these minor versions (i.e. 2.6.9 for 2.6, etc). Previous patch versions are supported on a best effort approach.

pip works on Unix/Linux, macOS, and Windows.


[1] For Python 2, see https://docs.python.org/2/installing, and for Python3, see https://docs.python.org/3/installing.
[2] “Secure” in this context means using a modern browser or a tool like curl that verifies SSL certificates when downloading from https URLs.
[3] Beginning with pip v1.5.1, get-pip.py stopped requiring setuptools to be installed first.
[4] The pip developers are considering making --user the default for all installs, including get-pip.pyinstalls of pip, but at this time, --user installs for pip itself, should not be considered to be fully tested or endorsed. For discussion, see Issue 1668.

linux 通过命令行获取本机外网IP

2017年10月9日
curl ifconfig.me
curl icanhazip.com
curl ident.me
curl whatismyip.akamai.com
curl tnx.nl/ip
curl myip.dnsomatic.com

shell判断一个进程是否存在,如果不存在重启该进程

2017年6月12日

Linux下shell脚本编程实例
判断一个进程是否存在,如果不存在重启该进程:

#!/bin/bash
while [ 1 ]
do
    SendMail_is_exstit=$(ps -ef | grep "feed SendMail" | grep -v grep | wc -l)
    if [ ${SendMail_is_exstit} == 0 ]
    then
        cd /var/www/sdkfeed/
                #要执行的脚本命令,我这里是跑redis队列发送邮件脚本
        ./app/Console/cake SendMail
                  
    fi
    sleep 60
done

单个项目配置composer

2017年5月22日

1.进入到项目根目录执行:

composer config repo.packagist composer https://packagist.phpcomposer.com
执行完查看composer.json后面自动新增了一段代码:

“repositories”: {
“packagist”: {
“type”: “composer”,
“url”: “https://packagist.phpcomposer.com”
}
}
2.也可以直接在composer.json文件后面新增上面的代码就ok了

centos低版本安装git 2.*

2017年5月2日

centos通过yum install git安装后默认为1.7,但是不支持https与ssh私有项目clone。
升级步骤,看似简单,但是中途会出现一些错误:

wget -O git.zip https://github.com/git/git/archive/master.zip
make prefix=/usr/local/git all 
make install

前向依赖

# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker

Mac搭建nginx+rtmp服务器

2017年3月23日

一、安装Homebrew

执行命令:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

如果已经安装过,而想要卸载:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

如果已经安装过,则不用安装!

二、安装nginx

先glone nginx项目到本地:

brew tap homebrew/nginx

执行安装:

brew install nginx-full --with-rtmp-module

通过操作以上步骤,nginx和rtmp模块就安装好了

三、运行nginx

执行命令:

 nginx

出现”Welcome nginx”,表示nginx服务器搭建成功了,而且已经安装了RTMP模块了:

四、配置nginx和rtmp

下面开始来配置nginx的rtmp模块。首先,我们要看看nginx安装到哪里了:

brew info nginx-full

出现如下类似信息:

==> Caveats
Docroot is: /usr/local/var/www
 
The default porthasbeensetin /usr/local/etc/nginx/nginx.confto 8080 sothat
nginxcanrunwithoutsudo.
 
nginxwillloadallfilesin /usr/local/etc/nginx/servers/.
 
- Tips -
Run port 80:
 $ sudochown root:wheel /usr/local/Cellar/nginx-full/1.10.0/bin/nginx
 $ sudochmod u+s /usr/local/Cellar/nginx-full/1.10.0/bin/nginx
Reload config:
 $ nginx -s reload
Reopen Logfile:
 $ nginx -s reopen
Stop process:
 $ nginx -s stop
Waiting onexitprocess
 $ nginx -s quit
 
To havelaunchdstarthomebrew/nginx/nginx-fullnowandrestartat login:
  brew servicesstarthomebrew/nginx/nginx-full
Or, if youdon't want/need a backgroundserviceyoucanjust run:
  nginx

从这些信息中,可以看到nginx.conf文件在:

/usr/local/etc/nginx/nginx.conf

nginx完整路径:

/usr/local/Cellar/nginx-full/1.10.0/bin/nginx

通过以下打开nginx.conf配置文件来配置:

vi /usr/local/etc/nginx/nginx.conf

直接滚动到最后一行,以就是在http {} 之后:

 
http {
    这里默认就有的,不用管这些
}
 
# 在http节点后面加上rtmp配置:
rtmp {
    server {
        listen 5920;
        applicationrtmplive {
            liveon;
            recordoff;
        }
    }
}
 

重启nginx:

/usr/local/Cellar/nginx-full/1.10.0/bin/nginx -s reload

五、安装ffmpeg

输入以下命令来安装ffmpeg:

 brew install ffmpeg

安装这个需要等一段时间,然后准备一个视频文件作为来推流,我们在安装一个支持rtmp协议的视频播放器,Mac下可以用VLC。

六、ffmpeg推流

ffmpeg -re -i /Users/huangyibiao/Desktop/test.mov -vcodeclibx264 -acodecaac -f flv rtmp://localhost:5920/rtmplive/room

将视频推流到服务器后,打开VLC,然后file->open network->输入:

rtmp://localhost:5920/rtmplive/room

观看视频!

小结

终于安装解决RTMP服务器了,后面可以自己尝试去学习相关技术了!

多波项目开发板挂载设置备份

2017年2月21日

IMG_6741

解决ssh_exchange_identification:read connection reset by peer 原因

2017年2月21日

服务器改了密码,试过密码多次后出现:

ssh_exchange_identification: read: Connection reset by peer

可以通过ssh -v查看连接时详情

ssh -v root@ip地址或域名

会出现以下信息:

OpenSSH_6.6.1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to xxx [xx] port 22.
debug1: Connection established.
debug1: identity file /home/yanue/.ssh/id_rsa type -1
debug1: identity file /home/yanue/.ssh/id_rsa-cert type -1
debug1: identity file /home/yanue/.ssh/id_dsa type -1
debug1: identity file /home/yanue/.ssh/id_dsa-cert type -1
debug1: identity file /home/yanue/.ssh/id_ecdsa type -1
debug1: identity file /home/yanue/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/yanue/.ssh/id_ed25519 type -1
debug1: identity file /home/yanue/.ssh/id_ed25519-cert type -1
........

解决方法:

vi /etc/hosts.allow

全部注释,追加:

sshd: ALL

重启ssh就ok了

service sshd restart