Apache PHP Mysql OSX

Working in Web Development means you have to have a development environment installed on your local machine, in order to test and develop dynamic pages, using a web server (Apache,), a database (MySQL) and a scripting language (PHP). There are ways of getting those components installed in a bundle, like WAMPLAMP or MAMP. But as a developer, you are more the manual type, right? So as I had to go through that installation process recently, this article documents the steps I went through.

Apache

OSX already comes with Apache installed, it is just a matter of starting the server. You can do this if you go to System Preferences > Sharing and check “Web Sharing”. The Apache default page should now be displayed at

http://localhost

Later on, you can use the following commands to start, stop or restart Apache:

$ sudo apachectl start
$ sudo apachectl stop
$ sudo apachectl restart

If you would like to change the DocumentRoot of the server, you need to edit the httpd.conf file:

$ sudo vi /etc/apache2/httpd.conf

In here, you need to change the DocumentRoot setting:

DocumentRoot "/Users/myUser/myNewWebroot/"
<Directory "/Users/myUser/myNewWebroot/">
...
</Directory>

PHP

PHP comes bundled up with Leopard as well. The important things to know here are where it got installed and where to find the configuration file.

Most likely, it got installed to:

/usr/local/php5

The configuration file should be located at:

/private/etc/php.ini

You only need to make sure that Apache knows that PHP is available, so edit httpd.conf:
$ sudo vi /etc/apache2/httpd.conf

And add the following lines (in the appropriate sections, to keep things tidy):

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

LoadModule php5_module libexec/apache2/libphp5.so

Finished with that, restart Apache, empty the browser cache and then load a php file for testing if it is correctly interpreted.

MySQL

Download the most recent dmg image from the MySQL site.

Before actually installing MySQL, I found it helps to restart the computer before proceeding with the installation. When running through the installation wizard, MySQL will get installed to:

/usr/local/mysql-VERSION

So, for example:

/usr/local/mysql-5.0.51b-osx10.5-x86/

Also, a symlink should have been created:

/usr/local/mysql -> mysql-5.0.51b-osx10.5-x86

You should also install the Preference Pane, which comes with the installation package asMySQL.prefPane

To start MySQL manually, run the following command:
$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

You should also add MySQL to $PATH:
$ vi ~/.profile
$ export PATH=$PATH:/usr/local/mysql/bin
$ source ~/.profile

To check whether that was successful, run:
$ echo $PATH

The default settings for the root user are:

  • Username: root
  • Password: [leave blank]

Add-on: PHPmyAdmin

To get PHPmyAdmin installed, which comes in handy for managing your database(s), download the latest package from their download page. Extract that package to a directory somewhere in your DocumentRoot.

Open config.sample.inc.php with an editor of your choice and add the following details for your MySQL installation:

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'whatever'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

$cfg['Servers'][$i]['user']          = 'root';
$cfg['Servers'][$i]['password']      = ''; // use here your password

After you made those changes, save the file as config.inc.php.

PEAR

PEAR should also already be available on your Mac. The location is probably:

/usr/local/php5/bin/pear

It is a good idea to add the path to PEAR to $PATH, similar to setting the path for MySQL (see above). In addition, upgrade PEAR to the latest version like so:

$ sudo pear channel-update pear.php.net
$ sudo pear upgrade PEAR

Apache PHP Mysql AIX

Open Source with AIX

AIX has a large range of Open Source tools, and applications already ported and packaged ready for you to install. This makes it far easier and quick to get Open Source tools and applications working and useful on AIX. All the big popular Open Source stuff is available. My favourites that are in the first URL below are:

  • Apache – web server the one that runs the web
  • emacs – editor and so much more
  • ethereal – network monitoring by packets, protocol, contents
  • Ganglia – cluster performance monitoring and graphing
  • GNC GCC – compiler collection particularly C and C++
  • gimp – image manipulation
  • Gnome – desktop
  • KDE – desktop
  • gzip – file compression utility
  • MySQL – the database
  • PHP – scripting, good for web servers
  • rdist – file distribution
  • Samba – Windows filesystem and printing and much more
  • rxvt – colour xterm
  • squid – proxy server
  • vim – improved vi editor for colourised syntax highlighing
  • VNC – Virtual Network Computing X windows on any machine (even Windows!!)
  • wget – checking and copying websites

Well, your list might be different but there are hundreds of them available. You can, of course, download the original source code and compile it yourself but this means you will need the compilers (most use the GNC compilers), some programing skills and time to read up on the options and build process. then you need to perform some testing to prove it is all working. Hint: I always compile with the latest GNU compilers to avoid problems.

Where to get Open Source with AIX

The below websites have proved to be the most useful websites. If you know a good place to look for more then just one of two packages then please added here.

Source Details URL
IBM AIX Toolbox for Linux Applications –
Open Source packages available for installation on AIX 5L –
There are about 385 packages.
http://www.ibm.com/systems/power/software/aix/linux/toolbox/download.html
BULL Bull Open Software archive for AIX http://www.bullfreeware.com/
BULL Bull Gnome web site http://gnome.bullfreeware.com/new_index.html
IBM IBM Developerworks in general http://www.ibm.com/developerworks/downloads/
IBM IBM AlphaWorks http://www.alphaworks.ibm.com/
pWare Open Source Software for AIX http://pware.hvcc.edu/
perzl.org Open Source software repository for AIX –
more than 100 most recent packages available now
http://www.perzl.org/aix/

