Ubuntu 14.04 Build php5+apache2+oracle and Oracle management software SQL Developer

Source: Internet
Author: User
Tags ini mkdir pear php file zip

Ubuntu 14.04 Build php5+apache2+oracle Environment

A recently developed project that uses Oracle for databases. Oracle itself supports Red Hat, and the support for Ubuntu is not good, and if Ubuntu needs to install Oracle, the system itself needs to do a lot of camouflage, so I'm only going 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 Ten 15:24:04 UTC 2015 x86_64 x86_64 x86_64 gnu/linux

PHP Version: 5.5.9-1ubuntu4.6

PHP will not be installed with Oracle Database management extensions, we need to download and compile the installation and configuration.

There are many related tutorials on the Internet, mainly divided into two categories, but the main ideas are as follows:

1. Download Instantclient basic and Instantclient SDK installation package from Oracle website;

2. Decompression, create a soft link to the library file;

3. Download and compile PHP oci8.so

4. Configure PHP

The difference is that some directly download PHP oci8.so files, decompression at the same time manual compilation, or as I have referred to the tutorials above, directly using the pear command to download and automatically compile.

The point is that there will be a lot of unexpected problems in the course of the tutorial, and then I'll start by writing a tutorial on the process I've successfully configured, and then explaining the problems I've encountered and how to fix it:

1. Solving the dependency problem:

sudo apt-get update
sudo 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 their own system into the corresponding list, respectively, download the corresponding Instantclient-basic-xxx.zip and Instantclient-sdk-xxx.zip.

3. Decompression, create a soft link to the library file;

This step is very important, and if handled improperly, the following compilation steps will not pass.

3.1 Unzip the file and remove the version number from the two folders. Also known as instantclient and SDK, then move the SDK folder whole to the Instantclient directory and coexist with other library files. Most other tutorials on the web do not describe the storage of the two folders, or they are placed directly in the same level of directory, resulting in the subsequent compilation of the SDK will always be prompted not to find. 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, enter the Instantclient directory, in the directory to create soft links (other tutorials do not describe the location of the link file). Note that you cannot directly create a link to a library file by right-clicking it:

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

Having completed this step, we can move the Oracle Instantclient folder throughout to our pre-arranged location, recommended by:

/usr/local/lib/

When the entire directory is replicated, the directory is referred to:

sudo chmod 777-r/usr/local/lib/instantclient/

Then configure some of the system constants that we might need next:

sudo vim/etc/environment

Add the following constants to the end of the file:

# Oracle Instant Client
Ld_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
Then you will automatically download the Oci8 source package and automatically compile it, and then you will be prompted to enter the Instantclient related PATH variable: input

Instantclient,/usr/local/lib/instantclient

The system is then compiled to indicate:

Build process completed successfully
Installing '/usr/lib/php5/20121212/oci8.so '
Install ok:channel://pecl.php.net/oci8-2.0.8
Configuration option ' Php_ini ' is ' not ' set to php.ini location
Should add "extension=oci8.so" to PHP.ini

If there is no such a hint, then congratulations, it must be the process of error. Let's assume that the end has been smooth. By now we have successfully compiled the oci8.so this extension. The next step is to assign it to the usage environment.

5. Configure PHP


We can open the extension directly in the 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/etc/php5/apache2/conf.d new Oci8.ini This file, apache2/conf.d This directory, will find all the plug-ins are preceded by numbers, here we do not have to pipe, directly ignore:


sudo Vim/etc/php5/apache2/conf.d/oci8.ini then adds the statement open oci8.so to the file.

Extension=oci8.so and restart Apache.


[HTML] View Plaincopyprint? Look at the code on the codes. Derived from my Code slice
Sudo/etc/init.d/apache2 restart

Sudo/etc/init.d/apache2 restart
When the reboot is complete, create a new test.php file in the server root directory and write:

<?php phpinfo ()?>

See if anything similar to 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 means that our configuration has been successful.

The following is the debug link:

1. The compilation process appears:

Configure:WARNING:You'll need re2c 0.13.4 or later if you are want to regenerate PHP parsers.
Resolved through the following:

When compiling and installing FileInfo for PHP, Configure:WARNING:You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. Read it and say it's re. 2c this thing.
Solution:
wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
Tar zxf re2c-0.13.5.tar.gz && CD re2c-0.13.5
./configure
Make && make install
Then go to compile installation FileInfo, will not report re2c error.

2. The compile process appears the library file cannot be found:
Configure:error:Oracle Instant Client Libraries libnnz.so and libclntsh.so not found
Check to see if you created the soft link through the command line


