вторник, 27 февраля 2018 г.

root sqlplus

ISCore for IAS & Weborama Registers

Terms:
  • iscore: nomvc framework for both Weborama and IAS Registers
  • registers: products which uses nomvc framework
This manual describes deployment of the products, not just nomvc.

Dependencies installation

Install all necessary packages:
$ sudo apt-get install apache2 apache2-dev
$ sudo apt-get install libapache2-mod-php7.0
$ sudo apt-get install libc-client-dev libkrb5-dev
$ sudo apt-get install libreadline-dev
Use apt-cache search for list available packages:
$ sudo apt-cache search php7.0-*
Install necessary php libraries
$ sudo apt-get install \
$ php-soap \
$ php7.0-mbstring \
$ php7.0-zip \
$ php7.0-xml \
$ php7.0-curl \
$ php-xdebug 
Enable necessary php modules:
$ sudo a2enmod php7.0
$ sudo a2enmod rewrite
Put your development account into www-data apache2 auxiliary applicative group:
$ sudo usermod -aG www-data eandreev

info.php for debug and troubleshooting

Create info.php in /var/www/html for further debug and troubleshooting:

Virtual host configuration

Edit local /etc/hosts and put there hot names for appropriate Registers:
$ sudo vim /etc/hosts
Contents of the file:
127.0.0.1   isreport
127.0.0.1   wreport
Further I will use isreport Regiter as example, but same operation are valid for wreport Register
Copy default virtual host configuration:
$ cd /etc/apache2/sites-available
$ sudo cp 000-default.conf isreport.conf
Edit appropriate virtual hosts:
$ sudo vim isreport.conf
Contents of virtual host configuration file:
<VirtualHost *:80>
    ServerName isreport
# -
    ServerAdmin webmaster@localhost
    DocumentRoot /home/[user]/NetBeansProjects/isreport/web
# -
    <Directory /home/[user]/NetBeansProjects/isreport/web>
        AllowOverride all
        Require all granted
    </Directory>
# -
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Retart apache and watch the log:
$ sudo service apache2 restart
$ sudo tail -f /var/log/apache2/error.log
Enable virtual host and reload apache:
$ sudo a2ensite isreport.conf
$ sudo service apache2 reload

Fetching the project from the git

$ cd ~/NetBeansProjects
$ git clone ssh://git@git.ias.su:2022/backend-developers/iscore.git
$ git clone ssh://git@git.ias.su:2022/backend-developers/isreport.git
Open the project in IDE, as Create new PHP project from existing source.

Applicative configuration

There is two main configuration file, both of them resides in the product working copy folder:
  1. context.yml: application configuration configuration file, which contains main part of application configuration data. You can import working test configuration from the server, or create your own from the template.
  2. isconfig.php: system application configuration file, which mainly contains local paths configuration
    1. Path to the current product root
    2. Path to the root of iscore

Import configuration from the server

You can import context.yml from the server using scp:
cd isreport
scp act4:/opt/www/project/isreport_test/apps/index/config/context.yml \
apps/index/config/

Create the configuration manually

You can create the configuration manually.
Put in /apps/index/config/context.yml code as follow:
prod: []
debug: []
all:
  project_name: IASReport
  db:
    dsn: oci:dbname=dbact4;charset=UTF8
    user: isreport_test
    passw: isreport_test
  smtp:
    host: mail.ias.su
    port: 25
    email: isreport_test@ias.su
#------------------------- for weborama ----------------------------------------
  adrime:
    apikey: [apikey]
  wcm:
    application_key: [public_key]
    private_key: [private_key]
    email: beinteractive2011@gmail.com
    password: [password]
  audit:
    url: http://wte-api.weborama.io/api/
    login: service@ias.su
    password: [password]
  adfox:
    url: https://api.adfox.ru/v1/API.php
    common_url: https://login.adfox.ru/commonReportsOutputForm.php
    login: weborama_sites
    password: vaHE_piso2
  wcm_files:
    storage_remote: 'cstatic.weborama.fr'
    storage_local: '/data/wreport/wcmfiles'
#--------------------- end for weborama ----------------------------------------
  alert:
    email: o.pshenichnikova@be-interactive.ru
  b1c:
    #тестовая версия
    url: http://78.40.28.202/v83_acc_IAStest/WS/ws1.1cws?wsdl
    login: service_account
    password: [password]
  imap:
    conn: '{mail.nic.ru:993/imap/ssl/novalidate-cert}'
    login: isreport_test@ias.su
    password: [password]
#--------------------------

isconfig.php

The applicative system configuration.
  1. Create isconfig.php file in root of the product directory.
  2. Populate it with appropriate data: paths for necessary folders.
define('IS_CORE_PATH', '/home/opshenichnikova/NetBeansProjects/iscore_test');
define('LOCAL_BASE_PATH', '/home/opshenichnikova/NetBeansProjects/wreport_test');