Google.com and Sourceforge are also excellent at finding additional applications and binaries for AIX.

More AIX Toolbox for Linux Applications

This should be called Open Source Applications rather than Linux Applications but the name stuck! This should the first place you look for Open Source for AIX and there is a long list. These open source packages have been prepared for installation on AIX 5L using the RPM Package Manager. These packages, also known as RPMs, are “officially” available on an as-is basis for beta-level use. Please read the statement at the top URL below for details. From personal experience these RPMs are robust and better tested than any “home grown” version. Although they are not always at the latest level.

Useful Links URL
Homepage http://www.ibm.com/servers/aix/products/aixos/linux/
Homepage on Source Forge http://sourceforge.net/projects/aixtoolbox
Licensing http://www.ibm.com/servers/aix/products/aixos/linux/altlic.html
Downloads http://www.ibm.com/servers/aix/products/aixos/linux/download.html

Support and Help for AIX Toolbox for Linux Applications

  • Although this project is not supported, a public mailing list is available to give users an opportunity to ask questions or provide feedback on the AIX Toolbox for Linux Applications. The list can be accessed from SourceForge.net at http://sourceforge.net/projects/aixtoolbox

There is also a AIX Toolbox for Linux Applications Redbook (IBM’s technical manuals written by subject matter experts) at Linux Applications on pSeries 

Does AIX come with compilers for compiling Open Source?

The answer is No – the AIX compilers are available under the name of VisualAge or XL compilers from IBM but at extra costs.
You have a number of options:

  1. Purchase the compiler from IBM or IBM Business Partners (BP)
  2. You can, however, download the the IBM compilers from the IBM website for evaluation purposes – unfortunately, these are well hidden on the website and even move about, so there is no point giving you a direct URL for a download link!! Goto http:www.ibm.com then take the link to “Products”, then take the link for “Software by category”, then the link for “Traditional Programming Languages” Once you find what you want (and don’t forget there many be more than one, for example C & C++ compiler and the VisualAge C compiler) take the “Trials and Betas” option on the far left and … well good luck. Typically, you need to download 50MB to 250 MB and have to agreed to an evaluation copy, so don’t leave this until the last minute.
  3. There are also third party vendors selling excellent compilers.
  4. Use the GNU compiler collection (GCC) that you can download for free – see the below Open Source link below for the AIX Toolkit.

Note however, that from one day of testing and about 2 year ago – so your milage might vary from mine – I found that the IBM compilers are different

  1. They generate more efficient code roughly 20% to 30% faster – I guess the IBMers really do know the POWER CPUs very well.
  2. They are a little fussy and complain about ambiguous statements in your code (probably says more about my code!)

For many Open Source tools and applications, the GNU compilers are assumed and should compile first time on AIX with the same compiler. If you don’t need the last word in performance then it can be simpler to use the GNU compilers and tool chain. If, however, performance is important then the extra cost and work of using the IBM compilers is worth the effort.

Precompiled Downloads of the GNU Compiler Collection (GCC)

GCC/G++ Bundles for AIX 5.2 and 5.3 from pWare – http://pware.hvcc.edu

  • This bundle  as gzip tarball of BFF files is the 4.2.3 version of C/C++/ObjC/Java/Fortran compilers for AIX 5.2 and has no other fileset requirements (Built with gcc 4.2.3).
  • This bundle  as gzip tarball of BFF files is the 4.2.4 version of C/C++/ObjC/Java/Fortran compilers for AIX 5.2 and has no other fileset requirements (Built with gcc 4.2.3).
  • This bundle  as gzip tarball of BFF files is the 4.2.3 version of C/C++/ObjC/Java/Fortran compilers for AIX 5.3 and has no other fileset requirements (Built with gcc 4.2.3).
  • This bundle  as gzip tarball of BFF files is the 4.2.4 version of C/C++/ObjC/Java/Fortran compilers for AIX 5.3 and has no other fileset requirements (Built with gcc 4.2.3).

AIX RPM install images from Michael Perzl – http://www.perzl.org/aix

The Apache web server and AIX

Apache has to be the prime example of Open Source success – it basically runs the WWW and it also runs very well on AIX. Fully marks to all the developers of this winning project. Further information can be found at the Apache home website at http://www.apache.org/

But where to get Apache for AIX from:

  • If you want Apache 1.3 this is available from the AIX Toolbox for Linux Applications (see above) or Bull website
  • It is also available from IBM and packaged with extra features for performance. It is then called HTTPServer and this is the basis for IBM Websphere. You can download this fromhttp://www.ibm.com/software/webservers/httpservers/ for free. this version has the IBM Fast Response Cache Accelerator (FRCA) – where the AIX kernel responds to simple cached requests without the context switch to the Apache process.
  • If you want Apache 2.0 then you have a limited choice
    • you can download the IBM HTTPServer version from http://www.ibm.com/software/webservers/httpservers/ where the v2.0 and v6.0 version appear to both have Apache 2.0.47 – the difference is not clear. I guess version 6 might include the FRCA but its not clear.
  • If you want the latest stable release or particular features compiled in or make use of particular Apache modules then you have to recompile Apache for AIX yourself (see below) or use the AMP bundle provided at the pWare site.

Precompiled Downloads of Apache

AIX RPM install images from Michael Perzl – http://www.perzl.org/aix

