Upload
proximity-group
View
422
Download
2
Embed Size (px)
Citation preview
© Proximity 2015
© Proximity 2015
About us
© Proximity 2015
Agenda
• What is open source?
• PHP for open source
• PHP on IBM i
• Live install of Zend Server
• Live install of Zend DBi
• What are Zend Server applications?
• Hands-on install from a .zpk
• Hands-on install from source
• Zend Server - A brief tour
• Configuring Zend Server – top tips
• Q & A
© Proximity 2015
Objectives – what are yours?
• What is your experience of open source applications?
• What is your experience of PHP, MySQL or Zend Server?
• Would you run an open source application on IBM i for your business?
• Are you interested in any specific open source applications?
© Proximity 2015
Objectives – what are ours?
• An understanding of open source applications on IBM i
• Implementation of Zend Server and Zend DBi
• Installation of an open source application of your choice
• Basic configuration of your open source application
• An open source application up and running
© Proximity 2015
What is open source?
© Proximity 2015
Free like a puppy
© Proximity 2015
Open source solutions
• Source code made available for free under license
• License provides rights to study, change and distribute
• Core code is free, but expect to pay for anything beyond this• Extra features
• “Skins” for CMS systems
• Support
• Cost of maintaining the software• Your time
• Backups etc.
© Proximity 2015
Open source solutions
• Can use any language or database, but PHP and MySQL is a popular combination
• PHP and MySQL are available on IBM i
© Proximity 2015
Open source solutions
• We will install the following• Zend Server – PHP engine, Apache web server
• Zend DBi – MySQL database
• This gives us our iAMP “stack”• i = IBM i
• A = Apache
• M= MySQL
• P = PHP
IBM i
Apache MySQL
PHP
Applications
© Proximity 2015
PHP on IBM i
• A great choice for web development• Easy to learn, especially for RPG developers
• PHP itself is open source and free to use
• Widely used
• Strong PHP community• Extensive resources and tools available
• Wealth of education materials
• Runs on IBM i• Integrates and works well with existing applications
• SQL database access, RPG / COBOL / CL program calls
• No 3rd party hardware required
© Proximity 2015
PHP on IBM i
HTTP request
HTML, CSS, JS etc.
CSS, JavaScript
© Proximity 2015
Installing Zend Server
© Proximity 2015
Installing Zend Server – who are Zend?
• Founded by Andi Gutmans and Zeev Suraski in 1999
• Provides products and services relating to PHP• Zend Server
• Zend DBi
• Zend Studio
• Zend Framework
© Proximity 2015
Installing Zend Server – what is Zend Server?
• The PHP engine (and not just on IBM i)
• Complete application server, including web server
• Brought to IBM i thanks to collaboration between IBM and Zend
• Basic version is free for IBM i (with forum support)
• Uses IBM HTTP Server (Apache)
• Comes complete with XML Toolkit to access native resources
© Proximity 2015
Installing Zend Server – prerequisites
• Folder /usr/local exists
• Ports 10080 - 10083 are available
• Licensed programs and PTFs appropriate to the OS version are installed
• Zend Server not already installed• I will install on to a clean partition, you can verify it works
© Proximity 2015
Installing Zend Server – prerequisites
For IBM i 6.1
• Current PTF Group for 5761DG1 (minimum SF99115 Group 13)
• FastCGI PTFs• 5761SS1 – SI36005
• 5761DG1 – SI36027
Licensed Program Product Option Description
5761SS1 33 Portable App Solutions Environment
5761SS1 30 Qshell
5761DG1 *BASE IBM HTTP Server for i
5733SC1 *BASE IBM Portable Utilities for i
5733SC1 1 OpenSSH, OpenSSL, zlib
© Proximity 2015
Installing Zend Server – prerequisites
For IBM i 7.1
• Current PTF Group for 5770DG1 (minimum SF99368 Group 1)
Licensed Program Product Option Description
5770SS1 33 Portable App Solutions Environment
5770SS1 30 Qshell
5770DG1 *BASE IBM HTTP Server for i
5733SC1 *BASE IBM Portable Utilities for i
5733SC1 1 OpenSSH, OpenSSL, zlib
© Proximity 2015
Installing Zend Server – prerequisites
For IBM i 7.2
• No additional PTFs required
Licensed Program Product Option Description
5770SS1 33 Portable App Solutions Environment
5770SS1 30 Qshell
5770DG1 *BASE IBM HTTP Server for i
5733SC1 *BASE IBM Portable Utilities for i
5733SC1 1 OpenSSH, OpenSSL, zlib
© Proximity 2015
Installing Zend Server – installing the software
• Download the appropriate SAVF from the Zend website,
and FTP to the IBM i
• Choose your installation mode• Silent (a.k.a. Batch)
• Interactive
• We will choose interactive
RSTLICPGM LICPGM(6ZSVRPI) DEV(*SAVF) SAVF(QGPL/ZSVRSAVF6)
• Skip Zend DBi for now
© Proximity 2015
Straw Poll
• What IBM i version are you running?
• Do you have Zend Server installed?
• Do you have any PHP / web development skills?
• Is your business using Open Source PHP applications on other platforms?
• Do you run Zend Server on Windows or Linux?
?
© Proximity 2015
Installing Zend Server – completing the installation
• Zend Server Console• Web based UI for configuration and monitoring of Zend Server
• Navigate to http://<your_server_IP>:10081/ZendServer
• First time in there will be initial configuration to do • Accept the license agreement
• Select the appropriate launch profile
• Development
• Production
• Set the admin and developer user passwords
• Deploy source libraries
© Proximity 2015
Exercise 1
© Proximity 2015
Installing Zend Server
• Validate the installation• Navigate to http://<your_server_IP>:10080
• Zend Server Test Page should be displayed
• Check the subsystem on the IBM i• For ease, we will use Presto to provide 5250 access via a browser
• Navigate to http://<your_server_IP>:8022/presto/presto
• Log in with QSECOFR / Proximity!!
• GO ZENDSVR6/ZSMENU > 5 > 3 > Enter
© Proximity 2015
Installing Zend DBi
© Proximity 2015
Installing Zend DBi – what is Zend DBi?
• MySQL binaries, compiled to run on IBM i
• Functionally identical to MySQL
• Popular, widely used open source database
• The database of choice for many open source applications
• Zend DBi is the IBM i implementation of MySQL, delivered by Zend
© Proximity 2015
Installing Zend DBi – installing the software
• Can be done as a second stage of the initial Zend Server installation
GO ZENDSVR6/ZSMENU
then take option 6 – ZendDBi Management menu and installation will start
• NOTE: QSECOFR privileges are required!
© Proximity 2015
Installing Zend DBi – verifying the installation
• A new subsystem and daemon job are created, so check that the
subsystem is running
WRKACTJOB SBS(ZENDDBI)
• Can also access the command line interface via QSH or QP2TERM
QSH
thencd /usr/local/mysql/bin
mysql –u root
> show databases;
> use mysql;
> show tables;
© Proximity 2015
Installing Zend DBi – verifying the installation
• After installation, the root user password should be set
> set password for ‘root’@’localhost’ = password(‘Proximity!!’)
> quit
• To access the command line interface, we now need to enter
mysql –u root --pass=‘Proximity!!’
© Proximity 2015
Exercise 2
© Proximity 2015
Installing Zend DBi
• Verify the installation• Navigate to http://<your_server_IP>:8022/presto/presto
• Log in with QSECOFR / Proximity!!
• GO ZENDSVR6/ZSMENU > 6 > 2
• Access the command line interface• QSH
• cd /usr/local/mysql/bin
• mysql –u root --pass=‘Proximity!!’
• > show databases;
• > use mysql;
• > show tables;
• > select * from user;
© Proximity 2015
Zend Server Applications
© Proximity 2015
Zend Server applications – what are they?
• Any software that you run using Zend Server• Open source applications
• Packaged, e.g. Magento, Drupal
• From Source, e.g. MediaWiki, Adminer
• Your own developed applications
• STREAM (delivery and transport management) in our case
• Once an application is configured, you can• View statistics and logging information relating to the application
• Define monitoring rules specific to the application
• Define caching rules specific to the application
© Proximity 2015
Zend Server applications – how to define an application
• Applications are created automatically when you deploy from a package
• You can also manually define an application for• Your manually developed code
• Other applications installed from source
• We will cover this in detail shortly
© Proximity 2015
Installing from a .zpk
© Proximity 2015
Installing an application from a .zpk – overview
• Zend provide a number of pre-packaged Open Source applications that can be
installed directly from the Zend Server console• Magento – e-commerce
• Drupal – content management
• WordPress – content management / blog
• Joomla – content management
• phpMyAdmin – database admin tool
• phpBB – forum
• We have successfully deployed all of these, and use Drupal running on IBM i for all
our company websites
© Proximity 2015
Installing an application from a .zpk – example
• We use Drupal extensively, so we will us this as an example• Access the Zend Server Console > Guide Page > click the Drupal icon
© Proximity 2015
Installing an application from a .zpk – download
© Proximity 2015
Installing an application from a .zpk – readme
© Proximity 2015
Installing an application from a .zpk – app details
© Proximity 2015
Installing an application from a .zpk – license
© Proximity 2015
Installing an application from a .zpk – prerequisites
© Proximity 2015
Installing an application from a .zpk – parameters
© Proximity 2015
Installing an Application from a .zpk – summary
© Proximity 2015
Installing an application from a .zpk – manual download
• Alternative approach, if you already have the .zpk file
• Access the Zend Server Console• Applications > Apps > Deploy Application
• Specify the location of the .zpk
• Remaining steps are as before
• Some config tweaks may be needed to ensure upload does not time out• Configurations > PHP > Filesystem and Streams
• Set default_socket_timeout to e.g. 300 seconds
• Configurations > PHP > Resource Limits and Tuning
• Set max_input_time to e.g. 300 seconds
© Proximity 2015
Installing an Application from a .zpk – under the covers
• Source is deployed in /usr/local/zendsvr6/var/apps/http/__default__/0
• A .conf file is generated and saved in /usr/local/zendsvr6/etc/sites.d/http/__default__/0
• The .conf files are included within the Apache config file
• Provides the necessary alias information to let Apache locate the application
• Any staging and activation scripts defined in the package are executed
• Application config based on the supplied parameters
• Generation of MySQL database if required
© Proximity 2015
Exercise 3
© Proximity 2015
Installing an application from a .zpk
• Access the Zend Server Console• Navigate to http://<your_server_IP>:10081/ZendServer
• Log in with admin / Proximity!!
• Deploy an application• Click on the Guide Page tab
• Click on the application you want to deploy
• Follow the steps defined on the crib sheet provided for the application
• Launch the application and have a wander around
• In the Zend Server Console, check the application specific statistics
© Proximity 2015
Installing from source
© Proximity 2015
Installing an application from source – overview
• Any application written in PHP that uses MySQL for the database can be
implemented on IBM i
• The examples we will look at today are• Adminer – database admin tool
• SugarCRM – CRM tool
• Mantis BT – bug tracker
• Media Wiki – wiki
• We have successfully deployed and use Adminer and SugarCRM on IBM i
© Proximity 2015
Installing an application from source – archives
• Typically, source will be provided in a .zip or .tar archive for ease of downloading
• Both of these types can be unpacked on the IBM i
© Proximity 2015
Installing an application from source – unpacking .zip files
• Download the .zip file to the IFS, go into QSH or QP2TERM and enter
jar tf <myFilePath>
to list the contents of the archive
• Navigate to the location that you want to extract to and enter
jar xf <myFilePath>
to extract the contents
© Proximity 2015
Installing an application from source – unpacking .tar files
• Download the .tar file to the IFS, go into QSH or QP2TERM and enter
tar -tf <myFilePath>
to list the contents of the archive
• Navigate to the location that you want to extract to and enter
tar -xf <myFilePath>
to extract the contents.
• If you have a .tar.gz file, extract the .tar file from it before transferring to the server
© Proximity 2015
Installing an application from source – unpacking .tar files
• The native tar command can be problematic, as file paths are limited to 100 characters
• If you get a @longlink file after unpacking, the path limit has been exceeded and some files will be
missing or wrongly named
• There are two ways to address this …
• The easy approach – save the .tar file to the IFS root and unpack, then move to the correct location
• This will only work if the file paths are now less than 100 characters
• The hard approach – install the Open Source binary for the GNU version of the tar command
• More information on how to do this is available at …
• http://www-01.ibm.com/support/docview.wss?uid=nas8N1011528
• http://www.youngiprofessionals.com/wiki/index.php/PASE/OpenSourceBinaries
© Proximity 2015
Installing an application from source – example
• Adminer is a lightweight MySQL management tool
• Single script file, so easy to install
© Proximity 2015
Installing an application from source – create folder
© Proximity 2015
Installing an application from source – create folder
© Proximity 2015
Installing an application from source – authority
© Proximity 2015
Installing an application from source – upload
© Proximity 2015
Installing an application from source – definition
• Access the Zend Server Console > Applications > click Define Application
© Proximity 2015
Installing an application from source – definition
© Proximity 2015
Installing an application from source – definition
© Proximity 2015
Installing an application from source – launch
© Proximity 2015
Exercise 4
© Proximity 2015
Installing an application from source
• Create a folder within htdocs for the application and set the folder authority• Navigate to http://<your_server_IP>:8022/presto/presto
• Log in with QSECOFR / Proximity!!
• wrklnk '/www/zendsvr6/htdocs/*‘
• mkdir ‘/www/zendsvr6/htdocs/<your_folder_name>’
• Take option 9=Work with Authority against the new folder
• Grant user QHTTPSVR *RWX data and *ALL object authority
• Upload the source• Use FileZilla to transfer the source, .zip or .tar to the new folder
© Proximity 2015
Installing an application from source
• Unpack the source (if necessary)• For .zip files
• In QSH or QP2TERM
• cd /www/zendsvr6/htdocs/<your_folder_name>
• jar xf <your_file_name>
• For .tar files
• In QSH or QP2TERM
• cd /www/zendsvr6/htdocs/<your_folder_name>
• tar –xf <your_file_name>
© Proximity 2015
Installing an application from source
• Define the Application within Zend Server• Navigate to http://<your_server_IP>:10081/ZendServer
• Log in with admin / Proximity!!
• Click on the Applications tab
• Click Define Application
• Follow the steps defined on the crib sheet provided for the application
• Launch the application and have a wander around
• In the Zend Server Console, check the application specific statistics
© Proximity 2015
Troubleshooting
• Most common problems are authority related
• Try granting QTMHHTTP full authority to the application folder and all contents
• Check the logs!
• PHP log in Zend Server console
• Apache logs in /www/zendsvr6/logs
• For specific applications refer to user documentation, or Google
© Proximity 2015
Zend Server Console
© Proximity 2015
Zend Server Console – overview – dashboard
• Default landing page when you log into the console
• Displays overview information for the server• Server statistics
• System events
• Information can also be filtered per application
© Proximity 2015
Zend Server Console – applications
• Lists defined and deployed applications
• Displays information for individual applications• Application status
• Summary information
• Provides access to application monitoring and caching rules
• Provides access to virtual host configuration and PHP library management
© Proximity 2015
Zend Server Console – configurations
• Configuration of various aspects of Zend Server
• Components – enable/disable and configure Zend Server Components
• Deployment – required for us!
• Important for app performance – Data Cache, OPCache, Page Cache
• Important for monitoring – Code Tracing, Monitor, Statistics
• PHP – configure installed PHP components
• Z-Ray – fantastic tool for developers – more later
• IDE Integration – allows close coupled debugging from Zend Studio
• Monitor – additional configuration for the Zend Monitor component
© Proximity 2015
Zend Server Console – administration
• Day-to-day administration of Zend Server
• Servers – allows restart of server and shows any server level errors
• Audit Trail – shows log of changes made to the server
• Users – change passwords for admin and developer users
• Web API – maintenance of Web API keys, used in Zend Studio integration and when
accessing the server via its API layer (e.g. from Jenkins or other CI tools)
• License – shows license information
• Settings – server level configuration
© Proximity 2015
Zend Server Console – Z-Ray Live
• Developer tool that gives insight into PHP code by delivering detailed
information into a browser component
• Information includes• PHP functions
• SQL queries
• Request variables
• Errors and warnings
• Server events
• Memory usage
• Z-Ray Live allows this data to be viewed for requests from devices where browser
component is not appropriate, e.g. mobile applications, API calls
© Proximity 2015
Configuring Zend Server
© Proximity 2015
Configuring Zend Server – top tips
• As seen on PowerWire.eu
• Character Set Configuration
• Multibyte Support
• Compression
• Bonus Tip! Memory Pools and Run Priorities
• Available on our website: http://proximity.co.uk/php-on-i
© Proximity 2015
Configuring Zend Server – character sets
Get this right now and you’ll never have character set problems
In /www/zendsvr6/conf/httpd.conf
DefaultFsCCSID 00285
CGIJobCCSID 00285
DefaultNetCCSID 01208
AddCharset UTF-8 .htm .html .xml
In /www/zendsvr6/conf/fastcgi.conf
SetEnv=“CCSID=1208” SetEnv=“LANG=C”
© Proximity 2015
Configuring Zend Server – character sets
In /usr/local/zendsvr6/share/ToolkitAPI/toolkit.ini
encoding = “UTF-8”
In the console, go to Configurations > PHP > ibm_db2
ibm_db2.i5_dbcs_alloc – set to use expanded allocations
© Proximity 2015
Configuring Zend Server – multibyte support
Means you’re not limited to ASCII
In the console, go to Configurations > PHP > mbstring
mbstring.http_output – set to UTF-8
mbstring.internal_encoding – set to UTF-8
mbstring.encoding_translation – set to On
mbstring.http_input – set to Pass
mbstring.language – set to neutral
© Proximity 2015
Configuring Zend Server – compression
A very quick win – speeds up response times of web pages
In /www/zendsvr6/conf/httpd.conf
LoadModule deflate_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
AddOutputFilterByType DEFLATE application/x-httpd-php
application/json text/css application/x-javascript
application/javascript text/html
© Proximity 2015
Configuring Zend Server – memory pools and run priorities
Worth considering for Production systems where resources are shared with legacy applications
Use WRKSHRPOOL to define one of the shared pools as “Zend”
Use CHGSBSD to allocate the pool to subsystem ZENDSVR6
Change the Zend Server Class using WRKCLS ZENDSVR6/*ALL to set Run Priority to 20,
equivalent to interactive jobs
Change the HTTP Server Class using WRKCLS QHTTPSVR/QZHBHTTP to set Run
Priority to 20, equivalent to interactive jobs
© Proximity 2015
Any questions?
© Proximity 2015
Thanks
• i-UG for the opportunity
• Steve Bradshaw for the hardware and support
• You for attending