Requirements
The following packages are required for installation:
- ap22-php53-5.3.8nb1
- apache-2.2.19
- apr-1.4.5
- apr-util-1.3.12nb1
- bootstrap
- expat-2.0.1nb2
- libiconv-1.14
- libxml2-2.7.8nb3
- mysql-client-5.1.58
- mysql-server-5.1.58
- perl-5.14.1
- php-5.3.8
- pkg_install-info-4.5nb3
- readline-6.2
- tcp_wrappers-7.6.1nb4
- xmlcatmgr-2.2nb1
- zlib-1.2.3
Create Groups and Users for MySQL & Apache
Click the "Users" button under the "Configure" menu on the right side menu (shelf).
Go to the "Groups" tab and click on "New Group", type mysql into "Group Name" and click Done.
Then click on "New Group" again to create another group and type www into "Group Name". Click "Done" to continue.
Now go to the "Users" tab and click on "New User", type mysql into Full Name, Login ID, home directory and select "mysql" as the group. Select the checkbox "Prevent this user from logging in." and the click "Done".
Now click on "New User" again to create the user for Apache. Type www into Full Name, Login ID, home directory and select "www" as the group. Select the checkbox "Prevent this user from logging in." and click "Done".
Click "Done" again to close the "Advanced" window and click "Done" to close the "Users" Window.
Setup Network
DHCP cannot be used for MySQL and Apache.
In the "Devices" tab, select "Manual" in the "Connection" combo box and enter the ip address and netmask that you have reserved for your QNX Server.
In our server they are:
IP: 10.0.2.15
Netmask 255.0.0.0
Now go to the "Network" tab and enter your host name for QNX Server, default gateway and name server.
In our server they are:
Host Name: qamp1
Default Gateway: 10.0.2.2
Name Servers: 10.0.2.2
Click "Done" when finished.
Important: DO NOT use localhost as the host name. You can use any host name EXCEPT localhost.
Open Text Editor (Under "Utilities" on the right side menu) and open the file /etc/hosts.
Add the following line, using your host name and ip address:
10.0.2.15 qamp1
Go to "File", click "Save" and close Text Editor.
Important: leave a blank line at the end of the file.
Setup QNX Environment
To setup these variables, open a Terminal Window (Under Utilities on the right side menu) and run the following commands:
echo "\nexport PATH=\$PATH:/usr/pkg/bin:usr/pkg/sbin" >> /etc/profile
echo "setconf CS_LIBPATH \$(getconf CS_LIBPATH):/usr/pkg/lib" >> /etc/rc.d/rc.local
Now REBOOT QNX to proceed.
Install Apache, PHP and MySQL packages
In our server, the download directory is /root/packages. You should replace this path with your own path when executing these commands.
Open a Terminal window (Under "Utilities" on the right side menu) and untar bootstrap.tar.gz under the root directory (/), using the following command:
tar -xzf /root/packages/bootstrap.tar.gz -C /
Now, cd to the root directory (/):
cd /
And run the following command to install Apache, PHP and MySQL:
pkg_add /root/packages/apache-2.2.19.tgz
pkg_add /root/packages/ap22-php53-5.3.8nb1.tgz
pkg_add /root/packages/mysql-server-5.1.58.tgz
Prepare Apache and MySQL to start automatically
cp /usr/pkg/share/examples/rc.d/apache /etc/rc.d/
echo "/etc/rc.d/apache start" >> /etc/rc.d/rc.local
cp /usr/pkg/share/examples/rc.d/mysqld /etc/rc.d
echo "/etc/rc.d/mysqld" >> /etc/rc.d/rc.local
Configure Apache and PHP
Listen 10.0.2.15:80 # <- CHANGE THIS LINE TO YOUR IP ADDRESS CONFIGURED BEFORE
ServerName 10.0.2.15 # (use your IP address) <- ADD THIS LINE IF IT DOES NOT EXIST
Also add the following lines to the appropriate sections to enable PHP 5 module:
In the "Dynamic Shared Object (DSO) Support" section add:
LoadModule php5_module lib/httpd/mod_php5.so
In the "AddHandler" section add:
AddHandler application/x-httpd-php .php
Finally verify the following values (they should already be set to these values):
ServerRoot "/usr/pkg"
User www
Group www
ServerAdmin you@example.com
DocumentRoot "/usr/pkg/share/httpd/htdocs"
Go to "File", click "Save" and close Text Editor.
Configure MySQL
mysql_install_db --user=root
chown -R mysql:mysql /var/ mysql
Finally, change the root password for mysql (use your desired password instead of 12345). In order to do this, first we need to start mysqld.
. /etc/rc.d/mysqld &
cd /usr/pkg/bin
./mysqladmin -u root -p password "12345"
./mysqladmin -h qamp1 -u root -p password "12345"
NOTE: When the system asks to "Enter password" it is asking for the current password. As there is no existing password, just press the Return (Enter) key.
Check this post if you an example of how to connect to MySQL from a C program.
Start / Stop Apache and MySQL Manually
. /etc/rc.d/apache start
. /etc/rc.d/apache stop
. /etc/rc.d/mysqld &
slay mysqld