Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bbparis's avatar

When I go to laravel folder, I see ALL FILES INSIDE

I update my question to be " When I go to laravel folder, I see ALL FILES INSIDE", as it is the question that get a detailed answer. So JUMP directly please to my 3rd post below. Thanks!

Hello,

I'm really so so tired after many hours spend on this 403 page on ubuntu. I still have the following :

Forbidden

You don't have permission to access /demo/ on this server.

Apache Server at dev.gowazo.com Port 80

How can I resolve this issue if you can help me please ?

0 likes
23 replies
bbparis's avatar

Thank you Ruffles, during my reading about this answer, permit me to ask another question. I have Ubuntu 12.04 / Apache 2.2 / Plesk 12. and inside Plesk I have 2 PHP versions ( 5.3 and 5.6 ) I select 5.6 for the domain where I'm installing Laravel. but as the default version of PHP is 5.3 on the server ( when I check apache -v ), when I send this command :

composer global require "laravel/installer=~1.1"

I get :

Your requirements could not be resolved to an installable set of packages.

Problem 1 - laravel/installer v1.1.1 requires guzzlehttp/guzzle ~4.0 -> satisfiable by guzzlehttp/guzzle[4.0.0, 4.0.1, 4.0.2, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.1.7, 4.1.8, 4.2.0, 4.2.1, 4.2.2, 4.2.3] .....

Installation failed, deleting ./composer.json.

davorminchorov's avatar

Delete PHP 5.3 and set PHP 5.6 to be the default. Or you can change the default to be 5.6 by pointing it to the version's path:

You can edit your .bash_profile file to change your default search path. Or update it using PATH=/usr/local/php/bin:$PATH or somesuch.

Changing the default php command path

bbparis's avatar

Concerning the first solution, unfortunately I have Apache 2.2, so I couldn't find DIRECTORY paragraph :

<Directory "your directory here"> Order allow,deny Allow from all

New directive needed in Apache 2.4.3:

Require all granted

Concerning the second solution ( your last post ), I'm trying ( thanks a lot for your help )

bbparis's avatar

Hello again.

Ok, finally, I left the dedicated server for Laravel and I just passed to DigitalOcean, and installed everthing : Ubuntu 14.04 LTS + LAPM now what is the new problem ( I don't think it is big ): When I goto laravel folder, I see ALL FILES INSIDE and not the homepage. After search, I found that this is a VirtualHost issue, right ? if YES, how can I solve it ? knowing that I point the IP of my DigitalOcean to : dev.mywebsite.com and laravel script in this folder : dev.mywebsite.com/demo

Thank in advance for yoru help, and again speacial thanks to you Ruffles.

bashy's avatar

Change your root path to the public folder of Laravel, also remove indexing of folders... that's pretty important.

bbparis's avatar

Thank you bashy, in fact I'm not really so clever to understand what you asked me to do : do you have any YouTube link that explain your first demand. I think the second demand if to remove the index.php files from the folders, right ?

bashy's avatar

Basically (depending on the web server software) you set the document root / root of the virtualhost to the public folder in Laravel (some frameworks have like a www folder which is the root of the site files). If you use Apache, you'd set

DocumentRoot /home/sites/site1/public

In Nginx it's just

root /home/sites/site1/public;

Again for disabling indexing, do these in either the virtualhost or htaccess (if it's Apache).

// Nginx (indexing is off by default but who knows!)
autoindex off;

// Apache
Options -Indexes
tgif's avatar

This worked for me. This is from my personal notes and these steps enabled me to setup my first Ubuntu server.

1.) Open /etc/hosts and add:

127.0.0.1 mysitename.com OR 192.168.1.76 mysitename.com

2.) Go to /etc/apache2/sites-available and copy the default.conf file in order to alter it with the name 'mysitename.com.conf'. Add or change the following lines:

ServerAdmin admin@laravel.dev

ServerName mysitename.com

ServerAlias www.mysitename.com

DocumentRoot /var/www/mysitename.com/public

<Directory

            Options FollowSymLinks 

            AllowOverride None 

Directory>

<Directory /var/www/mySiteNameProjectFolder>

            AllowOverride All

AllowOverride at a subdirectory level may have to be set to 'All' because Laravel uses pretty URIs.

3.) Now that the site is available and Apache is listening for it on port: 80 you need to enable it. You can create a link to '/etc/apache2/sites-available/mysitename.com.conf' and place it in '/etc/apache2/sites-enabled' but there is an easier way. Change directories to /etc/apache2/sites-enabled and use this Apache command:

a2ensite mysitename.com

This will create the link for you.

4.) Now create your laravel project with the same name and location as written in the 'mysitename.com.conf' file: DocumentRoot /var/www/mysitename.com/public

5.) Now we have to give Apache user and group ownership of the project folder. In order to know the name of the Apache user and group you can look in '/etc/apache2/envvars'. Go to the '/var/www' directory where your project folder is located.

sudo chown -R www-data:www-data mysitename.com/

6.) I changed this in the /etc/apache2/envvars file

#export APACHE_RUN_USER=www-data

#export APACHE_RUN_GROUP=www-data

export APACHE_RUN_USER=csuarez

export APACHE_RUN_GROUP=csuarez

The user name matches the user:group owner of the project folder.

8.) Restart Apache service

sudo service apache2 restart

9.) https://www.youtube.com/watch?v=yHqumQUJYfU

bbparis's avatar