AMP (Apache/MySQL/PHP) Bundle available from pWare – http://pware.hvcc.edu

    • The link is not valid. The bundle is not available.
  • This bundle  as a BFF tarball is Apache 2.2.8, MySQL 5.0.51b and PHP 5.2.6 hardened with the Suhosin patch and extension. All of these were compiled on AIX 5.2 with the GCC 4.2.3 compiler also available from the pWare site. This bundle is intended to run on AIX 5.2
  • This bundle  as a BFF tarball is Apache 2.2.10, MySQL 5.0.67 and PHP 5.2.6 hardened with the Suhosin patch and extension. All of these were compiled on AIX 5.3 with the GCC 4.2.3 compiler also available from the pWare site. This bundle is intended to run on AIX 5.3 & 6.1.
  • Notes:
    1. These bundles provide BDB, Oracle, MySQL and MSSQL access through PHP as well as XML, LDAP, FTP, FreeType, PDO and ODBC support.
    2. You no longer need to install bos.compat.termcap for the PHP fileset to install.
    3. Once installed you will need to configure the httpd.conf file(s) for use at your site. All software installs to /opt/pware and is managed by installp. The directory structure should be fairly intuitive.

Compiling Apache2+ on AIX using the GNU GCC compiler – By Example for Apache 2.2.2 and 2.2.4

This was performed on AIX 5.3 ML 03 – a simple default AIX install with no extras and no IBM compilers installed. It is also assumed the machine is on your network. It was quiet simple and straight forward using the latest GNU compiler and Apache source code but I did had problems using older compiler versions. Below are my notes on how to do this, step by step and where to download the tools and source code. I hope this will save you time.

  1. Make sure you have a few hundred MB of free space in following places
    • /usr this is where by default Apache will be installed
    • the directory you will use for compiling Apache
    • and some space in /tmp never does any harm!
  2. Download the following:
  3. Install libm.a from the AIX CDROMs – this is the maths library
    • As the root user
    • Insert the AIX 5.3 installation CDROM 1 into the CD and use “smitty installp” to load this package.
    • I assume you can do this without further help.
  4. Install the compiler and library – as the root user
    rpm -Uvh gcc-4*.rpm
    rpm -Uvh libgcc-4*rpm
  5. Uncompress the Apache Web Server source and untar the files in to a directory read for compiling
    gunzip httpd-2*tar.gz
    tar xvf httpd-2*.tar
    • You should now find a sub-directory with the name of httpd plus the version number. In my case it was “httpd-2.2.2”
    • cd to this directory
    • If you downloaded the httpd-2.2.2.tar.bz2 file, use bunzip2 to uncompress the file – not obvious unless you know!
  6. Prepare for the complication using the configure script, by typing the command (as a regular AIX user):
    ./configure -C --enable-so --prefix /usr/local/apache2
    • Here we request:
      • the checks are cached (-C) to save time,
      • dynamic library support (for example used by PHP which is a .so extension) and
      • the install directly will be /usr/local/apache2
    • Some people prefer to install into /opt/feeeware/apache2 but let us stick to the defaults to make it simpler. You can always try something different later on once you know it all works.
    • ./configure –help – will show you the hundreds of options.
    • Configure can take a long time – like 15 minutes (go for a cup of tea)
    • For Apache 2.2.4 add a further option as below:
      ./configure -C --enable-so --prefix /usr/local/apache2 --with-included-apr
    • Note that if you are compiling in an AIX 6.1 environment and intend to build PHP then you should omit
      --with-included-apr

      because you will get errors when attempting to start Apache. Apache will report missing symbols when loading the library libphp5.so. See point 10.

  7. Compile Apache2 by typing (as a regular AIX user):
    make
    • Note that you can use either AIX make or GNU make.
  8. Install Apache2 – all the important stuff will be in /usr/local/apache2. Type as the root user:
    make install
  9. If it all goes wrong, you can run “make clean” to start again from point 6.
  10. One method of solving the problems associated with included-apr is to download the APR and APR-utils from the Apache website and configure and make both packages. You can then rerun the Apache configure command as follows (for example):
    ./configure -C --enable-so --prefix=/usr/local/apache2 \
    --with-apr=/opt/freeware \
    --with-apr-util=/opt/freeware \

Configuring Apache2+ on AIX – By Example

Assuming you have just compiled and installed Apache2+ as in the above section, this is what I do to configure Apache:

  1. You will need to configure Apache before you start it
    vi /usr/local/apache2/conf/httpd.conf
    • Find the line that looks like this
      DocumentRoot "/usr/local/apache2/htdocs"
    • This is the top level directory for your web pages – you need to know this or you can’t add pages!!
  2. Test the Apache2 configuration
    /usr/local/apache2/bin/apachectl -t
    • I had an error “httpd: bad group name daemon”.
      • To fix this I changed /usr/local/apache2/conf/httpd.conf and the line “User daemon” to “User nobody” and the line “Group daemon” to “Group nobody”. This uses the standard UNIX/AIX user called “nobody”. An alternative would be to create a UNIX user and UNIX group both called daemon.
  3. Start Apache2
    /usr/local/apache2/bin/apachectl -k start
    • Other useful commands are “stop” and “restart”
  4. You can now test the webserver as the default web files directory has a simple web page pre-installed. If necessary, copy these web pages to your new web files directory. Point your browser at http:/<your-machine> and you should be informed that it is working.
    • Below we assume you will use default /usr/local/apache2/htdocs for some quick testing and will set up the alternative filesystem later on but don’t forget.

