Installing Apache, PHP and MySQL on IBM AIX 7.1

///Installing Apache, PHP and MySQL on IBM AIX 7.1

Installing Apache, PHP and MySQL on IBM AIX 7.1

I have recently had the pleasure of installing Apache, PHP and MySQL on a new Power 7+ 740 System running AIX 7.1 and no matter how many times I get involved with installing these products I tend to spend a lot of the day looking up the same old information and today I have decided that this is worthy of a blog post if only to serve as reminder for the next time that I will inevitably have to do this for another client.

Here is the process that I followed together with the various links that I have found useful in sourcing the open source products that I required to get the basic installations operational.

Firstly I created a separate filesystem for /usr/sys/inst.images and gave it a size of 5GB just to ensure that the /usr filesystem itself does not get too bloated with the install packages.

In order to avoid the “RPM Dependency Hell” that many of you are, I am in no doubt, more than familiar with I followed the instructions given at the following weblink:

http://www.perzl.org/aix/index.php?n=FAQs.FAQs#rpm-dependency-hell

…and installed wget-1.14-2aix5.1 together with its following list of dependencies (theres no getting around it) all of which are downloadable from http://www.oss4aix.org/download/everything/RPMS/

bash-4.2-10.aix5.1.ppc.rpm

Installation of the httpd (Apache Server)

Lets start by creating the apache user and group which will be used for the running of the Web Server, although these can be changed later if required.

# mkuser apache
# mkgroup -A apache
# mkdir /usr/sys/inst.images/httpd
# cd /usr/sys/inst.images/httpd

Download httpd-2.4.4-1.aix5.1.ppc.deps from the following link:

http://www.oss4aix.org/download/rpmdb/deplists/aix71/httpd-2.4.3-1.aix5.1.ppc.deps

and the httpd-2.4.4-1.aix5.1.rpm from the following link:

http://www.oss4aix.org/download/everything/RPMS/httpd-2.4.3-1.aix5.1.ppc.rpm

and copy them into the directory created in the above step and then run the following:

# wget -B http://www.oss4aix.org/download/everything/RPMS/ -i httpd-2.4.3-1.aix5.1.ppc.deps

Now install all the files as follows:

# rpm -Uvh *.rpm

If you receive a message stating that any packages are already installed your can either use the –force option as follows:

# rpm -Uvh –force *.rpm

* BEWARE *  use the —force option with caution as this will replace and overwrite existing packages even if existing packages are NEWER than those being installed. An alternative method is to simply remove the files for which you receive an “already installed” message from the directory and run the rpm –Uvh *.rpm command again, thus ensuring that none of your previously installed packages will be overwritten. Verify that all of the files that you want to install are correct by issuing the following command and checking the output contains the files packages that you think you should have installed.

# rpm -qa| sort | more

Once you are happy that the files you require have been installed you can start the Web Server with the following command:

# /opt/freeware/sbin/apachectl start

You can then verify that the server has started and you should see something similar to the following output:

# ps -ef|grep httpd

root 7077970 1 0 14:17:10 – 0:00 /opt/freeware/sbin/httpd -k start
apache 8519684 7077970 0 14:17:11 – 0:00 /opt/freeware/sbin/httpd -k start
apache 8585222 7077970 0 14:17:11 – 0:00 /opt/freeware/sbin/httpd -k start
apache 8716298 7077970 0 14:17:11 – 0:00 /opt/freeware/sbin/httpd -k start

Now you should be able to browse to the IP address of your AIX server and see something similar to the following:

image

Now if you wish to have the Apache Server start every time the system is rebooted then you should enter the following command to add the required entry to the /etc/inittab

# mkitab “apache:2:once:/opt/freeware/sbin/apachectl start > /dev/null 2>&1”

…and Voila!!! Apache is installed and working, so as a little tidy up you can now remove the /usr/sys/inst.images/httpd directory and its contents.

Installing PHP for AIX

The process for installing PHP is very similar and here is the process that I followed:

# mkdir /usr/sys/inst.images/php
# cd /usr/sys/inst.image/php

Now download the dependency list for mod_php_ap24-5.4.14-1.aix5.1.rpm from the following link:

http://www.oss4aix.org/download/rpmdb/deplists/aix71/mod_php_ap24-5.4.14-1.aix5.1.ppc.deps

and the mod_php_ap24-5.4.14-1.aix5.1.rpm package from the following link:

http://www.oss4aix.org/download/everything/RPMS/mod_php_ap24-5.4.14-1.aix5.1.ppc.rpm

and copy them into the directory that you created

Now run the following command to download the required files:

# wget -B http://www.oss4aix.org/download/everything/RPMS/ -i mod_php_ap24-5.4.14-1.aix5.1.ppc.deps

and once the download is complete then run the following command to install the filesets:

# rpm -Uvh *.rpm

If you receive a message stating that any packages are already installed your can either use the –force option as follows:

# rpm -Uvh –force *.rpm

* BEWARE *  use the —force option with caution as this will replace and overwrite existing packages even if existing packages are NEWER than those being installed. An alternative method is to simply remove the files for which you receive an “already installed” message from the directory and run the rpm –Uvh *.rpm command again, thus ensuring that none of your previously installed packages will be overwritten. Verify that all of the files that you want to install are correct by issuing the following command and checking the output contains the files packages that you think you should have installed.

If all of the filesets have been installed correctly then the required modifications will have been made to the /opt/freeware/etc/httpd/conf/httpd.conf which you can check by running the following command:

# tail /opt/freeware/etc/httpd/conf/httpd.conf

the last 3 lines should look like the following:


# PHP settings
Include conf/extra/httpd-php.conf

now you can restart the Apache Web Server in order to activate the PHP with the following command:

# /opt/freeware/sbin/apachectl restart

In order to test whether the PHP is actually being processed you can create a file /var/www/htdocs/testing.php which contains the following lines:

PHP testing


phpinfo() ?>

When you have done this you can then open a browser and navigate to the following web page where is the address of your server:

http:// address>/testing.php

If everything is working then you should see the following:

image

Congratulations, you now have a working Apache Server with PHP Hypertext processing…

So the next and final step is to install the MySQL database.

In order to complete this step I followed the procedure as detailed on the IBM Power Systems – AIX and Open Source Wiki, which you can find by clicking HERE

For the purposes of my installation I have updated the procedure slightly for my own purposes as follows:

  1. Login as root
  2. I created a new 2GB filesystem on the rootvg and mounted it to /usr/local
  3. I substituted the MySQL version detailed in the IBM reference material with the current latest tar ball version 5.1.30 can be downloaded from the following website: http://ftp.nchu.edu.tw/MySQL/downloads/mysql/5.1.html#aixYou might also try the following link for the MySQL Version 5.1.61 distributionhttp://ftp.sunet.se/pub/unix/databases/relational/mysql/Downloads/MySQL-5.1/mysql-5.1.61-aix5.3-powerpc.tar.gzYou can also download most versions of MySQL for AIX from the following link directly from the Oracle MySQL Product Archiveshttp://downloads.mysql.com/archives.php?p=mysql-5.1&o=aix
  4.  Make sure you have sufficient free space in /opt and /tmp (60MB+)
  5. Download and Install the following
    * Prerequisite Tools –        http://www.ibm.com/servers/aix/products/aixos/linux/download.html
    * gcc-4.0.0-1.aix5.3.ppc.rpm
    * libgcc-4.0.0-1.aix5.3.ppc.rpm
    * gcc-cplusplus-4.0.0-1.aix5.3.ppc.rpm
    * libstdcplusplus-4.0.0-1.aix5.3.ppc.rpm
    * libstdcplusplus-devel-4.0.0-1.aix5.3.ppc.rpm
    * Install using rpm -Uvh rpm name
    * MySQL
    * Download: http://dev.mysql.com/downloads/mysql/5.0.html
    * Download the 32 bit version if you plan to use PHP. I was unable to compile PHP5 with the 64 bit MySQL libraries.
    * The file I downloaded was mysql-standard-5.0.27-aix5.2-powerpc.tar.gz. Your file may be newer.
    * For this example, we’ll assume you download the file to /usr/local
    * Caution: Use “compatible” versions of Apache, PHP and MySQL. Don’t mix old with new versions. They are not compatible. I used Apache2.2, PHP5 and MySQL5. (For example, PHP4 from the AIX Linux Toolbox is not compatible with the current versions of Apache and MySQL.)
  6. Create MySQL UserID and Group
    * mkuser mysql
    * mkgroup -A mysql
  7. Uncompress the MySQL File and Link the Directory to /usr/local/mysql
    * cd /usr/local
    * gunzip mysql-standard-5.0.27-aix5.2-powerpc.tar.gz
    * tar xf mysql-standard-5.0.27-aix5.2-powerpc.tar
    * This creates the directory mysql-standard-5.0.27-aix5.2-powerpc
  8. Link Directory to /usr/local/mysql
    * ln -s mysql-standard-5.0.27-aix5.2-powerpc /usr/local/mysql
  9. Configure MySQL
    * cd /usr/local/mysql
    * scripts/mysql_install_db –user=mysql
    * chown -R root.mysql .
    * chown -R mysql.mysql data
    * chgrp -R mysql . (redundant: chown -R root.mysql .)
    * nohup bin/mysqld_safe –user=mysql &
  10. Validate MySQL Installation by Logging into Database
    * mysql -u root
    * >use mysql;
    * >show tables;
    * >exit;
  11. Add MySQL Start-Up Script to /etc/rc.d
    * cp /usr/local/mysql/support-files/mysql.server to /etc/rc.d/init.d
    * chmod a+x /etc/rc.d/init.d/mysql.server
    * Add a link in rc2.d: cd /etc/rc.d/rc2.d; ln -s /etc/rc.d/init.d/mysql.server S10mysql.server K10mysql.server