Hello, and thank you both @bashy and @csuarez for your help.

@csuarez : I appreciate your details, and followed the steps, but unfortunately not working, here is my ( dev.mywebsite.com.conf) file details :

<VirtualHost *:80> ServerName dev.mywebsite.com/demo # ServerAlias dev.mywebsite.com/demo DocumentRoot /var/www/html/demo/public

<Directory /var/www/html/demo/public>
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/myproject-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined

My mywebsite.com is hosted on a server, so I want to make all my test on another server or virtual server, so I took VPS with Digital Ocean for the subdomain (dev.mywebsite.com), but my Laraval project is inside (demo) directory in this subdomain. So like that :

Files of dev.mywebsite.com are in ( html ) folder inside /var/www ( html folder here like httpdocs ) Files of dev.mywebsite.com/demo ( this is mean files of Laravel) are in ( html/demo ) folder inside /var/www

I hope the above details will help you to support me with your solution. Thanks again.

bashy's avatar

Ah I now understand your previous thing about /demo. In that case you will need to rewrite everything /demo/* into /public

Add this above the current rewrite rules in .htaccess file (in Laravel public)

RewriteBase /demo

Virtualhost config (maybe under DocumentRoot setting)

Alias /demo "/var/www/html/demo/public/"
bbparis's avatar

Thanks @bashy for your reply. I did exactly as you said, but still get the liste of files inside :

dev.mywebsite.com/demo

But when I go to (public) folder, this is mean (dev.mywebsite.com/demo/public) , I see without problem the Laravel 5 homepage. I know that the solution is so simple, but till now, no chance :(

bashy's avatar

@bbparis What files do you see?

You don't need to do /public, it's rewritten to /demo

Your pages should work if you do dev.example.com/demo/someroute

bbparis's avatar

Yes you are right, but I'm still getting the liste of my files inside the demo folder

bbparis's avatar

you mean my file should be like that ?

VirtualHost *:80> ServerName dev.example.com/demo DocumentRoot /var/www/html/demo/public Alias /demo "/var/www/html/demo/public/" <Directory /var/www/html/demo/public> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted

ErrorLog ${APACHE_LOG_DIR}/myproject-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined

bashy's avatar

Oh right sorry, you need to change the part.

<Directory /var/www/html>
    // [...]
</Directory>
bbparis's avatar

Ohhh this problem is going to make me crazy. Not work I will not bother you again, and will take the fast solution :

add a index.php file inside /demo with the following code :

<?php
header('location: public');

I know that this is not a real solution, but I have no choice

bashy's avatar

You just need to link the structure up. I'm not sure what you see/don't see but it works for me.

bbparis's avatar

Maybe I made a mistake, unfortunately there is no private message here to send you the reel link.

bbparis's avatar

Great, you will get it in few minutes or maybe secondes

bbparis's avatar
bbparis
OP
Best Answer
Level 1

Finally I got the solution and understand the things better. Anyway I will explain, just to help the future person who will come to here to find a solution for his problem, as @bashy, @csuarez and @Ruffles was trying to help me, so THANK YOU again guys for your support.

1 : Follow the steps as explained by @csuarez

2: you will have a your .conf file inside your /etc/apach2/sites-available directory ( ex : mywebsite.conf ), and inside this file, this is what you should understand and I will explain you be presenting my .conf file :

-------------------------- inside mywebsite.conf file is below --------------------------

<VirtualHost 188.169.78.162:80>
ServerName dev.mywebsite.com
DocumentRoot /var/www/html/
Alias /demo "/var/www/html/demo/public/"
<Directory /var/www/html/demo>
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/myproject-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined

</VirtualHost>

-------------------------- inside mywebsite.conf file is above --------------------------

A : This line ( <VirtualHost 188.169.78.162:80> ) where you should put or ad the IP of you website or subdomain, here it is the IP of my subdomain (dev.mywebsite.com), so the IP is 188.169.78.162 only, so leave the (:80) after the IP

B : This line ( ServerName dev.mywebsite.com ) means that the name of your server ( server here is a word, so it is mean also you Cloud server, Private server, ... ), so your IP now is linked to the subdomain (dev.mywebsite.com)

C : this line ( DocumentRoot /var/www/html/ ) mean that your root files here here ( /var/www/html/ ) so if I type in my navigator this address (dev.mywebsite.com) I will see the files inside this folder ( /var/www/html/ ), sure you can change it to be ( DocumentRoot /var/www/html/otherDirectory ), and then when I visit (dev.mywebsite.com) I will see the files inside this folder ( /var/www/html/otherDirectory )

D : Here is the most important thing, mentioned by @bashy, the following line :

   Alias /demo "/var/www/html/demo/public/"

means that when I visite this link (dev.mywebsite.com/demo) I will see the files inside this folder ( /var/www/html/demo/public/ ), so the link (dev.mywebsite.com/demo) still same, but you will see the files of another directory. This is what I was looking as my Laravel copy is in this folder (dev.mywebsite.com/demo), but the files that the visitors should see are available in ( /var/www/html/demo/public/ ).

Maybe I write a lot of details, but the most important that we all should understand, who knows can't understand easily that really the one who is learning and new in this world, is like a BABY, a small child, that you should take him from his hand and explain him slowly, with example, images and videos if possible, like @csuarez did in his post (point 9) with the YOUTUBE video.

Again thanks for you all, for your time and your help. Regards

5 likes

Please or to participate in this conversation.