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:
…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
[ad name=”Responsive”]
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
# 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:
and the httpd-2.4.4-1.aix5.1.rpm from the following link:
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
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:
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.
[ad name=”Responsive”]
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
# 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:
and the mod_php_ap24-5.4.14-1.aix5.1.rpm package from the following link:
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:
[ad name=”Responsive”]
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://<ip address>/testing.php
If everything is working then you should see the following:
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:
- Login as root
- I created a new 2GB filesystem on the rootvg and mounted it to /usr/local
- 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
- Make sure you have sufficient free space in /opt and /tmp (60MB+)
- 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.) - Create MySQL UserID and Group
* mkuser mysql
* mkgroup -A mysql - 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 - Link Directory to /usr/local/mysql
* ln -s mysql-standard-5.0.27-aix5.2-powerpc /usr/local/mysql - 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 & - Validate MySQL Installation by Logging into Database
* mysql -u root
* >use mysql;
* >show tables;
* >exit; - 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.
[ad name=”Responsive”]
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:
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…
Tidak ada komentar:
Posting Komentar