怎样安装Node.js

2018年8月7日 由 Amon 没有评论 »

【介绍】

Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,用来方便地搭建快速的易于扩展的网络应用。

Node.js 的包管理器 npm,是全球最大的开源库生态系统。

参考:https://www.nodeapp.cn/

【环境】

注意:操作系统的版本会影响,Nodejs的特性在64位、32位下很可能不兼容。别用老旧系统版本,直接使用最新的64位CentOS7。

比如:在搬瓦工的CentOS6系统下报错:

-bash: /usr/local/bin/node: cannot execute binary file

【安装】

NVM(Node version manager)是Node.js的版本管理软件,使用户可以轻松在Node.js各个版本间进行切换。

git clone https://github.com/cnpm/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`

激活NVM:

echo ". ~/.nvm/nvm.sh" >> /etc/profile
source /etc/profile

列出Node.js的所有版本:

nvm list-remote

安装多个Node.js版本:

nvm install v6.9.5
nvm install v7.4.0

注意,不同的Node.js版本对应不同的gzip版本。

参考:http://amon.org/gzip

gzip版本符合要求,返回:

######################################################################## 100.0%
Checksums empty
Now using node v7.4.0

gzip版本不符合要求,返回:

######################################################################## 100.0%
Checksums empty

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Binary download failed, trying source.

查看已安装Node.js版本:

nvm ls

输出:

         v6.9.5
->       v7.4.0
         system
stable -> 7.4 (-> v7.4.0) (default)
unstable -> 6.9 (-> v6.9.5) (default)

切换Node.js版本:

nvm use v6.9.5

输出:

Now using node v6.9.5

NVM的更多操作请参考帮助文档:

nvm help

【部署】

参考:http://www.tfan.org/nodejs-running-on-port-80-with-apache/
参考:https://blog.csdn.net/gaoxuaiguoyi/article/details/50927661
参考:https://blog.csdn.net/ruzhuxiaogu/article/details/52663657
参考:http://stackoverflow.com/questions/12701259/how-to-make-a-node-js-application-run-permanently
参考:https://zfanw.com/blog/apache-proxy-node-js.html
参考:https://help.aliyun.com/document_detail/50775.html
参考:https://www.zhihu.com/question/19887245
参考:https://www.jianshu.com/p/ee935729f49c
参考:https://segmentfault.com/a/1190000010205995

可使用 Apache 的 Proxy mode 使 Node.js 和 Apache 共用 80 端口。

首先,在 Apache 的配置文件中,开启 mod_proxy 和 mod_proxy_http:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

在vhost文件中添加:

<VirtualHost *:80>
	ServerName amon.org
	ServerAlias www.amon.org
	ProxyRequests off
	<Proxy *>
		Order deny,allow
		Allow from all
	</Proxy>
	<Location />
		ProxyPass http://amon.org:3000/
		ProxyPassReverse http://amon.org:3000/
	</Location>
	DocumentRoot /usr/local/apache2/htdocs/amon.org
	<Directory "/usr/local/apache2/htdocs/amon.org">
		AllowOverride All
	</Directory>
	ErrorLog /usr/local/apache2/htdocs/logs/error.log
	CustomLog /usr/local/apache2/htdocs/logs/access.log combined
</VirtualHost>

写一个index.js文件

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
 
app.get('/', function(req, res){
	res.send('<h1>Welcome Realtime Server</h1>');
});
 
http.listen(3000, function(){
	console.log('listening on *:3000');
});

运行一下 Node.js 脚本:

node index.js

报错:

...
Error: Cannot find module 'express'
...

参考:http://www.cnblogs.com/yumianhu/p/3732668.html

到当前项目目录下执行命令:

npm link express

报错:

...
Error: Cannot find module 'socket.io'
...

参考:http://www.cnblogs.com/yumianhu/p/3732668.html

到当前项目目录下执行命令:

npm link socket.io

输出:

listening on *:3000

重启httpd,然后访问配置的虚拟主机 www.amon.org ,页面显示:

Welcome Realtime Server

证明部署成功。

怎样配置mod_python

2018年8月1日 由 Amon 没有评论 »

【介绍】

Mod_python is an Apache module that embeds the Python interpreter within the server. With mod_python you can write web-based applications in Python that will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections and other data between hits and access to Apache internals. A more detailed description of what mod_python can do is available in this O’Reilly article.

官网:http://modpython.org/

介绍:http://www.cnblogs.com/ArtsCrafts/p/mod_python.html

【安装】

文档:http://modpython.org/live/current/doc-html/installation.html
文档:http://www.cnblogs.com/oubo/archive/2012/04/06/2434961.html

下载:github.com/grisha/mod_python

wget https://github.com/grisha/mod_python/archive/master.zip && unzip master.zip && cd mod_python-master
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/local/bin/python2.7  --with-flex=/usr/bin/flex
make && sudo make install

【配置】

编辑 /usr/local/apache2/conf/httpd.conf ,

添加:

LoadModule python_module modules/mod_python.so

测试1:

从 mod_python 3.2.0 开始,可以使用 mod_python.testhandler 来诊断配置问题:

添加:

<Location /mpinfo>
  SetHandler mod_python
  PythonHandler mod_python.testhandler
</Location>

重启 httpd:

service httpd stop && service httpd start

在浏览器中打开:http://webinfo.org/mpinfo ,返回系统配置信息页面。

测试2:

创建项目目录 /usr/local/apache2/htdocs/test/

创建文件 /usr/local/apache2/htdocs/test/mptest.py

from mod_python import apache

def handler(req):
    req.content_type = 'text/plain'
    req.write("Hello World!")
    return apache.OK

编辑 /usr/local/apache2/conf/httpd.conf ,

添加:

<Directory /usr/local/apache2/htdocs/test>
    AddHandler mod_python .py
    PythonHandler mptest
    PythonDebug On
</Directory>

浏览器中打开:http://webinfo.org/test/mptest.py ,返回页面显示:

Hello World!

怎样安装eppy

2018年7月30日 由 Amon 没有评论 »

【介绍】

EPP: EPP Client for Python

eppy is a Python-based API for the `Extensible Provisioning Protocol`_ (EPP), commonly used for communication between domain registries and registrars.

参考:https://pypi.org/project/EPP/
文档:https://pypi.org/project/EPP/0.6/

【安装】

pip install eppy

【使用】

使用SSl登录EPP服务器:

from eppy.client import EppClient
client = EppClient(ssl_keyfile='client.key', ssl_certfile='client.pem')
client.connect('server.example.tld')
resp = client.login('userid', 'secretpassword')

EPP documents can be sent as strings using the `EppClient.write` method. Alternatively, use the provided :class:`EPPDoc` subclasses.

from eppy.doc import EppInfoDomainCommand
cmd = EppInfoDomainCommand()
cmd.name = "example.org"
print cmd

输出:

<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<domain:info xmlns="urn:ietf:params:xml:ns:domain-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<name>example.org</name>
</domain:info>
</info>
</command>
</epp>

输入:

repr(cmd)

输出:

"{'epp': {'command': {'info': {'domain:info': {'name': 'example.org'}}}}}"

Using :class:`XmlDictObject`

:class:`XmlDictObject` is a convenience wrapper for generating and reading EPP
documents by translating to and from Python dictionary.

from eppy.xmldict import XmlDictObject
o = XmlDictObject({'x': {}})
print o.to_xml([])


输出:


<x />

Creating a child element with an attribute and text node:

o['x'] = {'d': {'@a': 'true', '_text': '1'}}
print o.to_xml({})

输出:

<x>
<d a="true">1</d>
</x>

As a shorthand for elements without attributes:

o['x'] = {'d': 1}
print o.to_xml({})

输出:

<x>
<d>1</d>
</x>

Multiple elements?

o['x'] = {'d': ['1', '2', '3']}
print o.to_xml({})

输出:

<x>
<d>1</d>
<d>2</d>
<d>3</d>
</x>

