nginx整合php+lua+oracle环境搭建
nginx整合php+lua+oracle环境搭建 标签: nginxluaoraclephplinux
-- : 1473人阅读 评论() 收藏 举报
分类: 技术()
版权声明:本文为博主原创文章,未经博主允许不得转载。 *执行 yum update 为了得到一个最新的系统 *执行 rpm -ivh oracle-instantclient12.-basic-12.1.0.2.-.x86_64.rpm oracle-instantclient12.-devel-12.1.0.2.-.x86_64.rpm oracle-instantclient12.-sqlplus-12.1.0.2.-.x86_64.rpm 安装oracle客户端 *执行 echo "/usr/lib/oracle/12.1/client64/lib/" > /etc/ld.so.conf.d/oracle_client.conf *执行 ldconfig 设置加载库并加载 *执行 ldconfig -v | grep oracle 判定是否加载成功 *执行 vim /etc/profile 添加 export ORACLE_HOME=/usr/lib/oracle/12.1/client64/ export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/ export NLS_LANG="AMERICAN_AMERICA.AL32UTF8" *执行 source /etc/profile 设置oracle环境变量 并生效 *执行 echo $ORACLE_HOME 验证环境变量是否生效 *执行 hostname *执行 vim /etc/hosts 添加 127.0.0.1 hostname的结果 *执行 sqlplus64 用户名/密码@远程位置/数据库 测试oracle客户端是否生效 *执行 tar -zxvf libmcrypt-2.5..tar.gz *执行 cd libmcrypt-2.5. *执行 ./configure *执行 make *执行 make install *执行 tar -zxvf redis-2.8..tar.gz *执行 mv redis-2.8. /usr/local/redis *执行 cd /usr/local/redis *执行 make *执行 vi /usr/local/redis/redis.conf 打开配置文件 daemonize yes unixsocket /tmp/redis.sock dir /opt/redis/ *执行 mkdir /opt/redis *启动 /usr/local/redis/src/redis-server /usr/local/redis/redis.conf *执行 tar -zxvf php-5.5..tar.gz *执行 cd php-5.5. *执行 ./configure --prefix=/usr/local/php --enable-fpm --with-openssl --with-zlib --with-curl --enable-exif --with-zlib-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt --enable-sysvshm --enable-soap --enable-sockets --enable-opcache --enable-zip --enable-mysqlnd --with-xsl --with-pear *提示 configure: error: xml2-config not found. Please check your libxml2 installation. *执行 yum install libxml2-devel *提示 configure: error: Cannot find OpenSSL's <evp.h> yum install openssl-devel *提示 error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/ yum install libcurl-devel *提示 configure: error: jpeglib.h not found. yum install libjpeg-turbo-devel *提示 configure: error: png.h not found. yum install libpng-devel *提示 configure: error: freetype-config not found. yum install freetype-devel *提示 configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1. distribution yum install libxslt-devel *执行 make *执行 make install *执行 cp php.ini-development /usr/local/php/lib/php.ini *执行 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf vim 打开 pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice daemonize = yes *执行 cd 源码目录/ext/oci8/ *执行 /usr/local/php/bin/phpize *执行 ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib --with-php-config=/usr/local/php/bin/php-config *执行 make *执行 make install *执行 cd 源码目录/ext/pdo_oci/ *执行 /usr/local/php/bin/phpize *执行 ./configure --with-pdo-oci=instantclient,/usr,12.1 --with-php-config=/usr/local/php/bin/php-config *执行 make *执行 make install *执行 unzip phpredis.zip *执行 cd phpredis-master *执行 ./configure --with-php-config=/usr/local/php/bin/php-config *执行 make *执行 make install vi /usr/local/php/lib/php.ini 添加 extension=redis.so extension=oci8.so extension=pdo_oci.so date.timezone = "Asia/Shanghai" *执行 /usr/local/php/bin/php -m | grep redis *执行 /usr/local/php/bin/php -m | grep oci8 判断加载模块是否成功 [php test.php] <?php $oracle_host= ""; $oracle_dbname = ""; $oracle_user = ""; $oracle_pwd = ""; $redis_host = "127.0.0.1"; $redis_port = ""; function oracle_connect() { global $oracle_host,$oracle_dbname, $oracle_user,$oracle_pwd; try{ $conn = new PDO("oci:dbname=//{$oracle_host}/{$oracle_dbname};charset=AL32UTF8",$oracle_user,$oracle_pwd); }catch(PDOException $e){ echo ($e->getMessage()); return false; } return $conn; } echo "oracle connect:"; print_r(oracle_connect()); echo "\n"; echo "redis connect:"; $redis = new Redis(); $redis->connect($redis_host, $redis_port); print_r($redis); ?> [/php] *执行 /usr/local/php/bin/php -f test.php 无报错表示成功 *执行 tar -zxvf luarocks-2.1..tar.gz *执行 cd luarocks-2.1. *执行 ./configure *执行 make build *执行 make install *执行 luarocks install luasocket unzip luasocket-2.0.-rc1.zip cd luasocket-2.0. vi config 修改 INSTALL_TOP_SHARE=/usr/share/lua/5.1 INSTALL_TOP_LIB=/usr/lib64/lua/5.1 关闭 #------ # Compiler and linker settings # for Mac OS X # CC=gcc DEF= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN CFLAGS= $(LUAINC) $(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common LDFLAGS=-bundle -undefined dynamic_lookup LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc 打开 #------ # Compiler and linker settings # for Linux CC=gcc DEF=-DLUASOCKET_DEBUG CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic LDFLAGS=-O -shared -fpic LD=gcc *执行 make *执行 make install *执行 unzip lua-nginx-module.zip *执行 unzip ngx_devel_kit.zip *执行 tar -zxvf nginx-1.6..tar.gz *执行 cd nginx-1.6. *执行 ./configure --prefix=/usr/local/nginx --add-module=../ngx_devel_kit-master/ --add-module=../lua-nginx-module-master/ --with-pcre --with-debug --with-poll_module --with-file-aio --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_secure_link_module *提示 ./configure: error: ngx_http_lua_module requires the Lua library. yum install lua-devel *提示 ./configure: error: the HTTP rewrite module requires the PCRE library. yum install pcre-devel *执行 make *执行 make install 编辑添加nginx 测试 [nginx conf] server{ listen ; location /lua/ { default_type 'text/plain'; content_by_lua_file /usr/local/nginx/html/test.lua; } location /{ } location ~ \.php$ { root /usr/local/nginx/html/; fastcgi_pass 127.0.0.1:; fastcgi_index test.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params; } } [/nginx] *启动 /usr/local/php/sbin/php-fpm *执行 ps aux | grep php 确认启动成功 *启动 /usr/local/nginx/sbin/nginx *执行 ps aux | grep nginx 确认启动成功 *启动 /usr/local/redis/src/redis-server /usr/local/redis/redis.conf *执行 ps aux | grep redis 确认启动成功 vim /usr/local/nginx/html/test.php [php test.php] <?php $oracle_host= ""; $oracle_dbname = ""; $oracle_user = "; $oracle_pwd = ""; $redis_host = "127.0.0.1"; $redis_port = ""; function oracle_connect() { global $oracle_host,$oracle_dbname, $oracle_user,$oracle_pwd; try{ $conn = new PDO("oci:dbname=//{$oracle_host}/{$oracle_dbname};charset=AL32UTF8",$oracle_user,$oracle_pwd); }catch(PDOException $e){ echo ($e->getMessage()); return false; } return $conn; } echo "oracle connect:"; print_r(oracle_connect()); echo "<br/>"; echo "redis connect:"; $redis = new Redis(); $redis->connect($redis_host, $redis_port); print_r($redis); echo "<br/>"; phpinfo(); ?> [/php] *执行 unzip redis-lua-version-2.0.zip *执行 cd redis-lua-version-2.0 *执行 cp src/redis.lua /usr/share/lua/5.1/ *执行 unzip luautf8.zip *执行 cd luautf8-master/ *执行 gcc -shared -O3 lutf8lib.c -o utf8.so -fPIC *执行 cp utf8.so /usr/lib64/lua/5.1/utf8.so [lua test.lua] utf8 = require("utf8") local inu_str = "11a我"; local str_len = utf8.len(inu_str) print("utf8 test:") print(utf8.sub(inu_str,,)) print("\n") local redis = require("redis") local client = redis.connect('127.0.0.1', ) local response = client:ping() print("redis test:") print(response) print("\n") [/lua] *执行 lua test.lua 测试模块有效性 *执行 vim /usr/local/nginx/html/test.lua [lua test.lua] utf8 = require("utf8") local inu_str = "11a我"; local str_len = utf8.len(inu_str) ngx.say("utf8 test:") ngx.say(utf8.sub(inu_str,,)) ngx.say("<br/>") local redis = require("redis") local client = redis.connect('127.0.0.1', ) local response = client:ping() ngx.say("redis test:") ngx.say(response) ngx.say("\n") [/lua] *执行 /usr/local/nginx/sbin/nginx -t 测试nginx跟lua整合 *需要oralce完整安装包 unzip luasql.zip cd luasql-master vi config 核心配置 DRIVER_LIBS= -L$(ORACLE_HOME)/lib -lz -lclntsh DRIVER_INCS= -I$(ORACLE_HOME)/rdbms/demo -I$(ORACLE_HOME)/rdbms/public make make install *提示 libclntsh.so 找不到 *执行 echo "/opt/oracle/lib/" > /etc/ld.so.conf.d/oracle_client.conf *执行 ldconfig [lua test_oracle.lua] require "luasql.oci8" env = assert (luasql.oci8()) con = assert (env:connect(库名,用户名,密码,连接地址,端口)) [/lua]
nginx整合php+lua+oracle环境搭建的更多相关文章
- nginx 与 lua 开发环境搭建
首先下载最新版的 相关软件 的安装文件. nginx: http://nginx.org/en/download.html LuaJIT: http://luajit.org/download.htm ...
- Ubuntu下nginx+uwsgi+flask的执行环境搭建
选择web framwork是个非常艰难的事情, 主要分为轻量级和重量级框架. 因为没有搭建站点这样的须要, 所以回避SSH, Django这样的框架, 而选择一个轻量级框架. 自己也比較青睐pyth ...
- C++调用Lua编程环境搭建及测试代码示例
C++调用Lua编程环境搭建及测试代码示例 摘要:测试环境是VS2005+LuaForWindows_v5.1.4-45.exe+WIN7 1.安装lua开发环境LuaForWindows_v5.1. ...
- (十八)整合Nacos组件,环境搭建和入门案例详解
整合Nacos组件,环境搭建和入门案例详解 1.Nacos基础简介 1.1 关键特性 1.2 专业术语解释 1.3 Nacos生态圈 2.SpringBoot整合Nacos 2.1 新建配置 2.2 ...
- nginx + lua +redis环境搭建
环境搭建,其实主要是lua的环境,这个环境够麻烦的,在网上找了很多前辈的文章,终于完成了 ,安装redis wget http://download.redis.io/releases/redis-3 ...
- Nginx详解二十三:Nginx深度学习篇之Nginx+Lua开发环境搭建
Nginx+Lua开发环境 1.下载LuaJIT解释器wget http://luajit.org/download/LuaJIT-2.0.2.tar.gztar -zxvf LuaJIT-2.0.2 ...
- 一起学ASP.NET Core 2.0学习笔记(一): CentOS下 .net core2 sdk nginx、supervisor、mysql环境搭建
作为.neter,看到.net core 2.0的正式发布,心里是有点小激动的,迫不及待的体验了一把,发现速度确实是快了很多,其中也遇到一些小问题,所以整理了一些学习笔记: 阅读目录 环境说明 安装C ...
- keepalived+nginx高可用负载均衡环境搭建
上篇说道keepalived的环境搭建,本来keepalived结合lvs更有优势,但是也可以结合nginx来使用.下面接着说下nginx的环境搭建 环境信息: nginx(master) 192. ...
- Centos+nginx+uwsgi+Python多站点环境搭建
前言 新公司的第一个项目,服务器端打算用python作为restful api.所以需要在Centos上搭建nginx+fastcgi+python的开发环境,但后面网上很多言论都说uwsgi比fas ...
随机推荐
- Android-25种开源炫酷动画框架
前言 忙碌的工作终于可以停息一段时间了,最近突然有一个想法,就是自己写一个app,所以找了一些合适开源控件,这样更加省时,再此分享给大家,希望能对大家有帮助,此博文介绍的都是UI上面的框架,接下来会有 ...
- 折腾mysql的小坑记录
1.安装 CentOS下先卸载自带的mariadb rpm -qa | grep mariadb mariadb-libs--.el7_2.x86_64 mariadb--.el7_2.x86_64 ...
- 万里长征第二步——django个人博客(第六步 ——添加富文本编辑器)
下载kindeditor 在admin.py文件中配置链接 class Media: js = ( '/static/js/kindeditor-4.1.10/kindeditor-min.js', ...
- Koch 分形,海岸线,雪花
此算法用于生成Koch分形(海岸线,雪花).速度高速,效果绚丽 //支持的初始直线水平角度为60 的倍数. 交换起点与终点坐标可改变生成方向 void Koch(CDC *pDC, int x1, i ...
- ylbtech-LanguageSamples-Indexers(索引器)
ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-Indexers(索引器) 1.A,示例(Sample) 返回顶部 “索引器”示例 本示 ...
- delphi VCL研究之消息分发机制-delphi高手突破读书笔记
1.VCL 概貌 先看一下VCL类图的主要分支,如图4.1所示.在图中可以看到,TObject是VCL的祖先类,这也是Object Pascal语言所规定的.但实际上,TObject以及TObject ...
- 利用Nodejs & Cheerio & Request抓取Lofter美女图片
还是参考了这篇文章: http://cnodejs.org/topic/54bdaac4514ea9146862abee 另外有上面文章 nodejs抓取网易公开课的一些经验. 代码如下,注意其中用到 ...
- Hive不等值连接
select * from ( select t1.instalment_id as r_id , t2.instalment_id as p_id from (select instalment_i ...
- Win7如何删除家庭组
发表于 2010-07-15 11:38:06 [YY团]Win7家庭组不能正常使用的解决办法 只是把近期碰到的一个小毛病的解决方案共享一下罢了,估计碰到这问题的人不会很多-- 表现是家庭组不能正常访 ...
- Navicat for SQL Server创建连接提示错误08001怎么办
创建连接之后提示如下错误 打开SQL Server配置工具,把能打开的都打开(什么远程连接,什么SQL Server Browser之类的) 你再创建连接的时候就有不止一个连接了,连那些Named P ...