Configuration PHP5.4 oci8 MySQL5.5 on CentOS6 x86_64

41 篇文章 1 订阅
18 篇文章 0 订阅

Software Package

apr-1.4.6.tar.gz
apr-util-1.5.1.tar.gz
httpd-2.4.6.tar.gz
libiconv-1.13.1.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
mhash-0.9.9.9.tar.gz
mysql-5.5.25.tar.gz
oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm
oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm
pcre-8.31.tar.gz
php-5.4.17.tar.gz

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel ssse2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gettext-devel libXpm-devel libtool libevent libevent-devel gd-devel gd libmcrypt libmcrypt-devel pcre pcre-devel 


installation apr

[root@lamop software]# tar -zxvf apr-1.4.6.tar.gz > /dev/null 
[root@lamop software]# cd apr-1.4.6
[root@lamop apr-1.4.6]# ./configure --prefix=/service/apr
[root@lamop apr-1.4.6]# make && make install
[root@lamop software]# tar -zxvf apr-util-1.5.1.tar.gz >/dev/null 
[root@lamop software]# cd apr-util-1.5.1
[root@lamop apr-util-1.5.1]# ./configure --prefix=/service/apr-util --with-apr=/service/apr
[root@lamop apr-util-1.5.1]# make && make install

installation apache

[root@lamop software]# tar -zxvf httpd-2.4.6.tar.gz > /dev/null 
[root@lamop software]# cd httpd-2.4.6
[root@lamop httpd-2.4.6]# ./configure --prefix=/service/apache --enable-dav --enable-so --enable-maintainer-mode --with-apr=/service/apr --with-apr-util=/service/apr-util
[root@lamop httpd-2.4.6]# make && make install

installation MySQL5.5

[root@lamop software]# tar -zxvf mysql-5.5.25.tar.gz > /dev/null
[root@lamop software]# cd mysql-5.5.25
[root@lamop mysql-5.5.25]# cmake . -DCMAKE_INSTALL_PREFIX=/service/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/service/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=30306 -DCOMPILATION_COMMENT=ZWC -DWITH_DEBUG=0
[root@lamop mysql-5.5.25]# make && make install
[root@lamop mysql-5.5.25]# cat /service/mysql/my.cnf 
[client]  
port            = 30306
socket          = /data/mysql/mysql.sock  
  
[mysqld]  
port            = 30306
socket          = /data/mysql/mysql.sock  
skip-external-locking  
back_log = 500  
lower_case_table_names = 1  
skip-name-resolve  
max_connections = 1024  
table_open_cache = 512  
binlog_cache_size = 1M  
max_heap_table_size = 300M  
read_buffer_size = 10M  
read_rnd_buffer_size = 16M  
sort_buffer_size = 8M  
join_buffer_size=4M  
thread_cache_size = 4  
thread_concurrency = 4  
query_cache_size = 200M  
ft_min_word_len = 4  
thread_stack = 192K  
tmp_table_size = 200M  
slow_query_log  
long_query_time = 2  
slow_query_log_file = /data/mysql/slowsql.sql  
key_buffer_size = 32M  
bulk_insert_buffer_size = 64M  
myisam_sort_buffer_size = 128M  
myisam_max_sort_file_size = 200M  
myisam_repair_threads = 4  
myisam_recover  
  
# setup innodb  
innodb_additional_mem_pool_size = 16M  
innodb_buffer_pool_size = 2500M  
innodb_data_file_path = ibdata1:10M:autoextend  
innodb_write_io_threads = 4  
innodb_read_io_threads = 4  
innodb_thread_concurrency = 16  
innodb_flush_log_at_trx_commit = 2  
innodb_log_buffer_size = 8M  
innodb_log_file_size = 512M  
innodb_log_files_in_group = 3  
innodb_max_dirty_pages_pct = 90  
innodb_lock_wait_timeout = 120  
init_connect = 'SET autocommit=0'  
innodb-file-per-table = 1  
innodb-open-file = 500  
innodb_flush_method=O_DIRECT  
  
expire_logs_days = 5  
federated  
event_scheduler = 1  
  
log-bin=ZWC-TEST  
binlog_format=mixed  
server-id       = 1  
  
