0

Intro

I am struggling to deploy a Laravel project to a domain subfolder... Here's the complete "story":

My teacher has control of the machine at: http://ilp.fe.up.pt/
He created a user for me called mitocondrias so I could use it via ssh like:
ssh mitocondrias@ilp.fe.up.pt

He also set the usual public_html folder to be called html only.

So, to sum up, if I create a simple hello world index.html at /home/mitocondrias/html/ I can successfully see it at http://ilp.fe.up.pt/mitocondrias/


What I did

Now, regarding the Laravel deploy, here is what I did:

I cloned my Laravel project called CoExpr to my user home: /home/mitocondrias/coexpr

I deleted the html folder and created a symlink to /home/mitocondrias/coexpr/public called html with the following command:

mitocondrias@ilp:~$ ln -s ~/coexpr/public/ html

So, here is the final tree structure:

ilp.fe.up.pt/        (the root of my teacher web hosting)
|
|-- mitocondrias/    (my user home, aka /home/mitocondrias)
|   |
|   |-- coexpr/      (the Laravel project)
|   |   |
|   |   |-- [...]
|   |   |-- public/
|   |   |-- [...]
|   |
|   |-- html/        (this is actually not a folder,
|   |                 but a symlink to /home/mitocondrias/coexpr/public/)

I also ran the following commands to set the correct Laravel permissions:

  • chmod -R 755 coexpr/

  • chmod -R o+w storage


The problem

After all this, I can successfully see the landing page at: http://ilp.fe.up.pt/mitocondrias/ (the equivalent of localhost:8000 if I were serving the app with php artisan serve)

But when I try to use other routes, like: http://ilp.fe.up.pt/mitocondrias/explorer (the equivalent to localhost:8000/explorer) I get:

404 Not Found
The requested URL /home/mitocondrias/html/index.php was not found on this server.

What did I do wrong..?


Extra info

In case this is relevant, the .htaccess in /home/mitocondrias/coexpr/public/ is as it was generated upon the Laravel project creation with composer - I did not touch it:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

And because of the symlink, this is also the .htaccess at /home/mitocondrias/html/.


End

So, that's it... Aff, this was a long post... Thanks in advance!

Henrique Ferrolho
  • 912
  • 1
  • 10
  • 30

1 Answers1

2

This related question provides a debugging hint: Check if the route works with /index.php/, to see if the problem is related to .htaccess.

Loading http://ilp.fe.up.pt/mitocondrias/index.php/explorer works!

So for some reason your .htaccess is not working.

Maybe simply enabling it will fix your problem, as stated in this answer to another related question.

Community
  • 1
  • 1
Jan Papenbrock
  • 1,037
  • 1
  • 11
  • 24
  • After running `a2enmod rewrite` and editing `apache2.conf` to `AllowOverride All`, the `.htaccess` is still not working... Here is a copy of the current `/etc/apache2/apache2.conf` : http://pastebin.com/raw/BN3hHjr7 – Henrique Ferrolho May 21 '16 at 17:10
  • Just to be clear of simple errors: Did you restart Apache after these changes? Also, is there a site-specific configuration for your VirtualHost - in `/etc/apache2/sites-enabled/yourfilename.conf` – Jan Papenbrock May 22 '16 at 07:08
  • Yes, we did restart Apache. Here is the content of `/etc/apache2/sites-enabled/000-default.conf`: http://pastebin.com/raw/5TS8jnq9 – Henrique Ferrolho May 22 '16 at 13:53