Configuring Apache2+ on AIX – For Production Use

Note: the default web pages directory is /usr/local/apache2/htdocs. This is not a good idea as you risk filling up the /usr filesystem. this is what I recommend as a minimum of changes to the default Apache configuration:

  • It is normal to place the webpages and the log (error and access) files are in seperate filesystems for
    • Simpler security,
    • Making sure that / or /usr do not get 100% full
    • Generally easier space management and backups
  • The same applies for Apache log and Apache error files
  • In the configuration file you would then have to find and change at least the following lines
    DocumentRoot "/usr/local/apache2/htdocs"
    ...
    <Directory "/usr/local/apache2/htdocs">
    ...
    CustomLog logs/access_log common
    ...
    ErrorLog logs/error_log
  • You should switch of any Apache features that you know you do not need to improve security.

Below we assume you will use default /usr/local/apache2/htdocs for some quick testing and will set up the alternative filesystem later on but don’t forget.

MySQL: Open Source Database

MySQL is a widely-used database. It can be used in conjunction with Apache and PHP (see below) to provide web access to databases. For more information, see thehttp://www.mysql.com

Compiling MySQL on AIX using the GNU GCC and GCC++ Compilers – By Example

The compile requires the mysql file as well as the gcc, gccplusplus compilers and associated libraries. I compiled on AIX 5.3 ML5, and stored in in the default /usr/local directory.

  1. Log in as root
  2. Make sure you have sufficient free space in /opt and /tmp (60MB+)
    **I recommend you create a /usr/local filesystem (700MB for Apache + Mysql + PHP). A separate filesystem prevents logs from filling /usr.
  3. 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 rpmname
    • 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.)
  4. Create MySQL UserID and Group
    • mkuser mysql
    • mkgroup -A mysql
  5. 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
  6. Link Directory to /usr/local/mysql
    • ln -s mysql-standard-5.0.27-aix5.2-powerpc /usr/local/mysql
  7. 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 &
  8. Validate MySQL Installation by Logging into Database
    • mysql -u root
    • >use mysql;
    • >show tables;
    • >exit;
  9. 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

PHP: Hypertext Preprocessor and AIX – 5.1.4 and 5.2.1

Many websites use the excellent PHP extension package to add web features and dynamic content. PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. PHP stands for PHP: Hypertext Preprocessor. Further details of this most excellent project go to the PHP home website at http://www.php.net.

You can down load the PHP version 4.0 from the AIX Toolbox for Linux Applications website. This assumes your downloaded web server was compiled to support PHP and shared objects and I found that many do not support it – which is really annoying!! But if you need the SSL and XML optional features and want the latest PHP version (at the time of writing this is 5.1.4) then you will have to compile it yourself. Below are the datails on how to do this.

Compiling PHP on AIX using the GNU GCC compiler – By Example

