Prepare PHP 7.2 with oracle DB connection, CentOS 7

setenforce 0

yum -y install centos-release-scl vim git wget libaio gcc
yum clean all
yum -y install 'rh-php72-*' rh-nginx116-nginx

scl enable rh-php72 bash

# libaio is needed by oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64
# yum install libaio -y

rpm -Uvh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

rpm -Uvh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

cd /usr/lib/oracle/11.2/client64/lib

echo "${PWD}" | sudo tee /etc/ld.so.conf.d/oracle-instantclient.conf
sudo ldconfig

ldconfig -p|grep oracle

cd
wget http://pecl.php.net/get/oci8-2.1.8.tgz
tar xzvf oci8-2.1.8.tgz
cd oci8-2.1.8
phpize
./configure --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib

make && make install
make test

find / -name oci8.so

php -m | grep oci8
# nothing is there

cd /etc/opt/rh/rh-php72/php.d
cat << 'EOF' > oci8.ini
extension=oci8.so
EOF

php -m | grep oci8
# it's showing up

cd
git clone https://git.zabbix.com/scm/zbx/zabbix.git --branch 5.0.8 --depth 1 --single-branch z508
cd z508/ui
mkdir /usr/share/zabbix
mv * /usr/share/zabbix

cd /etc/opt/rh/rh-php72/php-fpm.d
cat << 'EOF' > zabbix.conf
[zabbix]
user = apache
group = apache

listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/opt/rh/rh-php72/lib/php/session/

php_value[max_execution_time] = 300
php_value[memory_limit] = 2G
php_value[post_max_size] = 36M
php_value[upload_max_filesize] = 40M
php_value[max_input_time] = 300
php_value[max_input_vars] = 100000
php_value[date.timezone] = Europe/Riga
EOF

cd /etc/opt/rh/rh-nginx116/nginx/conf.d
cat << 'EOF' > zabbix.conf
server {
        listen          80;
        server_name     68.183.0.103;

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;
        }

        location / {
                try_files       $uri $uri/ =404;
        }

        location /assets {
                access_log      off;
                expires         10d;
        }

        location ~ /\.ht {
                deny            all;
        }

        location ~ /(api\/|conf[^\.]|include|locale) {
                deny            all;
                return          404;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_pass    unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock;
#                fastcgi_pass    unix:/var/opt/rh/rh-php73/run/php-fpm/zabbix.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
                fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;
        }
}
EOF

systemctl restart rh-nginx116-nginx rh-php72-php-fpm

ss --tcp --listen --numeric | grep 80

# https://www.programmersought.com/article/8265910611/
# https://www.softwarecollections.org/en/scls/rhscl/rh-php72/

No comments: