日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

nginx整合php+lua+oracle环境搭建

發布時間:2024/9/20 php 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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环境搭建的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。