Rt
A recently developed project, the database uses Oracle. Oracle natively supports red Hat, the support for Ubuntu is not good, if Ubuntu needs to install Oracle, the system itself needs to do a lot of camouflage, so I only intend to use the Oracle database on the remote server.
Local Environment:
Linux xxx-thinkpad-t400 3.13.0-46-generic #75-ubuntu SMP Tue Feb 15:24:04 UTC x86_64 x86_64 x86_64 gnu/linux
PHP Version: 5.5.9-1ubuntu4.6
The PHP installation does not have an Oracle database management extension, and we need to download it ourselves and compile the installation and configuration.
Here I mainly refer to the following article:
Https://help.ubuntu.com/community/PHPOracle
Http://blog.sina.com.cn/s/blog_8f4fbe030100y5q3.html
There are many related tutorials on the Internet, mainly divided into two categories, but the main ideas are as follows:
1. Download the instantclient basic and Instantclient SDK installation packages from the Oracle website;
2. Unzip, create the library file soft link;
3. Download and compile PHP oci8.so
4. Configure PHP
The difference is that there is a direct download of PHP oci8.so files, decompression at the same time manually compile, or as I refer to the tutorial taught, directly using the pear command to download and automatically compile.
The point is that there are a lot of unexpected problems in the course of following the tutorial, and then I'll write the tutorial in the process I successfully configured, and then explain the problems I've encountered and how to fix them:
1. Resolve Dependency Issues:
sudo apt-get updatesudo apt-get upgrade
sudo apt-get install Php5-dev build-essential php-pear libaio1
sudo apt-get install unzip make
2. Download instant Client from Oracle website
Http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
According to your own system into the corresponding list, respectively, download the corresponding Instantclient-basic-xxx.zip and Instantclient-sdk-xxx.zip.
3. Unzip, create the library file soft link;
The processing of this step is very important and if handled improperly, it will cause the following compilation steps to fail.
3.1 Unzip the file and remove the version number of the two folders. Also known as the instantclient and SDK, the SDK folder is then moved throughout to the Instantclient directory, and other library files coexist. Most of the other tutorials on the web do not describe the relationship between the two folders, or directly put them in the same level directory, resulting in the subsequent compilation process is always prompted to not find the SDK. Here we must move the SDK folder to the Instantclient directory. You cannot refer to other tutorials on the web.
3.2 Create a soft link to the library file, note that there is no direct right-click to generate a link to the library file:
Ln-s libnnz12 (version number). So libnnz.so
As above, remove the original library file version information, generate no version information of the extension library file links;
At the same time, we need to generate
Ln-s libclntsh.so.12.1 libclntsh.so
Ln–s libocci.so.12.1 libocci.so
Once this is done, we can move the Oracle Instantclient folder to our pre-arranged location, with the recommended location:
/usr/local/lib/
After the entire directory has been copied, the directory is entitled to be raised:
sudo chmod 777-r/usr/local/lib/instantclient/
Then configure some of the system constants that we may need next:
sudo vim/etc/environment
Add the following constants at the end of the file:
# Oracle Instant clientld_library_path= "/usr/local/lib/instantclient" tns_admin= "/usr/local/lib/instantclient" Oracle_base= "/usr/local/lib/instantclient" Oracle_home= $ORACLE _base
4. Download and compile oci8.so
sudo pecl install Oci8
The next step is to automatically download the OCI8 source package and compile it automatically, and then prompt you to enter the Instantclient related path variable in the process: input
Instantclient,/usr/local/lib/instantclient
Then you will be prompted when the system compiles:
Build process completed successfullyinstalling '/usr/lib/php5/20121212/oci8.so ' install ok:channel://pecl.php.net/ Oci8-2.0.8configuration option "Php_ini" is not set to php.ini locationyou should add "extension=oci8.so" to PHP.ini
If there is no such hint, then congratulations, this process must be wrong. Let's just assume that it's all smooth. By now we have successfully compiled the oci8.so extension. The next step is to assign it to the usage environment.
5. Configure PHP
We can open extension directly in php.ini, but now PHP does not recommend this operation, so we do this: because my server is Ubuntu+apache, so the operation method is as follows:
In the/ETC/PHP5/APACHE2/CONF.D new Oci8.ini This file, apache2/conf.d this directory, you will find all the plug-ins are preceded by numbers, here we do not have to control, directly ignore:
sudo vim/etc/php5/apache2/conf.d/oci8.ini
then add the open oci8.so in the file,
Extension=oci8.so
Then restart Apache.
Sudo/etc/init.d/apache2 restart
After the reboot is complete, create a new test.php file in the server root directory and write:
<?php phpinfo ()?>
See if the following appears in the PHP page:
OCI8
OCI8 Support |
Enabled |
OCI8 DTrace Support |
Disabled |
OCI8 Version |
2.0.8 |
Revision |
$Id: f04114d4d67cffea4cdc2ed3b7f0229c2caa5016 $ |
Oracle run-time Client Library Version |
12.1.0.2.0 |
Oracle compile-time Instant Client Version |
12.1 |
If the following information is printed, it indicates that our configuration has succeeded.
Here is the Debug link:
1. The compilation process appears:
Configure:WARNING:You would need re2c 0.13.4 or later if you want to regenerate PHP parsers.
This is addressed through the following articles:
Http://blog.slogra.com/post-421.html
2. The library file cannot be found during the compilation process: Configure:error:Oracle Instant Client Libraries libnnz.so and libclntsh.so not found check if you are creating a soft link Created by the command line.
3.checking Oracle Instant Client SDK Header directory ... configure:error:Oracle Instant Client SDK header files not Foun D Your SDK folder is located in the Instantclient directory.
4.ERROR: '/tmp/pear/temp/oci8/configure--with-oci8=instantclient,/usr/local/lib/instantclient ' failed-- The path followed by the with-oci8 is correct, and should be the last directory we copied to.
If you encounter other problems, please leave a comment to communicate.
"ubuntu14.04" Build php5+apache2+oracle Environment