[mysqldump]  
quick  
max_allowed_packet = 16M  
  
[mysql]  
prompt=\\u@\\d \\r:\\m:\\s>  
no-auto-rehash  
  
[myisamchk]  
key_buffer_size = 128M  
sort_buffer_size = 128M  
read_buffer = 2M  
write_buffer = 2M  
  
[mysqlhotcopy]  
interactive-timeout  
[root@lamop mysql-5.5.25]# /service/mysql/scripts/mysql_install_db --defaults-file=/service/mysql/my.cnf --basedir=/service/mysql --datadir=/data/mysql --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/service/mysql/bin/mysqladmin -u root password 'new-password'
/service/mysql/bin/mysqladmin -u root -h 192.168.1.10 password 'new-password'

Alternatively you can run:
/service/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /service/mysql ; /service/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /service/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /service/mysql/scripts/mysqlbug script!

[root@lamop mysql-5.5.25]# /service/mysql/bin/mysqld_safe --defaults-file=/service/mysql/my.cnf --basedir=/service/mysql --datadir=/data/mysql --user=mysql &
[1] 13675
[root@lamop mysql-5.5.25]# 131113 20:19:51 mysqld_safe Logging to '/data/mysql/lamop.err'.
131113 20:19:51 mysqld_safe Starting mysqld daemon with databases from /data/mysql
[root@lamop mysql-5.5.25]# /service/mysql/bin/mysqladmin -uroot password
New password: 
Confirm new password: 
[root@lamop mysql-5.5.25]# /service/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.25-log ZWC

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@(none) 08:21:46>delete from mysql.user where password=''; 
Query OK, 5 rows affected (0.00 sec)

root@(none) 08:21:59>delete from mysql.db where user='';
Query OK, 2 rows affected (0.00 sec)

root@(none) 08:22:07>select @@version;
+------------+
| @@version  |
+------------+
| 5.5.25-log |
+------------+
1 row in set (0.00 sec)

root@(none) 08:22:11>

installation libmcrypt

[root@lamop software]# tar -zxvf libmcrypt-2.5.8.tar.gz > /dev/null 
[root@lamop software]# cd libmcrypt-2.5.8
[root@lamop libmcrypt-2.5.8]# ./configure 
[root@lamop libmcrypt-2.5.8]# make && make install
[root@lamop libmcrypt-2.5.8]# /sbin/ldconfig 
[root@lamop libmcrypt-2.5.8]# cd libltdl/
[root@lamop libltdl]# ./configure --enable-ltdl-install
[root@lamop libltdl]# make && make install

installation mhash

[root@lamop software]# tar -zxvf mhash-0.9.9.9.tar.gz > /dev/null 
[root@lamop software]# cd mhash-0.9.9.9
[root@lamop mhash-0.9.9.9]# ./configure
[root@lamop mhash-0.9.9.9]# make && make install
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
[root@lamop mhash-0.9.9.9]# ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

installation mcrypt

[root@lamop software]# tar -zxvf mcrypt-2.6.8.tar.gz > /dev/null 
[root@lamop software]# cd mcrypt-2.6.8
[root@lamop mcrypt-2.6.8]# /sbin/ldconfig 
[root@lamop mcrypt-2.6.8]# ./configure 
[root@lamop mcrypt-2.6.8]# make && make install

installation pcre

[root@lamop software]# tar -zxvf pcre-8.31.tar.gz > /dev/null 
[root@lamop software]# cd pcre-8.31
[root@lamop pcre-8.31]# ./configure --prefix=/service/pcre
[root@lamop pcre-8.31]# make && make install

installation libiconv

[root@lamop software]# tar -zxvf libiconv-1.13.1.tar.gz > /dev/null 
[root@lamop software]# cd libiconv-1.13.1
[root@lamop libiconv-1.13.1]# ./configure --prefix=/service/libiconv
[root@lamop libiconv-1.13.1]# make && make install

installation and configuration PHP5.4

