Is atleast being able to toggle PHP planned?

Is the ability to enable PHP planned? or should I just edit the NGINX config?

1 Like


Is the ability to enable PHP planned?


or should I just edit the NGINX config?

The box isn’t meant to be modified so that it can be updated smoothly. I would avoid modifying the box.

1 Like

That’s a fine way to handycap running a website on the box.

It is not a handicap. It’s not part of the feature set and is not planned by Josh. This is strictly a self-contained mail server project. Utilize external DNS to host PHP apps on a different server. :wink:


You’re able to enable PHP for certain domains by adding a conf file, named after your domain name followed by .conf (e.g. to /home/user-data/www .

$ cat /home/user-data/www/

    location ~* \.php$ {
    include fastcgi_params;
    fastcgi_pass php-fpm;
    fastcgi_index index.php;

Why does this work? Can you proof it (i.e. docs , sourcecode) ? I’m mean actually there is no reason for nginx to look at this place.

There are some undocumented features for last-resort situations, but I strongly advise against using those features.

IMO there should be a config choice to define a webserver for the root domain at install time then. Because some of the default behaviors don’t quite follow the paradigm of being a self contained mail server only.


@ellisgeek: What should the box do if the user does not want a web server on the root domain? (Note that it still has to run a web server on the box’s hostname in order to provide the admin panel, webmail, contacts/calendar synchronization, and Exchange/ActiveSync.)

Why not just not advertise on the root domain? If all the services run from the boxes hostname then simply male setting a A record an optional install step and if skipped either give the option to enable hosting or not host anything on the root domain.

I’m not really understanding what you are trying to get out of the settings. I don’t think there is a use case for having a domain simply not resolve at all, is there?

Assuming you want the domain to resolve to something, you can override the A record through the control panel (or, using external dns, just setting it as you want).

If you leave everything alone, with the A record pointing to the box, then the box has to say something when there’s a connection to it over http. You can’t have it resolve to the box and then not have a web server there — because it’s got a web server already (handling other things on the box’s hostname).

1 Like

It isn’t difficult to setup an external server with LAMP stack and host whatever apps. In comparison, it isn’t nearly as easy to setup and maintain a mail server. Therefore, MIAB features are designed appropriately for the intended use cases and scenarios listed on the homepage “Not make something endlessly customizable by power users.”

I have read

I have done this

$ cat /home/user-data/www/

location ~* \.php$ {
include fastcgi_params;
fastcgi_pass php-fpm;
fastcgi_index index.php;


but I cannot see the file added either in ./etc/nginx/nginx.conf or
./home/ubuntu/mailinabox/conf/nginx.conf. Should I re-start the server or is there a trigger to re-run

Run tools/web_update.


It did not work for me

For the future reference to others here are the steps I have taken

  • Created the /home/user-data/www/ file (with my domain replaced of course) as explained by @Norman
  • then set up all the folders for the new domain chown user-data
  • Then run “sudo ./mailinabox/tools/web_update”
  • I saw webupdated on console
  • At some point I have restarted the machine but I am not sure this had any affect.

s a quick solution I have manually added the @Norman suggestion to mailinabox/conf it seems to work but I would prefer to do it properly. Can you tell me which file should be updated after I run the tools/web_update and is there anywhere I can find the logs?

thanks guys

Hi I followed your instructions and it works. but I have
also included the @Norman suggestion inside the mail in a box nginx templates so if Miab rebuilds the nginx conf the modification will be included

Hi @Paula

How did you do this. any help would be gratefully appreciated. :sweat_smile:

My Regards

Just read the Instructions i have linked you some Hours ago - it is as simple as scrolling up a bit in this theard :stuck_out_tongue_winking_eye:

Hello to all !

its not working for me ! can you please help me ! @daghan @JoshData i need to active php for my domains !

here are the steps I have taken

Created the /home/user-data/www/ file (with my domain replaced of course) as explained by Norman
then set up all the folders for the new domain chown user-data
Then run "sudo ./mailinabox/tools/web_update"
but it seems like the update is not working on the console

root@box:~/mailinabox/tools# sudo ./web_update

Suggestions ?
Thnak you guys !!!


Configure php

We need to make one small change in the php configuration.Open up php.ini:

sudo nano /etc/php5/fpm/php.ini

Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.


If this number is kept as 1, the php interpreter will do its best to process the file that is as near to the requested file as possible. This is a possible security risk. If this number is set to 0, conversely, the interpreter will only process the exact file path—a much safer alternative. Save and Exit. We need to make another small change in the php5-fpm configuration.Open up www.conf:

` sudo nano /etc/php5/fpm/pool.d/www.conf`

Find the line, listen =, and change the to /var/run/php5-fpm.sock.

listen = /var/run/php5-fpm.sock

Save and Exit.

Restart php-fpm:

sudo service php5-fpm restart

Configure nginx
Open up the default virtual host file.

sudo nano /etc/nginx/sites-available/default

The configuration should include the changes below (the details of the changes are under the config information):

UPDATE: Newer Ubuntu versions create a directory called ‘html’ instead of ‘www’ by default. If /usr/share/nginx/www does not exist, it’s probably called html. Make sure you update your configuration appropriately.

server {
        listen   80;

        root /usr/share/nginx/www;
        index index.php index.html index.htm;


        location / {
                try_files $uri $uri/ /index.html;

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;


Here are the details of the changes:

Add index.php to the index line.

Change the server_name from local host to your domain name or IP address (replace the in the configuration)
Change the correct lines in “location ~ .php$ {“ section

Save and Exit

Create a php Info Page. We can quickly see all of the details of the new php configuration.

To set this up, first create a new file:

sudo nano /usr/share/nginx/www/info.php

Add in the following line:


Then Save and Exit.

Restart nginx

sudo service nginx restart

You can see the nginx and php-fpm configuration details by visiting http://youripaddress/info.php