免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3299 | 回复: 1
打印 上一主题 下一主题

Enabling PHP and MySQL on IBM i [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-19 21:07 |只看该作者 |倒序浏览
在 IBM i 上运行 PHP 和 MySQL ,是拓展 IBM i 应用的有效手段。希望本文能为 IBM i 带来更多的 FANS。

*******************************************************
Step 1: Check the Environment
*******************************************************

1. Make sure the IBM i version of your System is V5R4, or later.

2. Check the prerequisites for PHP & MySQL installation.

   DSPSFWRSC - Display Software Resource
   
    For i5.4:
    5722SS1      *BASE                       i5/OS Version 5 Release 4 (V5R4)
    5722SS1      Option 13                       System Openness Includes
    5722SS1      Option 30                       Qshell
    5722SS1      Option 33                       Portable App Solutions Environment
    5722SS1      Option 34                       Digital Certificate Manager
    5722DG1      *BASE                       IBM HTTP Server for i5/OS

   For i6.1:
    For i5.4:
    5761SS1      *BASE                       i5/OS Version 6 Release 1 (V6R1)
    5761SS1      Option 13                       System Openness Includes
    5761SS1      Option 30                       Qshell
    5761SS1      Option 33                       Portable App Solutions Environment
    5761SS1      Option 34                       Digital Certificate Manager
    5761DG1      *BASE                       IBM HTTP Server for i5/OS

3. Make sure that TCP/IP settings are correct.

GO TCPADM
  -> Choose 1
  -> Choose 12 - Change TCP/IP Domain (CHGTCPDMN)
GO TCPADM  
  -> Choose 1
  -> Choose 10 - Work with TCP/IP Host Table Entries

4. Make sure HTTP Server Admin Instance is active.

   NETSTAT
          -> Choose 3
                -> Press Shift+F2 - Find Port 2001 - httpd admin instance

  WRKSBSJOB SBS(QHTTPSVR)

     Job           User      Type     -----Status-----   Function        
     ADMIN       QTMHHTTP    BATCH    ACTIVE             PGM-QZHBMAIN   
     ADMIN       QTMHHTTP    BATCHI   ACTIVE             PGM-QZSRLOG     
     ADMIN       QTMHHTTP    BATCH    ACTIVE             PGM-QLWISVR     
     ADMIN       QTMHHTTP    BATCHI   ACTIVE             PGM-QZSRHTTP   
     ADMIN       QTMHHTTP    BATCHI   ACTIVE             PGM-QYUNLANG   
     ADMIN2      QLWISVR     BATCHI   ACTIVE             JVM-com.ibm.lw  
   
If httpd admin instance is not active, type:

   STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)

To verify it, type:

   http://<server_ip>:2001

5. Signon to your System, and make sure your job has the following attributes:

DSPJOB
          -> Choose 2
                -> Press Page Down - Find the following attributes:

    Language identifier . . . . . . . . . . . . . . . :   CHS
    Country or region identifier  . . . . . . . . . . :   CN
    Coded character set identifier  . . . . . . . . . :   65535  
    Default coded character set identifier  . . . . . :   935   

6. Now, you can enter the command one by one. And if the command is  too long for Cut & Past, just use CALL QCMD to enter the screen of Command Entry.


*******************************************************
Step 2:  Prepare for the Installation
*******************************************************

1. Download the ZendCore for i5/OS from the following web site. Currently, the latest version is V2.6

http://www.zend.com/en/products/platform/downloads

Unzip the zip-file ZendCoreFori5_OS-2.6.1.zip, and FTP the zcoresavf to your AS/400, under a library, e.g., SAVZEND26

2. Download another save-file from the following web site.

http://www.91files.com/?KBDKDJDY5YTJB3MQ20S1

It contains some prerequisites for either installation or verification.

Similarly, FTP the savzend.savf to your AS/400, under the library QGPL.

3. Restore the library SAVZEND, by entering the following command:

RSTLIB SAVLIB(SAVZEND) DEV(*SAVF) SAVF(QGPL/SAVSEND)  

It will create the library of SAVZEND, which contains five save files:

Q5733SC100  *FILE       SAVF
Q5733SC101  *FILE       SAVF
SAVDBTEST   *FILE       SAVF
SAVPMADM    *FILE       SAVF
SAVTEST     *FILE       SAVF


*******************************************************
Step 3: Install Portable Utilities, DBTEST, and Zend Core
*******************************************************

