Tôi đang cố gắng cài đặt Php 7.4.1, OracleClient và OCI8 cho kết nối Oracle. Tôi đã thử với mọi giải pháp có thể trên các diễn đàn khác nhau nhưng không có may mắn. Hệ thống: Centos Linux Phát hành 7.2.1511 [Core]
[root@localhost ~]# rpm -qa|grep php
php-common-7.4.10-1.el7.remi.x86_64
php-pecl-mcrypt-1.0.3-1.el7.remi.7.4.x86_64
php-process-7.4.10-1.el7.remi.x86_64
php-opcache-7.4.10-1.el7.remi.x86_64
php-xml-7.4.10-1.el7.remi.x86_64
php-devel-7.4.10-1.el7.remi.x86_64
php-sodium-7.4.10-1.el7.remi.x86_64
php-pdo-7.4.10-1.el7.remi.x86_64
php-pear-1.10.12-2.el7.remi.noarch
php-cli-7.4.10-1.el7.remi.x86_64
php-mysqlnd-7.4.10-1.el7.remi.x86_64
php-json-7.4.10-1.el7.remi.x86_64
php-gd-7.4.10-1.el7.remi.x86_64
php-oci8-7.4.10-1.el7.remi.x86_64
php-fedora-autoloader-1.0.1-2.el7.noarch
php-7.4.10-1.el7.remi.x86_64
[root@localhost ~]#
[root@localhost ~]# rpm -qa|grep oracle
oracle-instantclient18.3-sqlplus-18.3.0.0.0-3.x86_64
oracle-instantclient18.3-basic-18.3.0.0.0-3.x86_64
oracle-instantclient18.3-jdbc-18.3.0.0.0-3.x86_64
oracle-instantclient18.3-devel-18.3.0.0.0-3.x86_64
[root@localhost ~]#
[root@localhost ~]# vi .bash_profile
.bash_profile
Nhận các bí danh và chức năng
if [-f ~/.bashrc]; sau đó . ~/.bashrc fi
Môi trường cụ thể của người dùng và các chương trình khởi động
PATH=$PATH:$HOME/bin
Đường dẫn xuất khẩu
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
Tôi rất mới bắt đầu trong hệ thống. Bất kỳ sự giúp đỡ nào cũng được đánh giá cao
Cài đặt Apache và PHP55
Bạn có thể sử dụng apt-get trên ubuntu hoặc yum trên centos. Phiên bản mặc định của PHP trên kho lưu trữ Centos là PHP5.4, nhưng bạn có thể thêm kho lưu trữ EPEL để cài đặt PHP55. Bạn phải cài đặt các gói này trước khi cài đặt PHP-OCI8:
- Apache
- PHP với Php-Devel và PHP-Pear
- libaio trên centos hoặc libaio1 trên ubuntu
- GCC
Centos 7
sudo rpm -Uvh //dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpsudo rpm -Uvh //rpms.famillecollet.com/enterprise/remi-release-7.rpmsudo yum —enablerepo=remi,remi-php55 install httpd php php-devel libaio gcc
Ubuntu 14.04
sudo apt-get updatesudo apt-get install apache2 php5 php5-dev php5-pecl libaio1 gcc
Cài đặt PHP-OCI8
Bạn sẽ cần Oracle Instant Client, bạn có thể tải xuống tại đây. Nhận các gói cơ bản và SDK và trích xuất nó đến một nơi nào đó, ví dụ: /opt /instantClient.
Sử dụng PECL để cài đặt OCI8:
sudo pecl install oci8
Bạn sẽ được nhắc nhở cho thư mục oracle_home, nhập instantclient,/của bạn/instantClient/địa điểm. Bán tại:
instantclient,/opt/instantclient
Bật tiện ích mở rộng OCI8 trên php.ini của bạn. Thêm dòng này vào cuối tệp Php.ini của bạn:
extension=oci8.so
Thêm các biến môi trường Oracle vào Apache
Bạn phải thêm các biến môi trường vào Apache của bạn. Bạn có thể sử dụng mô -đun Apache SetEnv để thêm các biến môi trường. Thêm dòng này vào httpd.conf của bạn:
SetEnv LD_LIBRARY_PATH /opt/instantclient
Khởi động lại Apache của bạn và sau đó kiểm tra PHPINFO trên trình duyệt của bạn.
Nếu bạn đang sử dụng Centos, bạn cần định cấu hình SELINUX để cho phép HTTPD thực thi các chương trình yêu cầu địa chỉ bộ nhớ có thể thực thi và có thể ghi.
setsebool -P httpd_execmem 1
Giới thiệu
Lưu ý: Xem Cài đặt cập nhật OCI8 của tôi dưới dạng tiện ích mở rộng được chia sẻ trên bài viết của RHEL hoặc CentOS cập nhật bài viết này.
Đáp lại bài viết nổi tiếng cực kỳ [hàng ngàn lượt truy cập] của tôi khi cài đặt OCI8 trên RHEL, tôi quyết định thêm bài viết này vì tôi thấy những hướng dẫn đó đã trở nên lỗi thời và cũng nên sử dụng Php 7.2 với bất kỳ ứng dụng web nào mà bạn hiện đang hỗ trợ. Php 7.2 cung cấp các cải tiến hiệu suất đáng kể so với Php 7.0, vì vậy nếu bạn đang sử dụng Php 7.0, tôi khuyên bạn nên cập nhật lên PHP 7.2.
Dừng Apache
Bạn cần phải dừng Apache [máy chủ web] bằng lệnh sau. Trong bất kỳ lệnh Linux nào tôi hiển thị trong bài viết này, nó cho rằng bạn đã đăng nhập với tư cách là người dùng gốc, vì vậy bạn sẽ cần sử dụng sudo để ban hành các lệnh đặc quyền.sudo to issue privileged commands.
sudo service httpd stop
Thêm kho lưu trữ Epel & Remi
Bạn cần phải cài đặt các kho lưu trữ Epel & Remi như sau:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
0Đặt trình quản lý cấu hình cho PHP 7.2
Bạn cần phải nhờ YUM-UTILS sử dụng trình quản lý yum-config để đặt kho lưu trữ mặc định bằng cách sử dụng các lệnh sau:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
1Các ở trên cho phép kho lưu trữ REMI PHP 7.2.
Nếu bạn đã cài đặt Php 5.x hoặc Php 7.0, bạn sẽ cần tìm ra cách xóa nó. Tôi đã sử dụng lệnh này để xóa Php70u khỏi [các] hệ thống của mình:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
2Sau đó, bạn có thể kiểm tra xem bạn có còn cài đặt PHP với lệnh này không:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
3Bạn không nên thấy bất cứ điều gì liên quan đến cài đặt PHP, nếu không sẽ gỡ cài đặt gói.
Sau đó, bạn có thể cài đặt Php 7.2; Trong kịch bản của mình, tôi thường phát triển các ứng dụng Symfony sử dụng PHP trong Apache. Trong trường hợp của tôi, tôi sẽ sử dụng lệnh sau để cài đặt:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
4Điều này cài đặt tất cả các gói tôi cần.
Cài đặt OCI8
Đây là phần có thể trở nên khó khăn. Bạn sẽ có thể phát hành những điều sau đây tại thời điểm này:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
5Sau đó, bạn sẽ cần chỉnh sửa tệp php.ini như sau:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
6Đó là vị trí điển hình của tệp php.ini. Trong Symfony, hãy xem liên kết của View View Phpinof [], và sau đó tìm kiếm tệp cấu hình đã tải trên mạng, hiển thị tệp bạn cần chỉnh sửa. Sau đó, ở dưới cùng của tệp này, thêm dòng này:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
7Sau đó, trong VI, ban hành lệnh: WQ! Để lưu tệp và thoát. Sau đó, để kiểm tra xem PHP có được cài đặt đúng không, hãy đưa ra lệnh này:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
8Nếu bạn thấy các lỗi như không thể tải Thư viện liên kết động OCI8. Vì vậy, bạn có thể cần phải cài đặt lại Oracle Instant Client hoặc bạn đã cài đặt nó.
Cài đặt ứng dụng khách tức thời Oracle
Bạn cần tải xuống cho máy khách Linux của mình, ví dụ: 2 tệp sau:
Oracle-InstantClient12.2-Basic-122.2.0.1.0-1.x86_64.RPM Oracle-InstantClient12.2-Devel-122.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
Đảm bảo rằng chúng nằm trong thư mục nhà của bạn, sau đó cài đặt với các lệnh sau:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
9Sau đó đưa ra lệnh sau để xác minh PHP được cài đặt chính xác:
[root@localhost ~]# vi .bashrc vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
[root@localhost ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
8Bạn sẽ thấy không có lỗi và phiên bản Php 7.2 hiển thị.
Xác minh OCI8 & PHP 7.2 trên máy chủ web
Bạn cần phải khởi động lại máy chủ web Apache của mình:
sudo rpm -Uvh //dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpsudo rpm -Uvh //rpms.famillecollet.com/enterprise/remi-release-7.rpmsudo yum —enablerepo=remi,remi-php55 install httpd php php-devel libaio gcc1
Sau đó, trong Symfony, hãy nhìn vào liên kết của View View PhpInfo []. Hoặc tạo riêng của bạn bằng cách sử dụng mã này:
sudo rpm -Uvh //dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpsudo rpm -Uvh //rpms.famillecollet.com/enterprise/remi-release-7.rpmsudo yum —enablerepo=remi,remi-php55 install httpd php php-devel libaio gcc2
Sau đó tìm kiếm trên trang cho chuỗi trực tuyến OCI8, bạn sẽ thấy một cái gì đó giống như hình ảnh sau: