Instructions for installing Apache and PHP on unRAID.


Recommended Posts

I have a couple of goals.... I want to get down to only one "always on" box (which has to be unRAID) and I want unRAID to serve media directly to my media player via http using my customized php code (like OpenShowCenter).  As a bonus, I'd like the one "always on" box to handle large file transfers (i.e. ISO's, etc) and add root security.

 

I also want all the configuration files (httpd.conf, php.ini, etc) on the flash drive.

 

This is what I have done so far, without modifying the bzroot image:

 

  - spare HD installed with swap, and an ext2 partition mounted to /home

  - basic utilities cpio, wget

  - modified /etc/resolv.conf and /etc/hosts

  - Joe's unmenu

 

The following mods are also in place, using the bzroot modification procedure:

  - basic security with a password to the root login, and added groups and users

  - Apache 2.2.4 installed and running (port 81 so as to not conflict with the unRAID web interface) using a config file on the flash

  - PHP 5 installed with php.ini on the flash.

 

I tested streaming HD video stream via Apache to 2 computers at once and had no problems.

 

My bzroot image file is now about 60 MB, whereas the original was only 28 MB, which is still very small.

 

I am now working on:

ProFTP

ssh

ntp

Asterisk

Truecrypt

 

Likely also are:

TwonkyMedia or SlimServer

python

UPS monitoring

 

Things I can't or won't do:

NFS

 

I'm open to suggestions for other packages.

 

After I am done, I'll write up instructions for how to replicate this process and post them.  I'll also list the packages and dependencies.

 

I could also post my modified bzroot (test.gz) image file for others to download, but I would have to have Tom's permission to post it here or link to it.

 

Link to comment

First, you should familiarize yourself with the procedure I posted for modifying the bzroot file in http://lime-technology.com/forum/index.php?topic=871.0  as the following steps for adding Apache and PHP are done in step 3 of that procedure.

 