1. Install 5733-SC1.

RSTLICPGM LICPGM(5733SC1) DEV(*SAVF) OPTION(*BASE)
             LNG(2984) SAVF(SAVZEND/Q5733SC100)

RSTLICPGM LICPGM(5733SC1) DEV(*SAVF) OPTION(1)
             LNG(2984) SAVF(SAVZEND/Q5733SC101)

2. Restore Library DBTEST, and two tar files.

RSTLIB SAVLIB(DBTEST) DEV(*SAVF)
             SAVF(SAVZEND/SAVDBTEST)

RST DEV('/qsys.lib/savzend.lib/savtest.file') OBJ(('/home/*'))

RST DEV('/qsys.lib/savzend.lib/savpmadm.file') OBJ(('/home/*'))

3. Install PHP and MySQL.

CHGJOB CCSID(1388)

RSTLICPGM LICPGM(1ZCORE5) DEV(*SAVF)
    OPTION(*BASE) SAVF(SAVZEND26/ZCORESAVF)

CHGJOB CCSID(65535)

4. Enter the following commands:

ADDLIBLE ZENDCORE

ZCCSTREACD LIB(ZENDCORE) PORT(6078) RESTART(*YES)

CALL QP2TERM

# cd /www/zendcore/htdocs
# cp /home/test.tar .
# tar -xvf test.tar
# rm /home/test.tar

# cp /home/phpMyAdmin.tar .
# tar -xvf phpMyAdmin.tar
# mv phpMyAdmin-2.11.8.1-all-languages-utf-8-only phpMyAdmin
# rm /home/phpMyAdmin.tar

# cd /usr/local/mysql

// To Set the password for 'root'@'localhost'

# bin/mysqladmin -u 'root' -h 'localhost' password 'password'   

// To use MySQL in PASE

# bin/mysql --user='root' --password='password'   
# mysql> use mysql
# mysql> select user, host from mysql.user;     
# mysql> quit

// To grant All Privileges to 'root'@'localhost'

# bin/mysql --user='root' --password='password'
# mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'
          IDENTIFIED BY 'password' WITH GRANT OPTION;
# mysql> quit

// Some Useful Commands:

# bin/mysqladmin version --password='password'   
# bin/mysqladmin variables --password='password'   
# bin/mysqlshow --password='password'   
# bin/mysqlshow mysql --password='password'   


*******************************************************
Step 4: Verify the Installation
*******************************************************

1. Check the status of those jobs under subsystem ZEND and ZMYSQL.

WRKSBSJOB SBS(QHTTPSVR)

Job         User        Type     -----Status-----  Function   
ZENDCORE    QTMHHTTP    BATCH    ACTIVE            PGM-QZHBMAIN  
ZENDCORE    QTMHHTTP    BATCHI   ACTIVE            PGM-QZSRLOG   
ZENDCORE    QTMHHTTP    BATCHI   ACTIVE            PGM-QZSRLOG   
ZENDCORE    QTMHHTTP    BATCHI   ACTIVE            PGM-QZSRHTTP  
ZENDCORE    QTMHHTTP    BATCHI   ACTIVE            PGM-QZSRHTTP  

WRKSBSJOB SBS(ZEND)  

Job         User        Type     -----Status-----  Function   
I5_COMD     QTCP        BATCH    ACTIVE            PGM-EASYCOMD
ZC_STR_PRN  ZENDADMIN   BATCHI   ACTIVE            PGM-prngd   
ZENDCOREAP  ZENDADMIN   BATCHI   ACTIVE            PGM-httpd   
ZENDCOREAP  ZENDADMIN   BATCHI   ACTIVE            PGM-httpd   
ZENDCOREAP  ZENDADMIN   BATCHI   ACTIVE            PGM-httpd   
ZENDCOREAP  ZENDADMIN   BATCHI   ACTIVE            PGM-httpd   
ZENDCOREAP  ZENDADMIN   BATCHI   ACTIVE            PGM-httpd   
ZENDCOREAP  ZENDADMIN   BATCHI   ACTIVE            PGM-httpd   


WRKSBSJOB SBS(ZMYSQL)  

Job         User        Type     -----Status-----  Function        
ZMYSQLD     MYSQL       BATCHI   ACTIVE            PGM-mysqld      