3.checking Oracle Instant Client SDK Header directory ... configure:error:Oracle Instant Client SDK header files not Foun D
Whether 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.




Ubuntu 14.04 Install Oracle database management software SQL Developer Records

The whole process of thinking is as follows:

1. Check the local JDK version and reconfigure the JDK environment if it is old

2. From the Oralce official download the corresponding version of the Sqldeveloper

3. Solve Sqldeveloper Chinese display garbled

4. Set to run from the command line

Installation process:

1. Check the local JDK version:

Java-version

Java Version "1.8.0_31"
Java (TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot (TM) 64-bit Server VM (build 25.31-b07, Mixed mode)

Above is the JDK version of my system and it is highly recommended that you upgrade the JDK version if your version is too low. Otherwise, during the next installation of the latest version of the Sqldeveloper process, the boot will prompt the JDK version is too low.

The latest version of the JDK, currently available on the Oracle official web site, is 1.8, and we have direct access to the following URL to download the corresponding version of the JDK:

Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

The specific version needs to be based on your system, for example, my system is Ubuntu X64 14.04, then download the jdk-8u31-linux-x64.tar.gz version. Remember not to download the RPM format installation package. We are a debian/ubuntu type of system and do not support RPM installation files.

Download complete, unzip the file, and then check if your system has the JDK installed, or check your system for the following directories:

/usr/lib/jvm

If not, use

sudo MKDIR/USR/LIB/JVM

Create a directory. If so, simply copy the entire JDK folder that we downloaded and unzip to the directory.

Next, configure the JDK's environment variables:

sudo vim ~/.profile

Add the following statement below the file:

# #For Jdk1.8.0_31 PATH
Export java_home=/usr/lib/jvm/jdk1.8.0_31
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH

The path to the Java_home constant needs to be configured according to your actual situation.

The configuration is then made effective immediately:

SOURCE ~/.profile

No surprises, you can see your JDK version again through the Java-version command, and you'll get the same output as I did.

Even if your system has already installed the previous version of the JDK, you do not have to process the original JDK. This process automatically sets the system's JDK to the most recently installed version.

2. Download the latest version of Oracle Sqldeveloper installation package from Oracle:

Http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/sqldev-41ea-2372780.html

When downloading, because it is an Ubuntu system, select the other platform version when the version is selected.

After the download is complete, unzip it and place it in the user's home directory, for example, my ~/giantchan/.

Then access the folder from the command line:

CD ~/User name/sqldeveloper


Run sqldeveloper.sh

sudo./sqldeveloper.sh

The first time you start, you will be prompted to enter the path to the JDK. How do I see the path to the JDK?

Which Javac

We can print out the JDK directory through this command:

/usr/lib/jvm/jdk1.8.0_31/bin/javac

We intercept the path here to jdk1.8.0_31/, which is also:

/usr/lib/jdk1.8.0_31

Remember not to bring "/bin/javac", otherwise it will be an error, because sqldeveloper.sh will automatically look for the bin directory in the directory. If you add a path to the bin directory, you will repeat it.

If you accidentally add the bin directory, we can go to the/home/username/.sqldeveloper/4.1.0 (version number)/product.conf

sudo vim/home/username/.sqldeveloper/4.1.0 (version number)/product.conf

Locate the following statement to modify the path of the true JDK for the path:

Setjavahome/usr/lib/jvm/jdk1.8.0_31

Save exit after the modification is complete.

Rerun the./sqldeveloper.sh file. At this point the discovery can start the sqldeveloper normally. However, the client interface will still appear in Chinese garbled. Then the third step is to solve the garbled problem.

3. Solve the garbled problem of Sqldeveloper under Ubuntu:

We download any Chinese font TTF files from the Internet (must be TTF).

Then follow the tutorial step-by-step:

CD java_home/jre/lib/fonts

sudo mkdir fallback

CD fallback

CP Msyh.ttf./# The Msyh.ttf here is the font file, this is Microsoft ya black, you can use other font files, as long as the support of Chinese can be.

sudo mkfontdir

sudo mkfontscale

Then restart the sqldeveloper. At this point, Sqldeveloper has been successfully installed on the Ubuntu, it can run normally.

4. Run from the command line:

We can add the following command to the ~/.BASHRC file:

#oracle Sqldeveloper
Alias sqld= ' CD ~/username/sqldeveloper && sudo./sqldeveloper.sh '

The settings are then immediately enforced by the source command:

SOURCE ~/.BASHRC

You can then start the Sqldeveloper software with the SQLD command.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.