Set necessary permissions

cd ~/NetBeansProjects
sudo chown -R eandreev:www-data .

PHP complilation

You need compile PHP by your self, thus default PHP distribution does not contains oracle driver - OCI, and it is impossible to compile it completely separate from the main PHP binary.
IAS have its own complilation of PHP containing necessary libraries, but it isn't working currently.
When it will be fixed you will able to download it from repository given below.
For compile PHP with OCI, you need download appropriate SDK from Oracle.
What you will need to do (every step described separately in further chapters):
  1. Download basic + sdk 12.1 + sqlplus
  2. Unzip all
  3. Place unziped data in shared place
  4. Fix folder structure
  5. Prepare SDK with ldconfig

Download instant client SDK from Oracle

You need have free Oracle account.
Use 12.1 !!!

Prepare Oracle SDK

Unpack and fix folder structure:
$ sudo mkdir /opt/oracle
$ sudo mv instantclient_12_1/ /opt/oracle/instantclient
$
$ sudo ln -s /opt/oracle/instantclient/libclntsh.so.* \
/opt/oracle/instantclient/libclntsh.so
$ sudo ln -s /opt/oracle/instantclient/libocci.so.* \
/opt/oracle/instantclient/libocci.so
$ sudo ln -s /opt/oracle/instantclient/ \
/opt/oracle/instantclient/lib
$
$ sudo mkdir -p include/oracle/11.2/
$ cd include/oracle/11.2/
$ sudo ln -s ../../../sdk/include client
$ cd -
$
$ sudo mkdir -p lib/oracle/11.2/client
$ cd lib/oracle/11.2/client
$ sudo ln -s ../../../ lib
$ cd -
Config shared objects (so) with ldconfig
$ echo /opt/oracle/instantclient/ | sudo tee -a /etc/ld.so.conf.d/oracle.conf
$ sudo ldconfig
$ cd ~

Prepare environment for the compilation

Add export of necessary environment variables in .bashrc of the uer which will compile the PHP:
$ vim ~/.bashrc
Append to the end of .bashrc file:
export ORACLE_HOME=/opt/oracle/instantclient
export LD_LIBRARY_PATH="$ORACLE_HOME"
export PATH="$ORACLE_HOME:$PATH"
export TNS_ADMIN=/etc
Install necessary packages for perform compilation:
$ sudo apt-get install build-essential autoconf automake libtool bison re2c
$ sudo apt-get install libaio1 libaio-dev libxml2-dev

Clone PHP source

Clone PHP source:
$ git clone https://github.com/php/php-src.git
$ cd php-src
PHP have master branch and much development branches. Very possible that you will fail with compilation of master branch, you need to checkout stable development one.
List all exist branches:
$ git branch -r
Checkout some stable branch.
Watch out the info on site of the PHP open source project.
$ # DO NOT CHECKOUT DEV
$ # git checkout PHP-7.0
$ # Use follow
$ git checkout origin/PHP-7.0.22

GNU Buildconf

First step is buildconf.
Some branches are production and some development. Further you will need use buildconf or buildconf --force depend on nature of the branch - dev or prod.
$ ./buildconf
$ # or
$ ./buildconf --force
$ # if no dev checkout

GNU Configure

Second step is run appropriate configure step.
There is two configure script currently - for MacOS and Linux.
The scripts are in root of iscore project, named:
  1. lin_config.sh
  2. osx_config.sh
Further you need inside PHP source folder to run appropriate configure script using relative paths
$ [path to iscore repo]/[os]_config.sh
Actual version used with --with-pdo-oci option is 12.1 You can add --with-oci8 to configure scripts if necessary

Make

$ make
$ sudo make install
If errors you have compilation errors:
$ make clean
And make again.

Configure PHP