This was performed on AIX 5.3 ML 03 – a simple default AIX install with no extras and no IBM compilers installed. It is also assumed the machine is on your network. It is straight forward using the GNU compiler and PHP source code. This “by example” assumes you have just completed the compiling of Apache2+ (see above sections) and so have the GNU C 4.0 compiler available.

  1. Make sure you have a few tens MB of free space in the following directories:
    • /usr the default place for (or where ever you want to install PHP),
    • /opt where many of the pre-requisite libraries are installed and
    • in the directory you use for the compile,
    • some space in /tmp never hurts too.
  2. Download the following:
    • From PHP 5.1 source code
      • From http://www.php.net/downloads.php
      • For me the file was called php-5.1.4.tar.gz but you might fine a later version still. I have since compiled 5.2.1. Version 5.3.1 is currently available.
    • XML Support – this should be 2.6.21 or later depending on which version of PHP you are building. The AIX Toolbox for Linux Application site is back level
  1. #* General tools – all from http://www.ibm.com/servers/aix/products/aixos/linux/download.html
      1. LEX flex-2.5
      2. XML support expat-1.95.7
      3. Compression library zlib-1.2.2
      4. Compression develoment zlib-devel-1.2.2
      5. Compression library bz2-1.0.2-3
      6. jpeg support libjpeg-6b-6
      7. jpeg support development libjpeg-devel-6b-6
      8. png support libpng-1.2.1-6
      9. png development libpng-devel-1.2.1-6
      10. Pixmap xpm-3.4k
      11. Pixmap development xpm-devel-3.4k
      12. Freetype2 fonts freetype2-2.1.7-2
      13. Freetype2 fonts development freetype2-devel-2.1.7-2
    • Install all the RPM files – if they are in one directory use: rpm -Uvh *.rpm
    • For PHP 5.2.1, I found I also needed the GNU C++ compiler – all from http://www.ibm.com/servers/aix/products/aixos/linux/download.html
      1. gcc-cplusplus-4.0.0-1.aix5.3.ppc.rpm
      2. libstdcplusplus-4.0.0-1.aix5.3.ppc.rpm
      3. libstdcplusplus-devel-4.0.0-1.aix5.3.ppc.rpm
    • Assuming you have all the above in place, you can start on PHP itself
  2. Not quite. If you are building PHP 5.3.1 (and possibly earlier versions) in an AIX 6.1 environment then there are a few more steps.
    • Download and install the gnu make RPM from the AIX Linux Toolbox. By default, make will be installed in /opt/freeware/bin. You will need this to build PHP.
    • Download the source code for libxml2 as mentioned above. I used 2.6.30. Earlier versions do not seem to support shared libraries and I was not able to build later versions (2.7.X). Building the libraries required several tricks.
      • I needed to edit the configure script to recognise AIX 6.1
        cp configure configure.dist
        cat configure.dist | sed -e "s/aix5\*/aix5* |  aix6*/" > configure
        ./configure --prefix=/opt/freeware \
        --without-threads \
        --host=powerpc-ibm-aix6.1.4.0
        make
        make install
      • Note that this seemed to work better using AIX make instead of GNU make.
  3. Uncompress the PHP source code file and untar the files
    gunzip php*tar.gz
    tar xvf php*.tar
    • You should now find a sub-directory with the name of php plus the version number. For example “php-5.1.4” or “php-5.3.1”.
    • cd to this directory
    • If you downloaded the php-5.1.4.tar.bz2 file, use bunzip2 to uncompress the file – not obvious unless you know!
  4. If you are compiling PHP 5.3.1 on AIX 6.1 the configure script does not recognise AIX6. Edit configure
    cp configure configure.dist
    cat configure.dist | sed -e "s/aix5\*/aix5* |  aix6*/" > configure
  5. Prepare for the compilation using the configure script, by typing the following two commands (the first picks up the new utilities you installed above, the second seems long winded but refers to the directories to find the newly install libraries):
    export PATH=/opt/freeware/bin:$PATH
    # all the following lines of text are on one line (split here as the web server gets confused!)
    ./configure --prefix=/usr/local
    --with-apxs2=/usr/local/apache2/bin/apxs
    --with-config-file-path=/usr/local/apache2/conf
    --with-gd
    --with-zlib-dir=/opt/freeware/lib
    --enable-shared --disable-static
    --with-png
    --with-zlib
    --with-bz2
    --with-xml
    --with-jpeg-dir=/opt/freeware/lib
    --with-png-dir=/opt/freeware/lib
    --with-xpm-dir=/opt/freeware/lib
    --with-freetype-dir=/opt/freeware/lib
    --with-mysql=/usr/local/mysql
    • Here we detail the Apache dynamic library support (apxs) file, shared libraries and various options needs for most new webservers, zlib and bz2 for compression, jpeg and png for images, XML support.
    • Note that in PHP 5.3.1, the options –with-png and –with-xml are deprecated and you get a non-fatal warning. The workaround is to use –with-png-dir= and –with-xml-dir= pointing to the appropriate directories.
    • Note that when compiling 5.3.1 on AIX 6.1 running configure with the options above will fail because shared libraries are reported as not supported! The solution that I used was to add the option
      --host=powerpc-ibm-aix6.1.4.0
    • Some people prefer to install into /opt/feeeware/apache2 – the AIX normal place for open source applications. In this example, we will use the default directory of /usr/local/apache2 to make it simple. You can always recompile later, once you know the compile will work.
    • ./configure –help – will show you the dozens of options.
    • Configure can take a long time – like 10 minutes (go for a cup of tea).
    • Comment on the last line i.e. the MySQL option
      • If you only want Apache and PHP then you don’t need this last line – simply remove it.
      • If you want PHP to be able to connect to a MySQL database and have the MySQL installed and at /usr/local/mysql – then leave it in.
  6. If you are compiling PHP 5.3.1 on AIX 6.1 and run make at this point then it will fail with a message about duplicate symbols. This problem seems to be known in the PHP bug database. My solution to to this was to edit the file
    ./main/php_config.h and change
    #define HAVE_ARPA_NAMESER_COMPAT_H 1
    to
    #define HAVE_ARPA_NAMESER_COMPAT_H 0
  7. Compile PHP
    make
    • There will be compiler warnings about pointers type mismatches. As these were warning, I ignored them.
    • Make sure that you use GNU make. Otherwise your compilations may fail with an error message:
      Generating phar.php
      /bin/sh[14]: -d:  not found
    • If the compile fails with a vague “out of memory” error message, try increasing ulimit.
  8. Install PHP with the following two commands
    cp .libs/libphp5.so /usr/local/apache2/modules
    cp php.ini-recommended /usr/local/apache2/conf/php.ini

Configuring PHP with Apache2 on AIX – By Example

Assuming you have just installed Apache2+ (and it is working OK) and have just installed PHP as in the above section then this is what you need to configure PHP to work.

  1. Stop Apache2 with: /usr/local/apache2/bin/apachectl -k stop
    • Do not forget this – if you add the PHP configuration options before stoping Apache you will not be able to stop it cleanly and will have to kill it!
  2. You will need to configure PHP into Apache2 before you use it
    • Apache2 currectly does not understand that PHP is an option and what to do with .php files
    • In the /usr/local/apache2/conf/httpd.conf file, add the following at the end (or you can add them after similar lines in the file to keep it neat). These will let Apache know about 1) the PHP library, 2) that it should pass web server files ending with .php to PHP for processing and generating dynamic HTML and 3) that is the URL does not contain a file name (only a directory) and it finds a index.php file then it should by default open that file just like it does for index.html files.
      LoadModule php5_module modules/libphp5.so
      AddType application/x-httpd-php .php
      DirectoryIndex index.php
    • Advanced Apache Administrators may have other approaches and config file setups but the above will get you started.
    • Edit the /usr/local/apache2/conf/php.ini file and change the line
      ;date.timezone =
    • to
      date.timezone = "Europe/London"
    • or what ever time zone you are in. This helps applications that get confused when working out the Timezone in other ways.
  3. Restart Apache2 with: /usr/local/apache2/bin/apachectl -k start
  4. Now test PHP with Apache2
    • Create a file in the web server files directory (default /usr/local/apache2/htdocs) called testing.php as the following two lines:
      <h1> PHP testing </h1>
      <?PHP phpinfo() ?>
    • Make this file readable by everyone with: chmod 755 testing.php
    • Make it owned by nobody with: chown nobody:nobody testing.php
    • Now use you browser to access the file with a URL of http:<you-machine>/testing.php
      • You should see a lot of PHP information – this is everything that is available to the PHP script writers and can be useful in debuging some problems.

