特殊:Badtitle/NS100:PHPOracle:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/PHPOracle}} | {{From|https://help.ubuntu.com/community/PHPOracle}} | ||
{{Languages|UbuntuHelp:PHPOracle}} | {{Languages|UbuntuHelp:PHPOracle}} | ||
To be able to access Oracle databases from PHP, you will need to have the Oracle OCI library | To be able to access Oracle databases from PHP, you will need to have PHP compiled / linked with the Oracle OCI (oci8) library. | ||
You could use the [http://www.oracle.com/technology/tech/php/zendcore/index.html pre-built PHP 5 from Zend] or there are two other ways to get PHP working with OCI8: | |||
<ol><li>Install the Oracle Database [Oracle10g] [Oracle9i] | |||
</li><li>Install Oracle Instant Client</li></ol> | |||
If your Oracle database is in another machine, the Oracle Instant Client is a smaller install. | If your Oracle database is in another machine, the Oracle Instant Client is a smaller install. | ||
=== PHP using Oracle Database Server === | === PHP using Oracle Database Server === | ||
第10行: | 第11行: | ||
=== PHP using Oracle Instant Client === | === PHP using Oracle Instant Client === | ||
Tested Environment: | Tested Environment: | ||
Ubuntu Server | Ubuntu Server 10.04 LTS | ||
Oracle Instant Client | Oracle Instant Client 11.2 | ||
Prerequisites: | Prerequisites: | ||
<pre><nowiki> | <pre><nowiki> | ||
第17行: | 第18行: | ||
sudo apt-get install php5-dev php-pear | sudo apt-get install php5-dev php-pear | ||
</nowiki></pre> | </nowiki></pre> | ||
Instant Client installation requires some environment variables to be able to see the library folder. Edit /etc/environment and add at the end: | |||
http://www.oracle.com/technology/tech/oci/instantclient/index.html | <pre><nowiki> | ||
You will need the Basic ( | # Oracle Instant Client | ||
LD_LIBRARY_PATH="/usr/local/lib/instantclient_11_2" | |||
TNS_ADMIN="/usr/local/lib/instantclient_11_2" | |||
ORACLE_BASE="/usr/local/lib/instantclient_11_2" | |||
ORACLE_HOME=$ORACLE_BASE | |||
</nowiki></pre> | |||
Then download the [http://www.oracle.com/technology/tech/oci/instantclient/index.html Oracle Instant Client from Oracle.com] (you will need to create an account) | |||
You will need the Basic (48MB) and SDK (600K). The Basic Lite version does not work. | |||
<pre><nowiki> | <pre><nowiki> | ||
cd /usr/local/lib | cd /usr/local/lib | ||
sudo unzip <location-of-instant-client-basic> | sudo unzip <location-of-instant-client-basic> | ||
sudo unzip <location-of-instant-client-sdk> | sudo unzip <location-of-instant-client-sdk> | ||
cd | cd instantclient_11_2 | ||
sudo ln -s libclntsh.so. | sudo ln -s libclntsh.so.11.1 libclntsh.so | ||
</nowiki></pre> | </nowiki></pre> | ||
The symbolic link is needed by during the compilation step later. | The symbolic link is needed by during the compilation step later. | ||
第33行: | 第41行: | ||
You will be prompted for the location of the library: | You will be prompted for the location of the library: | ||
<pre><nowiki> | <pre><nowiki> | ||
instantclient,/usr/local/lib/ | instantclient,/usr/local/lib/oracle_11_2 | ||
</nowiki></pre> | |||
You will be prompted also for the ORACLE_HOME location, type 'all', accept and then insert: | |||
<pre><nowiki> | |||
instantclient,/usr/local/lib/oracle_11_2 | |||
</nowiki></pre> | </nowiki></pre> | ||
If successful, you may now add the following line at the bottom of php.ini | If successful, you may now add the following line at the bottom of php.ini | ||
<pre><nowiki> | <pre><nowiki> | ||
extension = oci8.so | extension=oci8.so | ||
</nowiki></pre> | </nowiki></pre> | ||
The php.ini is found in 2 places: /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini | The php.ini is found in 2 places: /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini |
2010年5月19日 (三) 23:53的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/PHPOracle }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/af | • {{#if: UbuntuHelp:PHPOracle|Afrikaans| [[::PHPOracle/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ar | • {{#if: UbuntuHelp:PHPOracle|العربية| [[::PHPOracle/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/az | • {{#if: UbuntuHelp:PHPOracle|azərbaycanca| [[::PHPOracle/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/bcc | • {{#if: UbuntuHelp:PHPOracle|جهلسری بلوچی| [[::PHPOracle/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/bg | • {{#if: UbuntuHelp:PHPOracle|български| [[::PHPOracle/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/br | • {{#if: UbuntuHelp:PHPOracle|brezhoneg| [[::PHPOracle/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ca | • {{#if: UbuntuHelp:PHPOracle|català| [[::PHPOracle/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/cs | • {{#if: UbuntuHelp:PHPOracle|čeština| [[::PHPOracle/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/de | • {{#if: UbuntuHelp:PHPOracle|Deutsch| [[::PHPOracle/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/el | • {{#if: UbuntuHelp:PHPOracle|Ελληνικά| [[::PHPOracle/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/es | • {{#if: UbuntuHelp:PHPOracle|español| [[::PHPOracle/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/fa | • {{#if: UbuntuHelp:PHPOracle|فارسی| [[::PHPOracle/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/fi | • {{#if: UbuntuHelp:PHPOracle|suomi| [[::PHPOracle/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/fr | • {{#if: UbuntuHelp:PHPOracle|français| [[::PHPOracle/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/gu | • {{#if: UbuntuHelp:PHPOracle|ગુજરાતી| [[::PHPOracle/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/he | • {{#if: UbuntuHelp:PHPOracle|עברית| [[::PHPOracle/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/hu | • {{#if: UbuntuHelp:PHPOracle|magyar| [[::PHPOracle/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/id | • {{#if: UbuntuHelp:PHPOracle|Bahasa Indonesia| [[::PHPOracle/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/it | • {{#if: UbuntuHelp:PHPOracle|italiano| [[::PHPOracle/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ja | • {{#if: UbuntuHelp:PHPOracle|日本語| [[::PHPOracle/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ko | • {{#if: UbuntuHelp:PHPOracle|한국어| [[::PHPOracle/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ksh | • {{#if: UbuntuHelp:PHPOracle|Ripoarisch| [[::PHPOracle/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/mr | • {{#if: UbuntuHelp:PHPOracle|मराठी| [[::PHPOracle/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ms | • {{#if: UbuntuHelp:PHPOracle|Bahasa Melayu| [[::PHPOracle/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/nl | • {{#if: UbuntuHelp:PHPOracle|Nederlands| [[::PHPOracle/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/no | • {{#if: UbuntuHelp:PHPOracle|norsk| [[::PHPOracle/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/oc | • {{#if: UbuntuHelp:PHPOracle|occitan| [[::PHPOracle/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/pl | • {{#if: UbuntuHelp:PHPOracle|polski| [[::PHPOracle/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/pt | • {{#if: UbuntuHelp:PHPOracle|português| [[::PHPOracle/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ro | • {{#if: UbuntuHelp:PHPOracle|română| [[::PHPOracle/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/ru | • {{#if: UbuntuHelp:PHPOracle|русский| [[::PHPOracle/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/si | • {{#if: UbuntuHelp:PHPOracle|සිංහල| [[::PHPOracle/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/sq | • {{#if: UbuntuHelp:PHPOracle|shqip| [[::PHPOracle/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/sr | • {{#if: UbuntuHelp:PHPOracle|српски / srpski| [[::PHPOracle/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/sv | • {{#if: UbuntuHelp:PHPOracle|svenska| [[::PHPOracle/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/th | • {{#if: UbuntuHelp:PHPOracle|ไทย| [[::PHPOracle/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/tr | • {{#if: UbuntuHelp:PHPOracle|Türkçe| [[::PHPOracle/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/vi | • {{#if: UbuntuHelp:PHPOracle|Tiếng Việt| [[::PHPOracle/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/yue | • {{#if: UbuntuHelp:PHPOracle|粵語| [[::PHPOracle/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/zh | • {{#if: UbuntuHelp:PHPOracle|中文| [[::PHPOracle/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/zh-hans | • {{#if: UbuntuHelp:PHPOracle|中文(简体)| [[::PHPOracle/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:PHPOracle | UbuntuHelp:PHPOracle | {{#if: | :}}PHPOracle}}/zh-hant | • {{#if: UbuntuHelp:PHPOracle|中文(繁體)| [[::PHPOracle/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:PHPOracle|:PHPOracle|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :PHPOracle/zh | | {{#ifexist: PHPOracle/zh | | {{#ifeq: {{#titleparts:PHPOracle|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:PHPOracle|1|-1|}} | zh | | }}
To be able to access Oracle databases from PHP, you will need to have PHP compiled / linked with the Oracle OCI (oci8) library. You could use the pre-built PHP 5 from Zend or there are two other ways to get PHP working with OCI8:
- Install the Oracle Database [Oracle10g] [Oracle9i]
- Install Oracle Instant Client
If your Oracle database is in another machine, the Oracle Instant Client is a smaller install.
PHP using Oracle Database Server
TODO
PHP using Oracle Instant Client
Tested Environment: Ubuntu Server 10.04 LTS Oracle Instant Client 11.2 Prerequisites:
sudo apt-get install build-essential sudo apt-get install php5-dev php-pear
Instant Client installation requires some environment variables to be able to see the library folder. Edit /etc/environment and add at the end:
# Oracle Instant Client LD_LIBRARY_PATH="/usr/local/lib/instantclient_11_2" TNS_ADMIN="/usr/local/lib/instantclient_11_2" ORACLE_BASE="/usr/local/lib/instantclient_11_2" ORACLE_HOME=$ORACLE_BASE
Then download the Oracle Instant Client from Oracle.com (you will need to create an account) You will need the Basic (48MB) and SDK (600K). The Basic Lite version does not work.
cd /usr/local/lib sudo unzip <location-of-instant-client-basic> sudo unzip <location-of-instant-client-sdk> cd instantclient_11_2 sudo ln -s libclntsh.so.11.1 libclntsh.so
The symbolic link is needed by during the compilation step later.
sudo pecl install oci8
You will be prompted for the location of the library:
instantclient,/usr/local/lib/oracle_11_2
You will be prompted also for the ORACLE_HOME location, type 'all', accept and then insert:
instantclient,/usr/local/lib/oracle_11_2
If successful, you may now add the following line at the bottom of php.ini
extension=oci8.so
The php.ini is found in 2 places: /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini
sudo /etc/init.d/apache2 reload
Check <?php echo phpinfo() ?> to verify if the OCI8 module is available.