Ubuntu中下載和安裝Tornado+Nginx+Redis

(一)

1.離線安裝

Tornado官網(wǎng)中獲取

命令:tar xzvf tornado-1.2.1.tar.gz

cd tornado-1.2.1

python setup.py build

sudo python setip.py install

2.在線安裝【pip】

命令:pip install tornado

3.測(cè)試

test.py

import tornado.ioloop

import tornado.web

class MianHandler(tornado.web.RequestHandler):

def get(self):

? ? ? ?self.write("Hello XX")

application = tornado.web.Application([

(r"/",MainHandler),

])

if __name__=="__main__":

?application.listen(8888)

tornado.ioloop.IOLoop.instance().start()

4.輸出

python test.py

啟動(dòng)tornado進(jìn)程,訪問(wèn)http://127.0.0.1:8888即可打印Hello XX

(二)

1.安裝Nginx

命令:cd /etc

sudo apt-get install nginx

2.啟動(dòng)Nginx

命令:sudo /etc/init.d/nginx start

然后訪問(wèn)http://localhost/

(三)

1.安裝Redis

官網(wǎng)獲取

命令:wget http://download.redis.io/release/redis-3.2.0.tar.gz

解壓:tar xzvf redis-3.2.0.tar.gz

進(jìn)入:cd redis-3.2.0

編譯:sudo make

安裝:sudo make install

測(cè)試:sudo make test

2.移動(dòng)文件,便于管理

sudo mkdir -p /usr/local/redis/bin

sudo mkdir -p /usr/local/redis/etc

mv /Downloads/redis-3.2.0/redis-conf /usr/local/redis/etc

cd /Downloads/redis-3.2.0/src

mv mkreleasehdr.sh redis-benchmark redis-check-aof ?redis-check-rdb redis-cli redis-server /usr/local/redis/bin

3.啟動(dòng)Redis服務(wù)

/usr/local/redis/bin/redis-server

/usr/local/redis/etc/redis.conf

Redis服務(wù)端的默認(rèn)連接端口是6379

4.客戶端連接

/usr/local/redis/bin/redis-cli

5.停止Redis

/usr/local/redis/bin/redis-cli

shutdown

或者pkill redis-server

6.Redis的配置

daemonize ? ? ? ?如果需要在后臺(tái)運(yùn)行,把該項(xiàng)改為yes

pidfile ? ? ? ? ? ? ? ? ?配置多個(gè)pid的地址默認(rèn)在/var/run/redis.pid

bind ? ? ? ? ? ? ? ? ? ?綁定ip,設(shè)置后只接受來(lái)自該ip的請(qǐng)求

port ? ? ? ? ? ? ? ? ? ? 監(jiān)聽(tīng)端口,默認(rèn)為6379

timeout ? ? ? ? ? ?設(shè)置客戶端連接時(shí)的超時(shí)時(shí)間,單位為秒

loglevel ? ? ? ? ? ? 分為4級(jí),debug/verbose/notice/warning

logfile ? ? ? ? ? ? ? ? ? 配置log文件地址

databases ? ? ? ? ? ?設(shè)置數(shù)據(jù)庫(kù)的個(gè)數(shù),默認(rèn)使用的數(shù)據(jù)庫(kù)為0

save ? ? ? ? ? ? ? ? ? 設(shè)置redis進(jìn)行數(shù)據(jù)庫(kù)鏡像的頻率

rbdcompression ? ? 在進(jìn)行鏡像備份時(shí),是否進(jìn)行壓縮

Dbfilename ? ? ? ? ? ? 鏡像備份文件的文件名

Dir ? ? ? ? ? ? ? ? ? ? ? ? ?數(shù)據(jù)庫(kù)鏡像備份的文件防止路徑

Slaveof ? ? ? ? ? ? ? ?設(shè)置數(shù)據(jù)庫(kù)為其他數(shù)據(jù)庫(kù)的主從數(shù)據(jù)庫(kù)

Masterauth ? ? ? ? ? ? 主數(shù)據(jù)庫(kù)連接需要的密碼驗(yàn)證

Requirepass ? ? ? ? ? ?設(shè)置登錄時(shí)需要使用的密碼

Maxclients ? ? ? ? ? ? 限制同時(shí)連接的客戶數(shù)量

Maxmemory ? ? ? ? ?設(shè)置redis能夠使用的最大內(nèi)存

Appendonly ? ? ? 開(kāi)啟append only模式

Appendfsync ? ? ? ? ?設(shè)置對(duì)appendonly.aof文件同步的頻率

vm-enabled ? ? ? 是否開(kāi)啟虛擬內(nèi)存支持

vm-swap-file ? ? ? ? 設(shè)置虛擬內(nèi)存交換文件路徑

vm-max-memory ? ? ?設(shè)置redis使用的最大物理內(nèi)存大小

vm-page-size ? ? ? ? ? ?設(shè)置虛擬內(nèi)存的頁(yè)大小

vm-pages ? ? ? ? ? ? ? ? ? ? 設(shè)置交換文件的總的page數(shù)量

vm-max-threads ? ? ? 設(shè)置VMIO同時(shí)使用的線程數(shù)量

Glueoutputbuf ? ? ? ?把小的輸出緩存存放在一起

hash-max-zipmap-entries ? ? ? ?設(shè)置hash的臨界值

Activerehashing ? ? ? ? ? ?重新hash

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容