nginx整合php+lua+oracle环境搭建
nginx整合php+lua+oracle环境搭建
标签: nginxluaoraclephplinux
2014-09-25 10:39 1473人阅读 评论(0) 收藏 举报
分类:
技术(70)
版权声明:本文为博主原创文章,未经博主允许不得转载。
*执行 yum update 为了得到一个最新的系统
*执行 rpm -ivh
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.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.7.tar.gz
*执行 cd libmcrypt-2.5.7
*执行 ./configure
*执行 make
*执行 make install
*执行 tar -zxvf redis-2.8.15.tar.gz
*执行 mv redis-2.8.15 /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.16.tar.gz
*执行 cd php-5.5.16
*执行 ./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.0 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 = "6379";
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.2.tar.gz
*执行 cd luarocks-2.1.2
*执行 ./configure
*执行 make build
*执行 make install
*执行 luarocks install luasocket
unzip luasocket-2.0.3-rc1.zip
cd luasocket-2.0.3
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.2.tar.gz
*执行 cd nginx-1.6.2
*执行 ./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 8080;
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:9000;
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 = "6379";
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,0,2))
print("\n")
local redis = require("redis")
local client = redis.connect('127.0.0.1', 6379)
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,0,2))
ngx.say("<br/>")
local redis = require("redis")
local client = redis.connect('127.0.0.1', 6379)
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]
来源:http://www.cnblogs.com/archoncap/p/5252983.html
nginx整合php+lua+oracle环境搭建相关推荐
- CentOS6.5_64下 nginx+uwsgi+Python +多站点环境搭建
本文章为各位介绍一篇关于CentOS6.5_64下 nginx+uwsgi+Python +多站点环境搭建 python web django 框架的例子. 作为一个严谨(其实就是有强迫症)的程序,为 ...
- 一起学ASP.NET Core 2.0学习笔记(一): CentOS下 .net core2 sdk nginx、supervisor、mysql环境搭建...
作为.neter,看到.net core 2.0的正式发布,心里是有点小激动的,迫不及待的体验了一把,发现速度确实是快了很多,其中也遇到一些小问题,所以整理了一些学习笔记: 阅读目录 环境说明 安装C ...
- SSM+nginx+tomcat+maven+mysql+redis环境搭建及工程全套配置,实现前后端动静分离
目录 前言 服务器环境搭建 windows开发环境 SSM搭建 加入redis(注解形式) nginx与tomcat关联配置,完成前后端连接 前言 本次采用前后端分离模式,前端以html.css.js ...
- SpringBoot2 整合Nacos组件,环境搭建和入门案例详解
本文源码:GitHub·点这里 || GitEE·点这里 一.Nacos基础简介 1.概念简介 Nacos 是构建以"服务"为中心的现代应用架构,如微服务范式.云原生范式等服务基础 ...
- Cocos2dx Lua开发环境搭建
本文记录在 Windows 下搭建 cocos2dx lua 开发环境,还有调试设置. 系统:Windows 7 64 IDE:Mircrosoft Visual Studio 2013 Cocos2 ...
- 南京华为云搭建总结之Oracle环境搭建以及数据泵数据的导入
安装Oracle Linux 查看是否安装 oracle ps -ef | grep ora 如果没安装 直接用Oracle镜像即可 直接启动即可: docker run -d --name sath ...
- C++调用Lua编程环境搭建及测试代码示例
测试环境是VS2005+LuaForWindows_v5.1.4-45.exe+WIN7 1.安装lua开发环境LuaForWindows_v5.1.4-45.exe 2.启动VS2005,选择C++ ...
- cics oracle xad_CICS + Linux + Oracle 环境搭建.doc
CICSLinuxOracle环境搭建 安装CICS v8.1介质 如果安装包已经被压缩,可以使用命令进行解压缩:gzip -d ** tax -xvf ** **为压缩包名 [root@ceshi ...
- CentOS+Nginx+uWSGI+Python多站点环境搭建
/usr/lib/python2.7/site-packages/django/bin/django-admin.py startproject myweb 但是又看了一下uwsgi 的官方文档,发 ...
最新文章
- JSTL中fmt标签详解
- python3 deque(双向队列)
- adguard没有核心 core no_业主装修最后悔的五个地方!没有之一
- java log4j logback jcl_内部分享:如何解决Java日志框架冲突问题。
- 一个域名解析到另一个域名_注册域名公司|教你如何注册一个.net域名
- [导入]vs2005视频教程 之 编译程序集和发布网站 [视频]
- Matlab运算之 norm,cross,makehgtform,asin(acos)
- Angr安装与使用之安装篇
- JAVA分页查询实现
- 用Excel做时间顺序的行为流程图
- 【WLAN】【基础知识】WIFI那些事儿之Beamforming
- 仿百度文库,office转pdf核心转换功能
- Kettle(三)Java定时调用.ktr文件
- anaconda查看环境中安装的包及具体位置查找
- 注册码破解神器--OllyDbg
- Linux TCP/IP大合集
- python程序填空_python练习题-基础巩固-第一周
- SCU 2818 QQ音速
- 游戏抽奖网站用java怎么做,Java实现游戏抽奖算法
- 基于JAVA解决淘宝爬虫限制