Nginx+lua(openresty)開發環境搭建shell指令碼
下面是自動搭建的指令碼,採用的是直接殺死本機執行80埠的程式。
#!/bin/bash
mkdir -p /usr/servers
cd /usr/servers/
yum install -y perl pcre-devel openssl openssl-devel gcc curl
wget http://openresty.org/download/ngx_openresty-1.7.7.2.tar.gz
tar -xzvf ngx_openresty-1.7.7.2.tar.gz
cd /usr/servers/bundle/LuaJIT-2.1-20150120/
make clean && make && make install
ln -sf luajit-2.1 .0-alpha /usr/local/bin/luajit
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
tar -xvf 2.3.tar.gz
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
tar -xvf v0.3.0.tar.gz
cd /usr/servers/ngx_openresty-1.7 .7.2
./configure --prefix=/usr/servers --with-http_realip_module --with-pcre --with-luajit --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
make && make install
cd /usr/servers/
A=`ls -l | grep luajit | awk -F " " '{print$9}'`
B=`ls -l | grep lualib | awk -F " " '{print$9}'`
if A="luajit" || B="lualib"
then
kill -9 `ps -ef | grep nginx | grep -v grep | awk -F " " '{print $2}'`
/usr/servers/nginx/sbin/nginx
openresty_status=`netstat -tnulp |grep nginx`
if [ -n "$openresty_status" ];then
echo "nginx 已啟動!"
else
echo "nginx 未啟動!"
fi
fi
cat>/usr/servers/nginx/conf/nginx.conf<<EOF
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
#include lua.conf;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#lua模組路徑,多個之間”;”分隔,其中”;;”表示預設搜尋路徑,預設到/usr/servers/nginx下找
lua_package_path "/usr/servers/lualib/?.lua;;"; #lua 模組
lua_package_cpath "/usr/servers/lualib/?.so;;"; #c模組
include /usr/example/example.conf;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
EOF
mkdir -p /usr/example/lua/
touch /usr/example/example.conf
touch /usr/example/lua/test.lua
cat>/usr/example/example.conf<<EOF
server {
listen 80;
server_name _;
location /lua {
default_type 'text/html';
lua_code_cache off;
content_by_lua_file /usr/example/lua/test.lua;
}
}
EOF
cat>/usr/example/lua/test.lua<<EOF
ngx.say("hello world,hello world");
ngx.say("The environment of 'nginx+lua' has been configured.");
EOF
/usr/servers/nginx/sbin/nginx -s reload
相關推薦
Nginx+lua(openresty)開發環境搭建shell指令碼
下面是自動搭建的指令碼,採用的是直接殺死本機執行80埠的程式。 #!/bin/bash mkdir -p /usr/servers cd /usr/servers/ yum install -y perl pcre-devel openssl openss
從零開始學習音視頻編程技術(三) 開發環境搭建(Qt4.86手動設置環境,主要就是設置g++和qmake,比較透徹,附下載鏈接)
路徑 details 分享 baidu 末尾 是我 其中 找到 source 1.先下載安裝Qt 我們使用的版本是4.8。 可以自行百度下載也可以從下面的網盤地址下載: Qt庫和編譯器下載: 鏈接:http://pan.baidu.com/s/1hrUxLIG 密碼
Java程式設計師從笨鳥到菜鳥之(一)開發環境搭建,基本語法,字串,陣列
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
【MPC5744P】S32DS中Processor Expert自動生成程式碼工具使用教程(一) 開發環境搭建
MPC5744P是NXP近幾年推出來的主打安全功能的雙核MCU,非常適合在汽車控制器相關產品中使用,非常強大。但是強大的同時,也意味著開發難度增大。 MPC5744P外設功能相關的暫存器非常之多,且對應的參考教程非常少,像STM32之類的工業MCU開發難度根本無法與之相比,早期只能依據官方參
Zephyr學習(二)開發環境搭建
一.概述 Zephyr支援在Windows、Linux和MacOS環境下開發,這裡只介紹如何在Windows下搭建zephyr的開發環境。 二.步驟 2.1安裝msys2 msys2是一個Linux模擬環境,類似於ArchLinux。 安裝完成後,要新增源(這與Linux環境是類似的),這裡我新增的
樹莓派開發筆記(一) 開發環境搭建
開發環境搭建 開發環境搭建 硬體準備 系統燒錄 系統配置 基本配置 其他配置 安裝開發軟體 開發環境搭建 硬體準備 SD-Card 樹莓派
Python學習之路 (一)開發環境搭建
目錄目錄正文前言:python3應該是Python的趨勢所在,當然目前爭議也比較大,這篇隨筆的主要目的是記錄在centos6.7下搭建python3環境的過程以及碰到的問題和解決過程。另外,如果本機安裝了python2,儘量不要管他,使用python3執行python指令碼就
thinkphp5整合H-ui後臺(一)開發環境搭建與公共模板設定
1、開發環境說明:1)軟體版本:thinkphp5.0.12_full,Wampserver64(php5.6.xx,apache2.4.xx,mysql5.7.xx),H-ui.admin_v3.1.xx。版本不需要一模一樣,是同一級別就行,可以用phpStudy取代Wam
python從零開始寫爬蟲(1)-- 開發環境搭建
我是一點都不會python,但為了寫爬蟲,所以就硬幹了。。。 1.windows下搭建python環境直接參考這個就行了安裝指南 2.透過pip安裝套件:1)pip install requests;2)pip install BeautifulSoup4 具體操
區塊鏈(1)開發環境搭建及Hello World合約展示
開發環境搭建 如果你對於以太坊智慧合約開發還沒有概念,請先閱讀以太坊智慧合約入門,本文基於windows平臺開發。 Geth 安裝 以太坊的客戶端有很多,我們選擇開發過程中最為流行的Geth,其基於Go語言開發。 到官方地址下載相應的安
android學習之(1)----開發環境搭建
1.安裝JDK JDK(Java Development Kit) 是 Java 語言的軟體開發工具包(SDK),通常安裝SE(Standerd Edition)版本。 安裝之後需設定系統環境變數:計算機---->右鍵---->屬性----&g
Ok6410裸板程式開發(1)-開發環境搭建
廢話不都說,直接進去正題。本人的開發環境如下: @system:Ubuntu12.04 @串列埠工具:minicom @交叉工具鏈:arm-linux-gcc4.3.2 @開發板:Forlinx OK6410 開發裸板程式時,沒有選擇Jlink,主要原因就是它不好用,而且
Spark 大資料中文分詞統計 (一) 開發環境搭建
幾年前搞BI專案時就聽說過大資料技術,當時也買了書,可惜沒有認真去學。幾年5月份 開始,報名參加王家林老師的大資料蘑菇雲行動,才算真正開始學習Spark,學習大資料技術。 網上很多Spark的例子都是經典的WordCount exam
angularjs2 學習筆記(一) 開發環境搭建 (vs2013)
開發環境,vs2013 update 5,win7 x64,目前最新angular2版本為beta 17 第一步:安裝node.js 安裝node.js(https://nodejs.org/en/),為的是能夠使用npm獲得angular2.0的開發包 驗證
Php學習(一) 開發環境搭建
開門見山,直奔主題,因為專案需要php提供介面,建立網站,所以最近在自學這門語言,在學習的過程中,遇到了不少問題,所以特意寫這篇文章整理一下知識,這篇內容主要就是PHP開發環境的配置,主要是PHP執行環
gstreamer 學習教程(一) 開發環境搭建
Win7 , vs2013 下 Gstreamer 開發環境搭建兩年前就想學習Gstreamer了,可是一直沒時間,現在才有空,準備把學習過程寫成博文,和初學的童靴一起分享成長過程。寫得不好,還請見諒。 開發環境選
Python札記(一)-開發環境搭建(ForMac)和第一個Python程式
今天的內容大致如下: 自己先看一下Python的功效,多多少少去了解一下。我們必須安裝一個Python環境在自己的PC上,用來解釋自己書寫的程式碼,本來Mac是內建的,但是是Python2.7.10(隨著新電腦的出售和系統更新,預裝版本可能會有差異,在終端輸入Python
SpringMVC基礎(一)開發環境搭建
SpringMVC 是一種基於java實現了web mvc設計模式的請求驅動型別的輕量級web框架,將web層進行職責解耦。 一、環境配置 1.spring-framework 3.2.0 版本
Angular入門到精通系列教程(4)- 開發環境搭建以及入手專案
- [1. 本地開發環境搭建](#1-本地開發環境搭建) - [1.1. node.js](#11-nodejs) - [1.2. Angular CLI](#12-angular-cli) - [2. 開發工具 - Visual Studio Code](#2-開發工具---visual-studi