[howto] apache webserver + PHP on OpenMediaVault

Sure, on OMVPlugins there is also an Apache plugin, but for the Moment it doesn’t work with actual OMV Version 0.5.
So here are some instructions how to get a working apache2 http Server with PHP on your OMV-machine and samba access for easy to fill content.

Get to the console of your OMV-Machine whether by remote ssh or directly on the machine if you have Keyboard and Monitor plugged.
We will use nano as Editor. If you don’t have it already installed you can do that by

sudo apt-get install nano 

or simply use vi

First of all we get our distro actual by


sudo apt-get update
sudo apt-get upgrade

Now we install Apache2 webserver and PHP by


sudo apt-get install apache2 php5 libapache2-mod-php5

(if you wish to install with all available packages for PHP you’ll go with:

apt-get install apache2 libapache2-mod-php5 libapache2-mod-perl2 php5 php5-cli php5-common php5-curl php5-dev php5-domxml php5-gd php5-imap php5-ldap php5-mcal php5-mhash php5-mysql php5-odbc php5-pear php5-xslt

)

Now we have to configure a bit.

We don’t want somebody having access to our openmediavault webroot, so we need a new webroot:


mkdir /var/www/www
chown www-data:www-data www

Or in case you want to have the webroot for your new virtual host on one of your data-volumes you could simply


cd /var/www
sudo ln -s /path/to/your/data/volume/webroot
sudo chown www-data:www-data /path/to/your/data/volume/webroot

The fact that OMV-WebUI resides already on port 80 now leaves us with the options whether to change it to anoher port or leave it and get our own server up on another port. For simplicity we’d go with the second choice and get our new server onto port 81.
To do so we have to create a new virtual host:


cd /etc/apache2/sites-available
sudo nano www

and fill it with life:



<VirtualHost *:81>
        AddHandler cgi-script .cgi

        # Increase HTTP request header field
        LimitRequestFieldSize 16380
        # Set maximum HTTP request length to 25 MiB
        FcgidMaxRequestLen 26214400
        FcgidIOTimeout 300

        DocumentRoot /var/www/www
        <Directory /var/www/www>
                DirectoryIndex index.php index.html
                Options +ExecCGI
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now we tell Apache to listen on port 81 too by

sudo nano /etc/apache2/ports.conf

adding:

#NameVirtualHost *:81
Listen 81

Finally we enable that new virtual host and reload our apache2 to get the changes live:


sudo a2ensite www
sudo service apache2 restart

The webserver should now be ready at http://xxx.xxx.xxx.xxx:81 (replace x with the ip of your OMV-machine).

For easy filling and changing we want to have samba-access to our webroot!
As samba is preinstalled for OMV we could configure the share in OMV’s webUI or manually as follows:


sudo nano /etc/samba/smb.conf

add following lines:


[www]
comment = webroot on port 81
path = /var/www/www/                     #or /var/www/whateveryourwebrootsnameonyourdatavolumeis
guest ok = yes
read only = no
browseable = yes
inherit acls = yes
inherit permissions = yes
ea support = no
store dos attributes = no
printable = no
create mask = 0755
force create mode = 0644
directory mask = 0755
force directory mode = 0755
hide dot files = yes
invalid users =
read list = "www-data"

Now restart samba to get the changes live:


sudo service samba restart

If everything went right we now have an working apache webserver on http://xxx.xxx.xxx.xxx:81
with easy access for changing content on smb://xxx.xxx.xxx.xxx/www/

This entry was posted in Linux, Openmediavault and tagged , , , , . Bookmark the permalink.

2 Responses to [howto] apache webserver + PHP on OpenMediaVault

  1. ermahgerd says:

    the ovm wiki mentions a quick solution to serve custom web content:

    http://wiki.openmediavault.org/index.php?title=Troubleshooting/FAQ

    this method was sufficient for my purposes and a lot easier to setup.

    • eliaxh says:

      Happy to hear you found your solution whether on this or another site. Of course the omv wiki describes a really fast way to achieve rudimentary serving content to the www that will fit for basic level users. However, if you wish to have an independend solution with an own web root that listens on another port or want your omv config-page not on default port etc. you have to go deeper into the system.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.