怎样安装epp-drs

2018年7月30日 由 Amon 没有评论 »

【介绍】

EPP-DRS(EPP域名注册系统)是一个强大的域名销售好管理系统。它可以运行域名注册服务的完整周期,比如注册、续费和转移。

系统WEB界面由以下三部分组成:
1. 域名订单向导
2. 注册人控制面板
3. 注册商控制面板

系统通过模块与不同的注册局和SRS通信,可以支持多达150个域名后缀。

文档良好的SDK允许开发者方便地构建和测试模块。

协议:EPP protocol (for EPP-based registry modules)RFCs 4930-4934

模板:Smarty

【安装】

下载:https://github.com/DicsyDel/epp-drs

手册; http://epp-drs.com/docs/
安装:http://epp-drs.com/docs/wiki/doku.php/wiki:epp-drs-installation-and-configuration-guide
接口:http://epp-drs.com/docs/wiki/doku.php/wiki:epp-drs.registry.modules.api

案例:https://www.norid.no/en/registrar/system/epp/ 挪威国别后缀.NO
下载:https://www.norid.no/uploads/2018/03/EppClient-0.97.tar.gz

wget https://github.com/DicsyDel/epp-drs/archive/master.zip && unzip master.zip && mv epp-drs-master portal && cd portal

参考:http://sourceforge.net/projects/aepps/ mod_epp

接口:https://www.sidn.nl/a/nl-domain-name/becoming-a-registrar?language_id=2&langcheck=true .NL注册商要求
接口:https://register.ly/domains/ly-domains/ .LY注册商要求

接口:https://github.com/registrobr/whmcs-registrobr-epp .BR整合WHMCS

需求列表:https://www.freelancer.co.za/job-search/sidn-epp-php/

需求:https://www.freelancer.uy/projects/php-website-design/epp-drs-new-templates-design/
需求:https://www.freelancer.uy/projects/php-software-architecture/epp-drs-whms-api/

php-epp-client Object-oriented PHP EPP Client to connect to ccTLD server

to register and manage ccTLD

the project will supports the following:

————————————

– Full EPP 57xx RFC standard
– Extensible PHP objects to add registry-specific additions
– Public/private key client certificates for connecting to EPP server
– Connection to EPP via HTTP/SSL – COCCA SERVER

Code/script will provide us with a fully functional EPP client to connect to any registry world-wide that supports EPP/COCCA.

——–

– check one domain name
– check multiple domain names and check how fast the registry is
– register a domain name
– change EPP password
– get information on a domain name
– update a domain name with new info
– create a contact object
– update contact details, ns, host
– DNSSEC sign a domain name
– list registry poll messages and confirm a message
-check if the domain is free
– register domain name

a list of methods that the library should support. Basically, most common operations for a hosting company like us:

– Retrieving / updating a domain contact information
– Retrieving / updating a domain name server (DNS) list
– Retrieving / updating a domain transfer lock
– Retrieving a domain expiration date
– Retrieving a domain security code
– Register a domain
– Renew a domain
– Transfer a domain
– Retrieve registered domain list in my account
– Retrieve expired / expiring domain list

Require a multi-layer/white label ICANN registrar automation system, like as orderbox ([login to view URL]) or Freenom ([login to view URL]).

The system will contain follwoing:

1. Customer and reseller front-end
2. Backend management including billing system
3. registrar whois server (port 43 application with socket protocol connection)
4. dns server
5. API server

Details are given below:

=> Customer Front-end
1. Product (domain) view, search, order.

=>Reseller Front-end
1. Reseller Pricing/Feature view and signup

=> Customer Back-end
1. Product (purchased) management
2. Billing (own) management
3. DNS management (for registered domains)
4. Payment Gateway (for add fund)

=>Reseller/sub-reseller Back-end
1. Manage order and billing
2. Customer/Reseller/sub-reseller management
3. Payment Gateway (for add fund)
4. Product/Pricing management
5. DNS Management
6. Brand and API management