[root@lamop software]# tar -zxvf php-5.4.17.tar.gz > /dev/null 
[root@lamop software]# cd php-5.4.17
[root@lamop php-5.4.17]# ./configure --prefix=/service/php --with-apxs2=/service/apache/bin/apxs  --with-mysql=/service/mysql --with-ttf --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv=/service/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-mcrypt
[root@lamop php-5.4.17]# make && make install
[root@lamop php-5.4.17]# cp php.ini-production /service/php/lib/php.ini
[root@lamop php-5.4.17]# chown -R apache.apache /service/apache/htdocs
[root@lamop php-5.4.17]# chmod -R 700 /service/apache/htdocs
Edit "/service/apache/conf/httpd.conf"
Add the following content under "LoadModule php5_module modules/libphp5.so"

AddType application/x-httpd-php .php


installation and configuration pdo_oci,oci8,oracleClient on PHP5.4

[root@lamop software]# rpm -Uvh *.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [ 33%]
   2:oracle-instantclient11.########################################### [ 67%]
   3:oracle-instantclient11.########################################### [100%]
[root@lamop software]# rpm -qa|grep oracle
oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64
oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64
oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64
[root@lamop ~]# cd /etc/ld.so.conf.d/
[root@lamop ld.so.conf.d]# touch oracle-x86_64.conf
[root@lamop ld.so.conf.d]# echo "/usr/lib/oracle/11.1/client64/lib" > oracle-x86_64.conf 
[root@lamop ld.so.conf.d]# cat oracle-x86_64.conf 
/usr/lib/oracle/11.1/client64/lib
[root@lamop ~]# which sqlplus
/usr/bin/sqlplus
[root@lamop ~]# tail -n 3 /etc/profile
export ORACLE_HOME=/usr/lib/oracle/11.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client64/lib/:$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

pdo_oci

[root@lamop ~]# cd /service/software/php-5.4.17/ext/
[root@lamop ext]# cp -rp pdo_oci pdo_oci_bak
[root@lamop ext]# cd pdo_oci
[root@lamop pdo_oci]# /service/php/bin/phpize 
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
[root@lamop pdo_oci]# ./configure --with-php-config=/service/php/bin/php-config --with-pdo-oci=instantclient,/usr,11.1.0.1
[root@lamop pdo_oci]# make && make install
Installing shared extensions:     /service/php/lib/php/extensions/no-debug-zts-20100525/
[root@lamop pdo_oci]# ls -l /service/php/lib/php/extensions/no-debug-zts-20100525/
total 128
-rwxr-xr-x 1 root root 129213 Nov 13 21:12 pdo_oci.so

oci8

[root@lamop ~]# cd /service/software/php-5.4.17/ext/
[root@lamop ext]# cp -rp oci8 oci8_bak
[root@lamop ext]# cd oci8
[root@lamop oci8]# /sbin/ldconfig 
[root@lamop oci8]# /service/php/bin/phpize CFLAGS="-I/usr/include/oracle/11.1/client64/" 
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
[root@lamop oci8]# ./configure --with-php-config=/service/php/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/11.1/client64/lib/
[root@lamop oci8]# make && make install
Installing shared extensions:     /service/php/lib/php/extensions/no-debug-zts-20100525/
[root@lamop oci8]# ls -l /service/php/lib/php/extensions/no-debug-zts-20100525
total 648
-rwxr-xr-x 1 root root 529458 Nov 13 21:15 oci8.so
-rwxr-xr-x 1 root root 129213 Nov 13 21:12 pdo_oci.so
Edit "/service/php/lib/php.ini"
extension_dir = "/service/php/lib/php/extensions/no-debug-zts-20100525/"
extension = "oci8.so"
extension = "pdo_oci.so"

[root@lamop oci8]# /service/apache/bin/apachectl stop
[root@lamop oci8]# /service/apache/bin/apachectl stop
httpd (no pid file) not running
[root@lamop oci8]# /service/apache/bin/apachectl start
[root@lamop oci8]# /service/apache/bin/apachectl start
httpd (pid 13014) already running

phpinfo







test connection oracle database

php code

<?php 
 
 $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.233)(PORT = 1521)))(CONNECT_DATA=(SID=oraprod)))";

 $conn = oci_connect("zwc","zwc",$db); 
  
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

$stid = oci_parse($conn, 'SELECT * FROM v$version');
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>\n";
    foreach ($row as $item) {
        echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
    }
    echo "</tr>\n";
}
echo "</table>\n";
?>  



THE END



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值