Once compiled moving Apache2+PHP to an new/production machine

This is relatively simple but hopefully these notes will save you time. First, backup the Apache2.2 and PHP files that by default are in the /usr/local/apache2 directory (assuming space for this in /tmp, its about 45MB):

cd /usr/local/apache2
tar cvf /tmp/apache2.tar

Second, copy or FTP this to the new machine here we assume the file is in /tmp and install them with

mkdir -p /usr/local/apache2
cd /usr/local/apache2
tar xvf /tmp/apache2.tar .

Third, you need only the supporting run time libraries and it is best not to copy these but to install them from the original RPM files (as we did for compiling but you only need a subset of the libraries). The list of RPM is below and where to get them:

  • XML Library Support – this has to be the one that you used when building PHP. If you used the source code Method on the source machine then you will need to copy the source code to the destination machine and rebuilt and reinstall. (Alternatively, if you know how to create RPM packages, you could do this on the source machine and copy the package to the destination).
    1. File libxml2 2.6.2X (find and use the rpm link)
  • General Libraries – all from http://www.ibm.com/servers/aix/products/aixos/linux/download.html
    1. jpeg support libjpeg-6b-6
    2. png support libpng-1.2.1-6
    3. Pixmap xpm-3.4k
    4. Freetype2 fonts freetype2-2.1.7-2
    5. libgcc 4.0 make it the library for AIX 5.3

Now, you should find your apache web server ready to test and run

/usr/local/apache2/bin/apachectl -t
/usr/local/apache2/bin/apachectl -k start

Samba on AIX

Samba has been working quite well on AIX for quite some time, and allows AIX to integrate into a Windows Domain (with ADS).
It can be a complete domain member server, and authentication can be performed by the DC’s in a windows AD domain or other kerberos/ldap servers.

The possibilities are almost endless, and the documentation for samba on Unix is quite plentiful.

The Samba website has a number of resources that can be used.
The Official Samba-3 HOWTO and Reference Guide is particularly recommended.

Install Pre-Compiled AIX binaries

You can find pre-compiled binaries for AIX on the official Samba site.
At the time of writing the current stable release of samba for AIX is 3.0.24
You will also need the “base” files for Samba. These certain “support” binaries and libraries that are either not included in AIX, or are at different levels than the ones included with AIX. These mostly consist of LDAP and Kerberos binaries and libraries that samba uses for Microsoft Windows Active Directory integration.
The current samba base files can be found here.
Both of these install into /opt/pware so not to affect other (OS or application) files on the system. These are the particular ones that the version of Samba has been compiled against.

The README file contains all basic information required on how to install this on AIX.

Configuring Samba to be src controlled.

To use SRC (System Resource Controller) to stop and start samba you need to run something like this:

/usr/bin/mkssys -s nmbd -p /opt/pware/samba/3.0.24/sbin/nmbd -a '-F -s /opt/pware/samba/3.0.24/lib/smb.conf' -u 0 -S -n 15 -f 9 -R -G samba
/usr/bin/mkssys -s smbd -p /opt/pware/samba/3.0.24/sbin/smbd -a '-F -s /opt/pware/samba/3.0.24/lib/smb.conf' -u 0 -S -n 15 -f 9 -R -G samba

Take notice that by using the “-F” switch with samba you tell it to not daemonize, and let startsrc/stopsrc control it fully.
When this is done you should be able to start/stop Samba with:

startsrc -g samba
stopsrc -g samba

Building a Linux-hosted AIX crosscompiler

While precompiled gcc packages for AIX are available, you might not be allowed to install a development environment on a system due to various policies. But you may still want to compile some tools which you would like to run on your AIX box, for example for debugging or research purposes. In that case, an AIX crosscompiler running on an i686 or x86_64 based Linux system comes in handy to build your binaries there and just copy them over to the AIX box for execution.

While GCC supports powerpc-ibm-aix5.3.0.0 as a target, building such a cross-compiler isn’t as easy and straightforward as it sounds in the first place. Nevertheless, it can be done.

AIX is not GNU/Linux

Every toolchain is specific with regards to:

  • the CPU (the instruction set, to be precise) for which code gets compiled
  • the kernel on which the code is supposed to run
  • the C library used

When people speak or write about cross-compilers, they very often mean compilers where only the CPU is different between host and target. This happens a lot with embedded systems. When developing code for an embedded Linux system this usually isn’t an Intel compatible PC platform, but quite frequently some ARM, MIPS or whatever CPU with an incompatible instruction set. But the target platform still runs a Linux kernel and uses a GNU C library.