=> Admin Panel Back-end
1. Everything of Reseller/Sub-reseller back-end
2. EPP Management (Registry API/SDK integration)
3. Other API Management (Such as SMS, email, other product, whois privacy etc)
4. Security Systems (Backup/Restore, Data migration, 2 factor authentication etc)
5. Emergency registrar integration
6. RDE Data export ([login to view URL]) system via admin panel.
7. Integration with API server (for remote product management) and whois server.

案例:https://github.com/diogotozzi/Epp
介绍:EPP protocol in PHP for interaction with Registro.br

案例:https://github.com/domainr/epp
介绍:EPP (Extensible Provisioning Protocol) client for Go. Extracted from and in production use at Domainr.com
作者:nb.io, LLC.

案例:https://github.com/AfriCC/php-epp2
介绍:A High Level EPP TCP/SSL Client for PHP

案例:https://github.com/centralnic/php-epp
介绍:EPP Support for PHP

案例:https://github.com/metaregistrar/php-epp-client
介绍:This code will provide you with a fully functional EPP client to connect to any registry world-wide that supports EPP. All code is organized in objects, so connecting to a new registry is just a matter of object re-use and extension. Sample registry connections are provided in the Registries directory.

Currently supported registries:

SIDN (.nl)
dotAmsterdam
Donuts
EurID (.eu)
DNS Belgium (.be .vlaanderen .brussels)
.CO.NL
dotFRL
IIS (.nu and .se)
CarDNS (.hr)
Metaregistrar
Nic.AT (.at)
Key Systems RRPPROXY
.PT
Switch (.ch)
Openprovider
Ficora (.fi)
DNS.PT (.pt)
Norid (.no)
Arnes (.si)

怎样安装Python-EPP

2018年7月29日 由 Amon 没有评论 »

参考:http://amon.org/python-epp
参考:http://amon.org/eppy

【介绍】

Python-EPP provides an interface to the Extensible Provisioning Protocol (EPP), which is being used for communication between domain name registries and domain name registrars.

EPP client written in Python. Development is still in an early phase, but most of this should actually work. Tested against the Dutch SIDN DRS5 interface.

官网:https://pypi.org/project/Python-EPP/
源码:https://github.com/jochem/Python-EPP

作者:Jochem Oosterveen
家乡:Amsterdam, NL

【安装】

wget https://github.com/jochem/Python-EPP/archive/master.zip && unzip master && cd Python-EPP-master
python setup.py build
python setup.py install

输出:

running install
...
Processing Python_EPP-0.1.0-py2.7.egg
Copying Python_EPP-0.1.0-py2.7.egg to /usr/local/lib/python2.7/site-packages
Adding Python-EPP 0.1.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/site-packages/Python_EPP-0.1.0-py2.7.egg
Processing dependencies for Python-EPP==0.1.0
Searching for BeautifulSoup==3.2.1
Best match: BeautifulSoup 3.2.1
Adding BeautifulSoup 3.2.1 to easy-install.pth file

Using /usr/local/lib/python2.7/site-packages
Finished processing dependencies for Python-EPP==0.1.0

【使用】

from EPP import EPP, Contact, Domain, Nameserver

config = {
    'host': '%s.domain-registry.nl' % ('testdrs' if args['test'] else 'drs'),
    'port': 700,
    'user': <user>,
    'pass': <pass>,
}
contacts = {
    'registrant': 'NEX001077-NEXTG',
    'admin': 'FJF000131-NEXTG',
    'tech': 'JOO011933-NEXTG',
}
ns = ['ns.nextgear.nl', 'ns2.nextgear.nl']

""" This wil automatically handle the greeting and login """
epp = EPP(**config)

""" Get the token for a given domain """
domain = Domain(epp, 'nextgear.nl')
print domain.token()

""" Lookup the IP for a given nameserver """
ns = Nameserver(epp, ns[0])
print ns.get_ip()

""" Get contact information for a given handle """
contact = Contact(epp, 'JOO011933-NEXTG')
print contact.info()