Kursad Oney

Running a webserver / example php app on an mx5x -blog archive

Discussion created by Kursad Oney Employee on Apr 17, 2012

I recently set up a webserver on an i.mx508 and have it serve php pages so I thought this could be handy for someone else too.

 

i.mx50 webserver

I followed the instructions here:

http://imxcommunity.org/forum/topics/using-imx-as-a-webserver

The build was surprisingly easy. I downloaded the most recent ltib for mx508 and included the following components:


[ ] php
[ ] apache
[ ] mysql

 

I deployed the resulting rootfs via NFS. Once your project is ready, you can deploy it on a permanent storage.

 

Settings

You will need to modify two configuration files:

httpd.conf , rc.local

The changes to httpd.conf change the default directory. Specifically:

DocumentRoot "/home/web"
    <Directory "/home/web">

This way the pages will be served from /home/web directory on the target board. If your php file is named anything other than index.php, you also add add it to the default pages to serve list.

DirectoryIndex index.html index.html.var index.php yourfile.php

 

The changes to rc.local set create /home/web if it doesn't exist and start the httpd daemon.

if [ ! -e /home/web ]
then
    mkdir -p /home/web
fi
echo "Starting apache..."
/usr/bin/httpd &

 

Here's a simple example php file (taken from http://www.php.net/manual/en/tutorial.firstpage.php)

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'?>
 </body>
</html>

 

Save this file to /home/web/index.php . You can then browse to http://ip-of-your-board and see "Hello World" in your browser.

Outcomes