Although there will be much more work to do in configuring particular requirements for your own environments, that pretty much completes the basic installation of the Apache, PHP and MySQL to a point where everything is working.
All that remains is for a reboot to ensure that all your services start automatically as expected and your work is done, pass it off to the DBA….

*** Update – June 2015 ***

I have received some interesting feedback from people that are following this guide in relation to the latest versions of PHP (namely the 5.4 version that is available from perzl.org).

This information has been kindly provided to me by Peter Barnett in relation to his recent attempts at installing mySQL and PHP.

Peter states that he encountered issues with the PHP connecting to the mySQL database and he received an error stating that PHP was unable to find model mysql_connect (or mysql_connect), unfortunately Peter did not provide the exact syntax of the error.

Peter has found that the PHP 5.4 Version available for download from perzl.org no longer contains the legacy mySQL libraries and instead now contains the mysqli->mysqlnd API which now uses mysql scripting.

Once Peter investigated the mysql scripting he found that he could get everything working as he needed to.

Peter found some useful tutorials at the following website:

http://www.w3schools.com/php/func_mysqli_connect.asp

I have not personally had the need to investigate this fully, but I hope that it may help some of you if you are struggling.

Happy to receive any comments, both positive or negative, life is a constant learning curve…

By | 2017-10-04T10:52:04+00:00 Monday, May 20th, 2013|IBM / AIX, My Work|22 Comments

About the Author:

I am truly lucky to have found Sharon Garratt, a wonderful partner to share my passions for food, technology, photography and travel with. I really don’t know how she puts up with me.

  • I am no DB2 expert, but I believe that the libraries that you require are not installed with DB2 and you may need to install these separately, this link may help you to locate what you require:

    http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217

    Please check the following link for more regarding PHP and DB2

    http://php.net/manual/en/book.ibm-db2.php

    I think the “Installation” sub-section gives some useful information that may or may not be pertinent.

    Sorry I cannot offer any better advice, strange as it may sound, I have not had the experience of setting up PHP and Apache with DB2.

    Good luck

  • Tarek

    Thanks so much Mike for this awesome write-up , it really helped me so much , i followed your tutorial and php test page is showing up and everything is okay , and not i am trying to connect to db2 via (ibm_db2 extension) from PHP , but i can’t find the db_db2.so extension on (IBM AIX 7.1) , can you please help me with that ? , thanks so much in advance

  • Tarek

    hi , have you solved this problem please ? , also how you got db2_ibm.so thanks so much in advance

  • Pingback: 10 Days to a Better Blog – Day 7 » mike scheerer()

  • Mike Scheerer

    …another good reference is the IBM Redbook “Developing PHP Applications for IBM Data Servers”

    http://www.redbooks.ibm.com/redpieces/abstracts/sg247218.html

  • Mike Scheerer

    Just goes to show that the Internet REALLY is a small world.

    Good Luck with the problem, I am sure that it is resolvable and you may need to compile your own build of Apache to include the libraries that you need.

    Take a look at the following document which might help to point you in the right direction, although you have probably found this yourself too…:-)

    http://www.evermeet.cx/var/db2issues/db2php_1/files/DB2_PHP_Apache2_SSL.pdf

  • ani_biz

    Thanks Mike for you generous response. But the question that you are pointing to was in fact asked by me 😛

  • Mike Scheerer

    Hi there,

    Sorry but I am no DB2 expert unfortunately, but I believe your problem is that Apache cannot find the library files that it depends on for the DB2 link.

    I would suggest that a little bit of googling might turn up the answer that you need.

    I did find the following at stackoverflow.com that might help you, or at least give you a source of further assistance.

    http://stackoverflow.com/questions/24385951/dependent-module-libdb2-ashr-o-could-not-be-loaded

    Good Luck and I am sure that your problem is resolvable.

  • ani_biz

    Thanks Mike, this was really helpful.

    I am facing a problem from few days. Hoping you could help me out with this.

    I was trying to connect to DB2 from php script. I had DB2 client installed on the system, db2_ibm.so and pdo_ibm.so files for php 32 bit are also there. I have rightly added them to the PHP extension directory and php.ini.

    Now when I restart the apache, I get an error stating that:
    “Dependent module libsdb2.a(shr.o) could not be loaded.”

    And this is how I am stuck with my latest project.

  • it’s good to know that you found the information useful, it makes the writing much more worthwhile knowing that it has at least helped someone else with their problems.

  • prasoon

    Firstly thanks Mike, I owe you a beer !

    I was stuck with the problem that Cannot load /opt/freeware/lib/httpd/modules/libphp5.so , much like what Riyaz was getting.

    Later I realized that it was due to the fact that openssl 1e had to be forced installed (as opposed to 1c which has needed for httpd setup) : rpm -ivh –force openssl-1.0.1e-2.aix5.1.ppc.rpm .

    This did the trick for me.

  • Have you tried installing httpd previously? I would suggest that you remove all traces of any previous install attempts including PHP or MySQL and them follow the procedure again.

    The original IBM information is referenced and linked in the original article…

    Good Luck

  • Riyaj Shaikh

    I am getting this when I followed the document till PHP mod installation

    /opt/freeware/sbin/apachectl restart

    httpd: Syntax error on line 528 of /opt/freeware/etc/httpd/conf/httpd.conf: Syntax error on line 6 of /opt/freeware/etc/httpd/conf/extra/httpd-php.conf: Cannot load /opt/freeware/lib/httpd/modules/libphp5.so into server: t0509-130 Symbol resolution failed for /opt/freeware/lib/libssh2.a(libssh2.so.1) because:nt0509-136 Symbol strcmp (number 40) is not exported fromntt dependent module /opt/freeware/lib/libcrypto.a(libcrypto.so.1.0.1).nt0509-136 Symbol memmove (number 55) is not exported fromntt dependent module /opt/freeware/lib/libcrypto.a(libcrypto.so.1.0.1).nt0509-136 Symbol strncpy (number 64) is not exported fromntt dependent module /opt/freeware/lib/libcrypto.a(libcrypto.so.1.0.1).nt0509-136 Symbol bcopy (number 109) is not exported fromntt dependent module /opt/freeware/lib/libcrypto.a(libcrypto.so.1.0.1).nt0509-022 Cannot load module /opt/freeware/lib/httpd/modules/libphp5.so.nt0509-026 System error: Cannot run a file that does not have a valid format.nt0509-192 Examine .loader section symbols with thentt ‘dump -Tv’ command.

  • Riyaj

    Hi Where IBM has covered AIX, Apache, PHP and MySQL ? Can I get reference please

  • Something is surely not right there Boni, did you resolve the issue are you still having problems?

  • Boni

    ThnQ Mike ,This issue was fixed.But I am not clear after installing php i am not getting the GUI output what you posted. Instead of that i am getting only this on browser. PHP testing . Is it installed properly ?

  • Boni,

    You need to follow the instructions at the beginning of this post which give you the details that you need to get around the classic “Dependency Hell”, the details can be found at the following link…

    http://www.perzl.org/aix/index.php?n=FAQs.FAQs#rpm-dependency-hell

    Good Luck!!!

  • Boni

    Hi Mike I am unable to install Apache itself .Its failing with dependencies.If i am trying to install those dependencies again those dependencies need somemore dependencies. Your support will be highly appreciated .
    Thanks In Advance.

  • Pingback: Installing LAMP « KF Solutions()

  • Mike Scheerer

    Thanks Nigel much appreciated, I hope others will find it useful too, I know it was fairly well covered on the IBM site, but I wanted to put my experiences on record and give others that ask the questions about AIX, Apache, PHP and MySQL another source of reference.

  • Nigel Griffiths

    Cool article, thanks for sharing it.