• Articles / Artículos
  • Contact / Contacto
CODEANDO : our blog about technology

Setup guide for Apache, PHP and MySQL on QNX 6.5 (NEW)

1/6/2016

0 Comments

 

​Requirements

This article describes the steps required to install Apache 2.2, PHP 5.3 and MySQL 5 on QNX 6.5 for i386 platform. 
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 ​
These packages are part of pkgsrc under BSD License.
​

Create Groups and Users for MySQL & Apache 

​First of all, we need to create two new groups and users in QNX, one for MySQL and one for Apache: Before you begin, start photon if necessary and login as root.
Click the "Users" button under the "Configure" menu on the right side menu (shelf). 

Picture
Now press the "Advanced" button
​
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

Open Network Settings (Under "Configure" on the right side menu) to setup the network. 
Picture
Network settings must be in MANUAL MODE.
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.

Once the network is configured in manual mode, add your hostname to /etc/hosts.
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. 
Picture
​NOTE: To test that hosts was correctly configured, you can open a terminal window and type "ping qamp1" (where qamp1 is your hostname). The QNX server should respond from the ip address that your entered in your hosts file.
​

Setup QNX Environment

​We need to setup PATH and CS_LIBPATH in /etc/profile and /etc/rc.d/rc.local.
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

Download all the packages required (See the "Requirements" section of this document for the download link) into a directory in your QNX server, and install them as follows.
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

To prepare Apache and MySQL to start automatically when QNX boots run the following commands:
​
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

Edit apache config file according to the Apache help descriptions. In order to do this, open the file /usr/pkg/etc/httpd/httpd.conf using Text Editor and change:​
​
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

Run the following commands to prepare 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.
​
The installation is finished. You can reboot your QNX server. Apache and MySQL will start automatically when system boots.​
​
Check this post if you an example of how to connect to MySQL from a C program.

​Start / Stop Apache and MySQL Manually

If you need to start apache manually, run:
. /etc/rc.d/apache start
​To stop apache, run:
. /etc/rc.d/apache stop
To start MySQL manually, type:
. /etc/rc.d/mysqld &
To kill MySQL manually, type:
slay mysqld
This post is published by the developer's team at INNVAS SRL. If you have any comments, suggestions or requests, please feel free To contact us. Thanks for stopping by!

0 Comments



Leave a Reply.

    Picture

    Authors

    We are the development team at INNVAS SRL, a nice group of engineers and IT specialists with solid experience in software development on different platforms, most of them custom developments, for different areas and industries. Our experience includes real time systems (automation and control), SCADA systems, drivers and protocols, GIS, image processing, simulation and optimization, web portals, mobile applications, embedded solutions, among others. 
    We enjoy working on different hardware and software platforms (Windows, Linux, QNX, Android, iOS , Raspberry Pi) and technologies (.NET, Java, HTML5,  C / C ++, Python, Matlab, CUDA, among others).

    Categories

    All
    Apache
    Linux
    MySQL
    Netbios
    Networking
    OpenTSDB
    PHP
    QNX
    Raspberry Pi
    Samba
    Ubuntu

    Archives

    July 2016
    June 2016
    May 2013

    Ads

    Consulting

    Picture
    Need support in QNX ?

    Apache on QNX
    Open SSL on QNX
    MySQL on QNX
    PHP 5 on QNX
    Open LDAP on QNX

    Contact us at:


    INNVAS SRL
    Montevideo
    Uruguay
    ​www.innvas.com
    info@innvas.com


    QNX is a trademark of
    ​QNX Software Systems
Powered by Create your own unique website with customizable templates.