You need to disable old cli php binary:
$ which php
$ sudo mv [path] [path]_back
IMPORTANT
According to follow bag: pcrebag, you must ajust follow valuw in php.ini:
pcre.jit=0
You need configure php.ini file.
While providing path for newly created shared objects, list directory with installed libraries:
$ ls -la /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/*.so
Edit 10-pdo.ini of current PHP installation:
sudo vim /etc/php/7.0/apache2/conf.d/10-pdo.ini
Provide there necessary paths:
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/oci8.so
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/pdo_oci.so
Every time run php -i for test your configuration.
You mut see line with ORACLE_HOME configuration.
$ php -i | grep ORACLE_HOME
Add path to instant client to Apache2 envvars:
$ sudo vim /etc/apache2/envvars
Add follow line:
export PATH=$PATH:/opt/instanclient

TNSNames

You need import tnsnames.ora file with Oracle routes:
Connect to act4 server, and find necessary path:
$ cd $ORACLE_HOME/network/admin
$ pwd
The path can be: /u01/app/oracle/product/11.2.0/db_1/network/admin/
Copy tnsnames.ora using the path:
$ scp act4:[the path]/tnsnames.ora /etc/

Composer

Download composer from Composer site.
You will find follow script there, you just need substitute appropriate hash, get it from the site.
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === 
'[hash]') { echo 'Installer verified'; } else { echo 
'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
$ sudo php composer-setup.php --filename=composer --install-dir=/usr/local/bin
$ php -r "unlink('composer-setup.php');"
Install necessary dependencies from root of the product folder:
./composer install

DB

You have deployed schemas in Oracle DB, but if you need your own schema, than:
First run schema.sql of iscore, and than of concrete project.

Frontend configuration

Make links for web folders:
$ cd [project]/web
$ ln -s [path_to_iscore]/web/js/ js
$ ln -s [path_to_iscore]/web/css/ css

Link PHP handlers

Add follow code to Apache2 main or child configuration file.
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
    Require all denied
</FilesMatch>
# Running PHP scripts in user directories is disabled by default
# 
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

Install and config php.ini

  1. Locate php.ini-production file, which came as result of make install while PHP complilation stage.
  2. Copy it in place of current php.ini config file
cp php.ini-production to /usr/lib
Edit it as you need.

Extra chapters

Compilation of Apache2

May be you will need compile Apache2 by your own, especially for MacOS working station.
Run configure, make and make install:
  1. pcre-8
  2. apr
  3. apr-util
Compile:
$ ./configure \
--with-pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr
$ make
$ make intall

IAS Repository

You can install some packages such as instant client from our company's repository.
Edit your sources.list file of apt-get:
$ sudo vim /etc/apt/sources.list
Add follow line:
deb http://repo.ias.su debcored soft
Update apt-get and install instantclient
$ sudo apt-get update
$ sudo apt-get install instantclient
For list packages available from IAS apt-get repository:
$ cat /var/lib/apt/lists/repo.ias.su_dists_debcored_soft_binary-amd64_Packages \
| grep Package
For list all installed packages, use:
$ sudo dpkg -i

Troubleshooting compilation on OSX

If you have OSX, you can get follow error:
apxs:Error: /Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.12.xctoolchain/usr/local/bin/apr-1-config not found!.
configure: error: Aborting
Fix it by:
$ which apr-1-config
/usr/local/bin/apr-1-config
$ sudo mkdir -p \
/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.12.xctoolchain/usr/local/bin/
$ sudo ln -s /usr/local/bin/apr-1-config \
/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.12.xctoolchain/usr/local/bin/
Or:
apxs:Error: /Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.12.xctoolchain/usr/local/bin/apu-1-config not found!.
configure: error: Aborting
Fix it by:
$ which apu-1-config
/usr/local/bin/apu-1-config
$ sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.12.xctoolchain/usr/local/bin/
$ sudo ln -s /usr/local/bin/apu-1-config /Applications/Xcode.app/Contents/
Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/

Pthreads

Pthreads is multithreading in PHP, but it is completely unstable with Apache2

git clone https://github.com/krakjoe/pthreads.git
cd pthreads
phpize
./configure
make
sudo make install

*****************
[name] – заменить на имя пользователя

sudo apt-get install netbeans                                  //установка среды разработки

cd ~/NetBeansProject                                                 //папка по умолчанию для проектов NB
mkdir wreport-test                                                      //папка для репозитория
cd wreport-test                              

git clone ssh://git@git.ias.su:2022/backend-developers/wreport.git  // сам репозиторий

//настройка apache

cd /etc/apache2/sites-available
sudo cp isreport.conf wreport.conf

sudo vim wreport.conf                // привести файл к виду:
                <VirtualHost *:80>
ServerName test.wreport

                ServerAdmin webmaster@localhost
                DocumentRoot /home/[name]/ NetBeansProject /wreport-test/web

 <Directory /home/[name]/ NetBeansProject /wreport-test/web>
  AllowOverride all
  Require all granted
 </Directory>
               
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

sudo a2ensite wreport.conf

sudo service apache2 reboot


sudo vim /etc/hosts
                127.0.0.1 test.wreport  // добавить строку


sudo service apache2 reboot

потом в браузере в адресной строке написать test.wreport 

УСТАНОВКА PHPSTORM UBUNTU 16.04


https://sredalinux.blogspot.ru/2014/07/ubuntu17-ubuntu.html
https://www.youtube.com/watch?v=Sz69kdItkPw
http://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html
https://www.youtube.com/watch?v=MDtFD6AB0xA
руут
https://www.youtube.com/watch?v=-mkLR1OF1nQ
доступ к любой папке
https://www.youtube.com/watch?v=528codMCv_c
https://www.youtube.com/watch?v=ICKs6uEnXWQ

https://www.youtube.com/watch?v=qs13JEBdmZI

Комментариев нет:

Отправить комментарий