Step 3a: download (from http://packages.slackware.it/) the following Slackware packages:

 

- php-5.2.3-i486-2

- libxml2-2.6.28-i486-1

- httpd-2.2.4-i486-6

- apr-util-1.2.8-i486-1.tgz

- apr-1.2.8-i486-1.tgz

- expat-2.0.1-i486-1.tgz

- glibc-solibs-2.5-i486-4.tgz

 

Step 3b: Install these packages to the bz-mod directory

 

ROOT=/mnt/disk1/bz-mod  installpkg <package file> 

 

Step 3c: Create apache user and group

You could change the apache config to use the user “root” instead of “apache” but I want to make the install as consistent as possible with a standard apache install, so we need a user and group named apache.

 

groupadd apache
adduser apache
cp /etc/shadow /mnt/disk1/bz-mod/etc/
cp /etc/group /mnt/disk1/bz-mod/etc/
cp /etc/passwd /mnt/disk1/bz-mod/etc/

 

Step 3d: Move the config files and create symbolic links to them

Apache and php will look for the config files in /etc/httpd.  We could specify a different one on the command line, but the most consistent way is to symlink it to the flash.

 

mkdir /boot/config/etc
mkdir /boot/config/etc/httpd
cp /mnt/disk1/bz-mod/etc/httpd/* /boot/config/etc/httpd/ -r
rm -r /mnt/disk1/bz-mod/etc/httpd
ln -sd  /boot/config/etc/httpd  /mnt/disk1/bz-mod/etc/httpd

 

Now the apache and php config files will be on the flash drive in /config/httpd which is mounted on/boot/config/etc/httpd  and also symlinked from /etc/httpd.

 

Step 3e: Modify the apache config file httpd.conf

I’m going to assume that if you want to get apache running on unRAID, you know how to configure apache, and can make the appropriate changes in the httpd.conf and php.ini files.  Make sure you take care of these issues:

 

  • you MUST listen on a different port than the default port 80.  Otherwise, you will step on the unRAID management utility.
     
  • Either disable logging, or put logs some place appropriate.  If you have installed an extra "always-on" disk outside the array, you can point logs there, or you can point them to a disk in the array.  Remember, if you keep logs on the array, the disk they are on will spin up as well as parity every time you access the server.
     
  • Enable php in apache
     
  • Set up the location for your web documents.
     
  • You should also comment out all unneeded modules in php.ini

 

Now proceed to step 4 of the bzroot modification procedure and you are done.

 

Once you reboot, use this command to test your apache httpd.conf file:

 

apachectl configtest

 

If all is well, start apache with:

 

apachectl start

 

Test php with the command:

 

php -i

 

Put a copy of phpinfo.php (attached below) into your apache document root, and pull it up in the browser to confirm php is working properly.  Note the paths that phpinfo.php reports.  If needed, you can change them in php.ini.

 

Be sure to make the files in your apache document root owned by apache, or apache can't serve them.  cd to the apache document root and use:

 

chown apache:apache * -R

 

Link to comment
  • 2 weeks later...

That is sort of like asking GM to design a car that is easy to use for people who don't know how to drive.  Short of uploadiing my modified bzroot file, those instructions are pretty much what has to be done.

 

In order to run Apache on Linux, one cannot avoid having to know a sufficient amount of Linux, such as setting permissions, user management, etc.  You also have to configure Apache using the httpd.conf file.... not for newbies.  Troubleshooting Apache when something doesn't work also requires real Linux knowledge.

 

Apache is a full-featured top of the line web server.  Some people need all that power... some only need specific parts (such as mod_perl)... but some can get by with something less full-featured.  You could look around for a different web server that may be simpler to install and administer; BUT it must be configurable to the point of changing the listening port from the default 80 to something else (since unRAID used port 80).

Link to comment

BubbaQ,

 

My first reaction to reading your post was, "smack!"

 

However, you are 100% right and you said it the only way it could be said.

 

The need to understand the OS at a fairly deep level is one reason why WHS is so darn attractive to 90% of the "I have the need, but not the know-how or time" community.  Regardless of what we may think of Microsoft, they package their functionality in a way that Linux distros attempt to do, but fall short.  To further your analogy - I want to drive the car, not understand how to rebuild the engine or how that "transmission-thingy" actually functions.  MS shows you the steering wheel, tranny lever, ignition, gas/brake pedals and gas cap.  Linux introduces you to camshaft timings, fuel/air stoichiometric theory, and gear ratios.  The latter gives you far better control over the driving experience, but the former allows my mother to get to the Chippendale show.

 

Back to the topic at hand ... please continue to hang out here and post your learnings.  While many may never take advantage of them, you and a select subset of the members here are offering a huge benefit to those that do and probably are giving Tom a few good ideas for how to make his solution more robust.

 

 

Cheers,

Bill

 

 

Link to comment
  • 1 year later...

hey, nice post... im having one problem though, starting apache with php...

 

here is the error of apachctl -S

httpd: Syntax error on line 476 of /etc/httpd/httpd.conf: Syntax error on line 6 of /etc/httpd/mod_php.conf: Cannot load /usr/lib/httpd/modules/libphp5.so into server: /usr/lib/httpd/modules/libphp5.so: undefined symbol: xmlTextReaderSetup

 

 

it seems that my libxml may be currupted, i have tried installing it several time, "installpkg libxml2....", with no success.  Any suggestions?

 

thanks

Link to comment
  • 1 year later...

Thanks, but I cannot find half of the packages this post says to download, nor which versions of the ones that are there.  Nor can I find cpio-2.5-i486-3 as referenced in the original post.  So how am I supposed to install apache - that's all I want to do?  Am I missing something?

 

Thanks

 

I installed this of yours instead:

 

http://lime-technology.com/forum/index.php?topic=3354.0

 

and it does exactly what I needed - to stream files to the pch via HTTP.  Now I just have to figure out if the server restarts itself after a reboot, but Ill figure it out.

 

Thanks for creating these.

Link to comment
  • 9 months later...

Apparently the Slackware Package Browser is down, and I can't find any evidence of how long it's been that way, but their twitter hasn't been touched in over a year.  Where can I get these packages, or is there another way to get PHP running on an unRAID box?

Valid links for many packages, including "php", are in the package-manager files in unMENU. 

 

It greatly simplifies their download and installation.

 

Here is how "php" looks in unMENU's package manager  (and the links to the packages are valid):

5vqiyp.jpg

Link to comment

hey, nice post... im having one problem though, starting apache with php...

 

here is the error of apachctl -S

httpd: Syntax error on line 476 of /etc/httpd/httpd.conf: Syntax error on line 6 of /etc/httpd/mod_php.conf: Cannot load /usr/lib/httpd/modules/libphp5.so into server: /usr/lib/httpd/modules/libphp5.so: undefined symbol: xmlTextReaderSetup

 

 

it seems that my libxml may be currupted, i have tried installing it several time, "installpkg libxml2....", with no success.  Any suggestions?

 

thanks

It is not that it is corrupted,  libxml is probably not installed.  It is a separate slackware package.

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.