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环境搭建的更多相关文章

  1. nginx 与 lua 开发环境搭建

    首先下载最新版的 相关软件 的安装文件. nginx: http://nginx.org/en/download.html LuaJIT: http://luajit.org/download.htm ...

  2. Ubuntu下nginx+uwsgi+flask的执行环境搭建

    选择web framwork是个非常艰难的事情, 主要分为轻量级和重量级框架. 因为没有搭建站点这样的须要, 所以回避SSH, Django这样的框架, 而选择一个轻量级框架. 自己也比較青睐pyth ...

  3. C++调用Lua编程环境搭建及测试代码示例

    C++调用Lua编程环境搭建及测试代码示例 摘要:测试环境是VS2005+LuaForWindows_v5.1.4-45.exe+WIN7 1.安装lua开发环境LuaForWindows_v5.1. ...

  4. (十八)整合Nacos组件,环境搭建和入门案例详解

    整合Nacos组件,环境搭建和入门案例详解 1.Nacos基础简介 1.1 关键特性 1.2 专业术语解释 1.3 Nacos生态圈 2.SpringBoot整合Nacos 2.1 新建配置 2.2 ...

  5. nginx + lua +redis环境搭建

    环境搭建,其实主要是lua的环境,这个环境够麻烦的,在网上找了很多前辈的文章,终于完成了 ,安装redis wget http://download.redis.io/releases/redis-3 ...

  6. Nginx详解二十三:Nginx深度学习篇之Nginx+Lua开发环境搭建

    Nginx+Lua开发环境 1.下载LuaJIT解释器wget http://luajit.org/download/LuaJIT-2.0.2.tar.gztar -zxvf LuaJIT-2.0.2 ...

  7. 一起学ASP.NET Core 2.0学习笔记(一): CentOS下 .net core2 sdk nginx、supervisor、mysql环境搭建

    作为.neter,看到.net core 2.0的正式发布,心里是有点小激动的,迫不及待的体验了一把,发现速度确实是快了很多,其中也遇到一些小问题,所以整理了一些学习笔记: 阅读目录 环境说明 安装C ...

  8. keepalived+nginx高可用负载均衡环境搭建

    上篇说道keepalived的环境搭建,本来keepalived结合lvs更有优势,但是也可以结合nginx来使用.下面接着说下nginx的环境搭建 环境信息: nginx(master)  192. ...

  9. Centos+nginx+uwsgi+Python多站点环境搭建

    前言 新公司的第一个项目,服务器端打算用python作为restful api.所以需要在Centos上搭建nginx+fastcgi+python的开发环境,但后面网上很多言论都说uwsgi比fas ...

随机推荐

  1. NSIS安装包制作

    6)闪屏界面,可以在源代码中加入下列代码即可: A.普通效果 以下是代码片段: Function .onInit SetOutPath $TEMP File /oname=spltmp.bmp &qu ...

  2. LaTeX 相对于 Word 有什么优势?

    sjhstone ,本科EE在读 vczh等 276 人赞同 [Word公式进阶请往下翻]有人还写过论文,参见PLOS ONE: An Efficiency Comparison of Documen ...

  3. Spring @Autowired 注解不生效

    @Autowired默认不生效.为了生效,需要在xml配置:<context:annotation-config> 注解一<context:component-scan base-p ...

  4. 让你明白response.sendRedirect()与request.getRequestDispatcher().forward()区别

    JSP中response.sendRedirect()与request.getRequestDispatcher().forward(request,response)这两个对象都可以使页面跳转,但是 ...

  5. [转]SSIS中OLE DB Source中如何执行Store Procedure 以得到源数据

    本文转自:http://www.cnblogs.com/michaelxu/archive/2009/10/16/1584284.html 有很多人喜欢在OLE DB Source中执行Store P ...

  6. Vue-router路由基础总结(二)

    一.命名路由 有时我们通过一个名称来标识一个路由显得更方便一些,特别是在链接一个路由,或者是执行一些跳转的时候.你可以在创建 Router 实例的时候,在 routes 配置中给某个路由设置名称. 我 ...

  7. 关于app更新安装闪退和EditText长按出现的水滴颜色设置问题

    关于app应用内更新安装后闪退的问题,解决办法如下: private void updateApp(File body) { Intent intent = new Intent(Intent.ACT ...

  8. 利用JMX来监控大部分java应用

    JMX(JavaManagement Extensions,即Java管理扩展)是一个为应用程序.设备.系统等植入管理功能的框架.JMX可以跨越一系列异构操作系统平台.系统体系结构和网络传输协议,灵活 ...

  9. onethink 密码加密方式详解

    /** * 系统非常规MD5加密方法 * @param string $str 要加密的字符串 * @return string */ function think_ucenter_md5($str, ...

  10. hibernate 多对多单向

    多对多会利用中间表做外键的形式关联   package com.bjsxt.hibernate; import javax.persistence.Entity; import javax.persi ...