What is the php path for an Ubuntu 14.04 droplet?

Good day everyone,

I was wondering if you could tell me how I could make this line work in my htaccess (both versions):

ErrorDocument 404 /apps/{NAME}/public/404.php
ErrorDocument 404 /404.php

Basically the 404 is in my /public folder (root directory) and that’s what I’d like to link to in the .htaccess. I’ve tried searching the topics here and I can’t figure out what exactly I’m asking for. The “php path” sounds like the best bet? Lol. ;-)


I don’t know why I didn’t say it earlier, sorry. I’m using Apache2.

@GreenKi Yeah… I don’t use that, half the things don’t work for me there :/

The way I got it is that you want to reference to the 404 page to display on your web page that is located at /apps/{NAME}/public/404.php. If this is what you need we will have to find out which web server you use, there are 2 standards: nginx and apache2. Try ps aux | grep apache and see if it gives any output, if it doesn’t you are using nginx. Just to make it more clean this is a section of my nginx server config to show you the 404 page reference:

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_index index.php;
        include fastcgi.conf;

If you are using apache this will have to be modified to fit your purpose. Don’t try to insert this code in your files.

@Rockeer I found something. I wonder if this is it (from php info page)

 doc_root	/srv/users/{username}/apps/{app name}/public

That doesn’t work nor /404.php. hrm.

@Rockeer I was referencing the DO’s terminal session (that link they give us on the site here.) Sorry! I’m at campus right now we’re really only allowed web interfaces and MS Office products.

I’ll try that php info statement and maybe that will get me the directory I need.

@GreenKi You will be happy you made the swap, VPS is a bit harder but gives you a lot more control which is better in the end :)

@GreenKi If you are using putty you copy by selecting text and right clicking (its a bit clunky is it also pastes but it works ^_^) if you are using OSX, you can copy from standard output with cmd+c, and in Linux its CTRL + C :)

Now, what are you using, I am guessing Apache2?

If its apache, can’t help you there (I am an nginx user), you will probably have to add the folder and listen for php files in apaches “sites-available” config.

This appears to be a part of serverpilot’s features. I’ll go ahead and ask the question over there. I apologize. I’m brand spankin’ new to VPS’s (from CPanel after 6 years lol.)

@Rockeer I can’t seem to copy and paste from the terminal. (LOL! Learning.) :)

master process is showing (/etc/php5.4-sp/fpm.conf) then near the bottom it says pool {droplet name}

This comment has been deleted

What does ps aux | grep php yield?

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @GreenKi,

If you haven’t seen this already, ServerPilot has an article on customizing Apache error messages.

This format does work:

ErrorDocument 404 /404.php

assuming you have a file called “404.php” in your app’s “public” directory.

Note that you can’t use the ErrorDocument directive to catch 404’s for requests that end in “.php” themselves. That is, if a file is requested such as “/this-does-not-exists.php”, that won’t get handled by the ErrorDocument directive because the request ends in “.php”. To handle 404s for requests that end in “.php”, you should use rewrite rules that direct those requests to a specific php script which can send a 404 response.

For example, adding this in your .htaccess file will show a custom 404 page (using a file named “404.php”) for requests for php scripts when the requested script doesn’t exist:

RewriteRule ^404\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /404.php [L]

Then in that 404.php script you would have something like:

header("HTTP/1.0 404 Not Found");
// generate the HTML of the response here

If you’re still having problems with this, you can open a ticket with ServerPilot.

Hello there!

That sounds about right or that you are on the right track. If it does not work, the problem may lie in how you are handling your general .php requests (catch-all vs. specific php files). If you are just handling “index.php”, the redirect to handle your new php error page might not be served properly.

Hope this helps! :)