When cross-compiling for a RISC based AIX machine on a PC based Linux box, in comparison, you are dealing with all: A different CPU instruction set, a different kernel and a different C library. This increases complexity quite a bit and renders some readily available HOWTOs on the web which assume that “different CPU instruction set but still GNU/Linux” pattern next to useless, unfortunately.

Please also note that there is no port of the GNU C library to AIX available. Even with GCC, you will need to use the AIX platform C library. Not that it might not be possible to port the GNU C library to AIX, but it just hasn’t been done. (Feel free!) This also implied that whatever software you intend to build for AIX using your cross-toolchain will have to be portable enough to work on AIX or should explicitly support AIX as a target platform. Fortunately, a lot of the common OSS does.

You need the AIX headers and libs on your Linux box

Building your cross-toolchain: Step by Step Howto

The GCC build process will need the cross-binutils in order to build itself. Your existing binutils will not work. (Though I haven’t understood yet why, maybe someone can fill that in.)

Therefore you should optain, build and install binutils into a separate directory tree. In the next step, your GCC configure script will pick them up from there and use them.

Dell Server 2.4 Opteron 4GB 2×500 NetBSD

640px-Servidor

 

Dell Server 2.4 Opteron 4GB 2×500 NetBSD

 

 

Apache PHP Mysql HP-UX

HP-UX specific installation notes

This section contains notes and hints specific to installing PHP on HP-UX systems.

There are two main options for installing PHP on HP-UX systems. Either compile it, or install a pre-compiled binary.

Official pre-compiled packages are located here: » http://software.hp.com/

Until this manual section is rewritten, the documentation about compiling PHP (and related extensions) on HP-UX systems has been removed. For now, consider reading the following external resource: » Building Apache and PHP on HP-UX 11.11

HP-UX specific installation Notes

Installing PHP 5.x with Apache 2.x on HP UX 11i and configuring
PHP 5.x with Oracle 9i
I am very glad to share this information to configure PHP 5.x work
with Apache 2.x and Oracle 9i on HP UX 11i.

Step 1: Install Apache 2.x with DSO support:
——————————————–

This is a stratight forward Apache installation with
–enable-so option

gzip -d httpd-2_0_NN.tar.gz
tar xvf httpd-2_0_NN.tar
cd httpd-2_0_NN

./configure \
–prefix=/var/apps/apache2 \
–enable-so \
–enable-mods-shared=most \
–libexecdir=/var/apps/apache2/libexec

You can add other options as required.

make

make install

Step 2: Install and configure PHP 5.x with Oracle 9i
—————————————————-

Edit the ./configure file to change “$OCI8_DIR/lib” as “$OCI8_DIR/lib32”

By default, with Oracle 9i, “$OCI8_DIR/lib” will be poiting to
Oracle 64 bit libraries in “$OCI8_DIR/lib64″ directory.
Unfortunately, PHP 5.x does not work with 64 bit oracle shared libraries.

Run configure..

$ ./configure \
–prefix=/var/apps/php \
–with-apxs2=/var/apps/apache2/bin/apxs \
–with-oci8=/oracle/app/product/9.0.2 \
–disable-libxml \
–enable-libgcc \
–enable-ftp \
–enable-calendar \
–enable-track-vars \
–enable-trans-sid \
–enable-sigchild \
–libexecdir=/var/apps/apache2/libexec \
–with-config-file-path=/var/apps/apache2/conf

–enable-libgcc \
–enable-sigchild \

You can add other options as required. You can use the –help
option to configure to get a complete list.

After configure runs, you must edit the file libtool.

$ vi ./libtool

At line 184, you should change the line from:

deplibs_check_method=”unknown”
to
deplibs_check_method=”pass_all”

so that PHP and mod_php are properly compiled.

3. Compile and install the files.

Run make. This should complete normally.

$ make

Run make install. This will fail when it attempts to call apxs.

$ make install

Step 3: Configure Apache 2.x
—————————-

Edit httpd.conf file to include

For PHP 5:

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php .phtml

Set environment variables in $APACHE_ROOT/bin/envvars file

SHLIB_PATH=”/var/apps/apache2/lib:$SHLIB_PATH”
export SHLIB_PATH

LD_LIBRARY_PATH=$ORACLE_HOME/app/product/9.0.2
/lib32
export LD_LIBRARY_PATH

LD_PRELOAD=/usr/lib/libpthread.sl:$ORACLE_HOME/app/
product/9.0.2/JRE/lib/PA_RISC/native_threads/libjava.sl
export LD_PRELOAD

After lot of hard work, by following the above procedure,
we were able to make PHP 5.x is work with Apache 2.x
and Oracle 9i on HP UX 11i OS.

 

 

 

Sun Ultra 5

640px-Sun_Ultra_5

My firts server, NetBSD on it.

NetBSD Wireless Network auto-detection scripts

NetBSD Wireless Network auto-detection scripts 

The configuration:

  1. /etc/rc.conf:
    apmd=yes
    wpa_supplicant=yes
    wpa_supplicant_flags="-B -iath0 -c/root/wpa.conf"
    ifwatchd=yes
    ifwatchd_flags="-c /root/ifwatch-up -n /root/ifwatch-down tlp0 ath0"

     

  2. WPA supplicant config: /root/wpa.confHere’s a sample config file for wpa_supplicant(8) that I use for University, home and another place. Note that the WPA in there is a bit more complex than in a home-setup with just a pre-shared key (PSK):
    % cat /root/wpa.conf
    ctrl_interface=/var/run/wpa_supplicant
    ctrl_interface_group=wheel
    
    #
    # WPA-enabled network with identities 
    # (used at uni-regensburg.de and fh-regensburg.de)
    #
    network={
            ssid="802.11i"
            key_mgmt=WPA-EAP
            eap=TTLS
            identity="abc12345"
            password="foobar"
            phase2="auth=PAP"
    }
    
    #
    # An unencrypted (open) network:
    #
    network={
            ssid="eyeswideshut"
            scan_ssid=1
            key_mgmt=NONE
    }
    
    #
    # A WEP-encrypted network with pre-shared key:
    #
    network={
           ssid="wepssid"
           scan_ssid=1
           key_mgmt=NONE
           wep_key0="wepkey"
           #wep_tx_keyidx=0
           #priority=5
    }

     

  3. Watching interfaces: /root/ifwatch-updownifwatchd(8) can’t pass parameters, so I’m using two different scripts, and then look at $0 to see if we’re going up or down:

     

    % ls -la /root/ifwatch-*
    lrwxr-xr-x  1 root  wheel   14 Mar 10 12:27 /root/ifwatch-down -> ifwatch-updown
    lrwxr-xr-x  1 root  wheel   14 Mar 10 12:27 /root/ifwatch-up -> ifwatch-updown
    -rwxr-xr-x  1 root  wheel  760 Aug 16 11:45 /root/ifwatch-updown

    Here is the script that handles ethernet and wifi networks going up and down: 

    % cat /root/ifwatch-updown
    #!/bin/sh
    #
    # See if network is going up or down, to be called via ifwatchd(8)
    #
    # Copyright (c) 2007 Hubert Feyrer <hubert@feyrer.de>
    # All rights reserved.
    #
    
    case $0 in
    *-up)
            case $1 in
            tlp*)
                    # Disable wireless bouncing up and down if we're on wire
                    #
                    logger stopping wpa_supplicant
                    sh /etc/rc.d/wpa_supplicant stop
                    ;;
            esac
    
            pkill dhclient
            sh /etc/rc.d/network restart
            dhclient $1
            sh /etc/rc.d/ntpd restart
            ;;
    
    *-down)
            case $1 in
            tlp*)
                    # Re-enable wireless if we go off-wire
                    #
                    logger starting wpa_supplicant
                    sh /etc/rc.d/wpa_supplicant start
                    ;;
            esac
    
            pkill -x ssh
            sh /etc/rc.d/ntpd stop
    
            pkill dhclient
    
            sh /etc/rc.d/network stop
            route delete 194.95.108.0/24
            ;;
    
    *)
            logger "$0 $@": unknown 
            ;;
    esac
    
    logger "$0 $@" done.
    echo ^G >/dev/console

    A few comments:

    • As the comment says, if the ethernet interface (tlp) is found to be connected, wpa_supplicant(8) is stopped to prevent it from bouncing up and down and possibly disrupt things.
    • I stop the network at every time, to flush routes and everything. This mostly works, but not completely, thus I remove one route manually. Someone please fix “route flush”…
    • I use NTP, and to prevent ntpd(8) from spamming the logs when offline, I disable it when offline.
    • When network goes away, I kill my ssh sessions. I prefer this over dead sessions that I have to kill with ~.
    • The echo-command in the last line sends a beep with ^G to give a signal that network’s up/down now.

     

  4. APM setup:During my experiments, wpa_supplicant(8) died during suspend/resume, I thus stop it before suspending, and start after resuming. This may also have positive effects on power consumption (if not it should probably be hooked in here). My machine uses APM, and I mostly use /usr/share/examples/apm/script, see that file for install instructions.

    Here’s the diff that I use to handle wpa_supplicant – dhclient is restarted via ifwatchd:

     

    % diff -u /usr/share/examples/apm/script /etc/apm/battery
    --- /usr/share/examples/apm/script      2003-03-11 15:56:54.000000000 +0100
    +++ /etc/apm/battery    2007-03-10 12:57:21.000000000 +0100
    @@ -25,7 +25,7 @@
     S=/usr/X11R6/share/kde/sounds
    
     # What my network card's recognized as:
    -if=ne0
    +if=ath0
    
     LOGGER='logger -t apm'
    
    @@ -43,8 +43,11 @@
            # In case some NFS mounts still exist - we don't want them to hang:
            umount -a    -t nfs
            umount -a -f -t nfs
    -       ifconfig $if down
    -       sh /etc/rc.d/dhclient stop
    +
    +       sh /etc/rc.d/wpa_supplicant stop
    +
    +       cd /usr/tmp ; make off
    +
            $LOGGER 'Suspending done.'
            ;;
    
    @@ -62,7 +65,9 @@
     *resume)
            $LOGGER 'Resuming...'
            noise $S/KDE_Startup.wav
    -       sh /etc/rc.d/dhclient start
    +
    +       sh /etc/rc.d/wpa_supplicant start
    +
            # mount /home
            # mount /data
            $LOGGER 'Resuming done.'

    The “make off” when shutting down the machine unmounts the cgf-encrypted data partition that I’m using for SSH and PGP keys. I manually mount it when I need it again.

     

With these four steps — rc.conf, wpa.conf, ifwatch-script, and APM script — things should be in place to auto-detect cable and wifi networks, and get things online.

The future — more work on this would include adding ACPI/powerd(8) scripts, and putting all of this either into the default NetBSD install, or at least into NetBSD’s /usr/share/examples.