2. Verify the connection by using NETSTAT:

   NETSTAT
          -> Choose 3
                -> Press Shift+F2 - Find Port 89 – zendcore http instance
                           - Find Port 6078 – i5_COMD service

3. Access Zend Core Administration Console.

http://<server_ip>:89/ZendCore/

4. Access PHP environment.

http://<server_ip>:89/test/hello.php

5. Access via db2_API from PHP

EDTF STMF('/www/zendcore/htdocs/test/dbaccess1.php')

|-> $database = "xxxxxxxx"; // Use WRKRDBDIRE to retrieve Name of LOCAL DB
|-> $usr      = "xxxxxxx";  // Use Uppercase
|-> $pwd      = "xxxxxxx";  // It is case sensitive

EDTF STMF('/www/zendcore/htdocs/test/dbaccess2.php')

|-> $database = "xxxxxxxx"; // Use WRKRDBDIRE to retrieve Name of LOCAL DB
|-> $usr      = "xxxxxxx";  // Use Uppercase
|-> $pwd      = "xxxxxxx";  // It is case sensitive

http://<server_ip>:89/test/dbaccess1.php
http://<server_ip>:89/test/dbaccess2.php

6. Access Demos via i5_command

CD DIR('/www/zendcore/htdocs')  
EDTF STMF('./i5Toolkit_library/demo_for_toolkit_classes.php')

|  include_once('Toolkit_classes.php');                                      
|  /* Define i5/OS user and password before running this demo program  */   
|->$USER="xxxxxxxx";        // It should not be QSECOFR                                                
|->$PASSWORD="xxxxxxx";     // It is case sensitive                                                
                                                                          
http://<server_ip>:89/i5Toolkit_library/demo_for_toolkit_classes.php
http://<server_ip>:89/Zend_Navigator_Demo/login.php

7. Access MySQL

CD DIR(‘/www/zendcore/htdocs/phpMyAdmin/’)
CPY OBJ('config.sample.inc.php') TOOBJ(config.inc.php) REPLACE(*YES)                                                      
EDTF STMF('config.inc.php')

|   /*
|    * First server
|    */
|   $i++;
|   /* Authentication type */
|-> /* $cfg['Servers'][$i]['auth_type'] = 'cookie'; */
|-> $cfg['Servers'][$i]['user'] = 'root';
|-> $cfg['Servers'][$i]['password'] = 'password';

http://<server_ip>:89/phpMyAdmin/

a. Create the Database 'dbtest'
(set collation as utf8-general-ci or utf8-unicode-ci)
b. Import MYSQL_DBTEST.SQL (in attached zip file) as script to create the table 'userlist'

http://<server_ip>:89/test/mysqlaccess.php

If you can see the following screen, CONGRATULATIONS !

The result of the query is:
Employee ID         Employee Name         Telephone Number
914885              李四                  13805993500
923599              张三                  13805848506
912009              王五                  13801249560

*******************************************************
Step 5: Trouble Shooting
*******************************************************

1. When having problem, see the Log files under the following three directories:

  /usr/local/Zend/apache2/logs
      access_log                            STMF
      error_log                             STMF

  /usr/local/Zend/Core/logs
      php_error_log                         STMF

  /www/zendcore/logs
      access_log.Qxxxxxxxxx                 STMF
      error_log.Qxxxxxxxxx                  STMF


2. Enter the following commands:

CALL QP2TERM

/usr/local/Zend/apache2/bin/apachectl start

The correct response is:
httpd (pid xxxxx) already running   

However, if you get the following error message:

httpd: Syntax error on line 1033 of /usr/local/Zend/apache2/conf/httpd.conf:
Cannot load /usr/local/Zend/Core/modules/apache2/libphp5.so into server:
Could not load module /usr/local/Zend/Core/modules/apache2/libphp5.so.\n\t
Dependent module libz.a(libz.so.1) could not be loaded.\n
Could not load module libz.a(libz.so.1).\n
System error: No such file or directory\n
Could not load module /usr/local/Zend/Core/modules/apache2/libphp5.so.\n
Additional errors occurred but are not reported.         

Then, you should install 5733-SC1.


*******************************************************
The END
*******************************************************


[ 本帖最后由 oliverchenbing 于 2009-9-19 21:15 编辑 ]

Enabling PHP and MySQL on IBM i.zip

24.75 KB, 下载次数: 27

论坛徽章:
0
2 [报告]
发表于 2009-10-15 14:54 |只看该作者
呵呵, 我顶下.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP