Using i.MX as a webserver

Showing results for 
Search instead for 
Did you mean: 

Using i.MX as a webserver

Contributor I

What is a webserver

A web server is a computer program that delivers (serves) content, such as web pages, using the Hypertext Transfer Protocol (HTTP), over the World Wide Web

Why use on i.MX?

There are many reasons that you might want a web server running on an i.MX applications processor. This tutorial will instruct you how to build the neccessary packages with LTIB and configure the device to host a website.

Running a LAMP stack on i.MX

LAMP is an acronym for a solution stack of free, open source software, originally coined from the first letters of Linux (operating system), Apache HTTP Server, MySQL (database software), and PHP, principal components to build a viable general purpose web server.

Adding the LAMP packages to LTIB

Adding the packages to LTIB is very easy and should build fine without any issues.

  1. Simply reconfigure the BSP with LTIB to add the packages
    $ ./ltib -c 
  2. Now add the following packages to the BSP
  • httpd (Apache webserver)
  • mysql
  • php, python, or perl
Starting/Running the Web Server on your i.MX device

You simply to need to execute the binary "httpd". Typically, this is done when the system starts up, you can do this manually from the command line

$ /usr/sbin/httpd &

You can set up the system to do this automatically at start up in one of the rc files.I suggest starting httpd after most other services have started (i.e.: put it in rc.local).

Edit rc.local and add:

/usr/sbin/httpd &
Test your web server
  1. Find the ip address on your i.MX device
    $ ifconfig eth0      Link encap:Ethernet  HWaddr 00:22:19:06:b3:c1           inet addr:  Bcast:  Mask:           inet6 addr: fe80::222:19ff:fe06:b3c1/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:10228404 errors:0 dropped:0 overruns:0 frame:0           TX packets:3843568 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:3334983106 (3.3 GB)  TX bytes:3344815017 (3.3 GB)           Interrupt:17 
  2. Now open a browser and point to the ip address 


You should see the Apache welcome page

If you have any issues at this point, remove the proxy setting in your browser or add the i.MX ip address to your exceptions list
Configuring apache on i.MX

You can find an enormous amount of documentation for configuring Apache webserver on the Apache website" rel="nofollow
Here we will start with the very basic setup. If you want to point Apache to serve files located in /home/public_html/ then...

  1. On the i.MX target cd into the /user/conf directory
    $ cd /usr/conf 
  2. Edit httpd.conf
    $ vi httpd.conf 
  3. Change the following lines:
    - DocumentRoot "/usr/htdocs" to DocumentRoot "home/public_html"


    - <Directory "/usr/htdocs">  to <Directory "home/public_html">

Adding a secure socket layer (SSL)

  1. In ltib built kernel and fs with minimum configuration - no httpd and no openssl. So if the httpd package is selected then you must first remove it and then rebuild
  2. Edited httpd spec file to add "--enable-ssl" to configure arguments
  3. $ gedit dist/lfs-5.1/httpd/httpd.spec 
  4. Add link in /lib to link to
    $ cd /lib $ ln -s
  5. Extract httpd from package pool
    $  ./ltib -m prep -p httpd 
  6. Extract openssl from package pool
    $  ./ltib -m -prep -p openssl 
  7. Link /usr/include/openssl
    /home/jeff/fsl/10_05/mx51/ltib/rpm/BUILD/openssl-0.9.8g/include/openssl  $ cd /usr/include  $ ln -s /home/jeff/fsl/10_05/mx51/ltib/rpm/BUILD/openssl-0.9.8g/include/openssl openssl
  8. Now Patch httpd-2.0.54/modules/ssl/ssl_toolkit_compat.h with the the following patch
    #ifdef OPENSSL_VERSION_NUMBER  +#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) #ifndef PEM_F_DEF_CALLBACK +#define PEM_F_DEF_CALLBACK PEM_F_PEM_DEF_CALLBACK #endif #endif + /*  * rsa sslc uses incomplete types for most structures  * so we macroize for OpenSSL those which cannot be dereferenced 
    This is supposedly fixed in later verstions 2.0.55.
  9. Build openssl
    $  ./ltib -m scbuild -p openssl
  10. Deploy openssl
    $  ./ltib -m scdeploy -p openssl
  11. Build httpd
    $  ./ltib -m scbuild -p httpd
  12. Deploy httpd
    $  ./ltib -m scdeploy -p httpd
Tags (1)
0 Kudos
2 Replies

Contributor III

Inside LAMP, Apache should be replaced by lighttpd, MySQL should be replaced by MariaDB. Right?

0 Kudos

Contributor III


I have tried the same on imx28 but I am getting errors and httpd server is not restarting.

Issue is reported on community but no answer. Following is the link for the same.

Issue with running httpd server on imx28

Can you please help me what is going wrong with it?

Or is there other option ?



0 Kudos