On Ubuntu I've installed Laravel and PHP. But when I type ip of my server in the browser I can see only files and folders.
Ubuntu 16.04, php 7.4, apache2
This is my folder /var/www/html/myproj/
:
root@srv:/var/www/html/myproj# ls
CHANGELOG.md bpl laradock routes webpack.mix.js
README.md composer.json package.json server.php
app composer.lock phpunit.xml storage
artisan config public tests
bootstrap database resources vendor
What I have to do yet?
This is laravel.conf file that is in /etc/apache2/sites-available
:
<VirtualHost *:80>
ServerName yourdomain.tld
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/myproj/public
<Directory /var/www/html/myproj>
AllowOverride All
<RequireAll>
Require ip 127.0.0.1 xxx.xx.xx.xx
</RequireAll>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.htaccess looks like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Assuming you are using Apache2, there are several things to do.
First, try to open the public path in your browser, for example : http://localhost/public
If the problem remains, verify in your server configuration that .htaccess
file are handled, this property must be set in the apache2
configuration :
AllowOverride All
Here is an example with the default web server folder :
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
In general this value is set to None
by default, so change it to All
.
But, to be sure you can do that, you must have activated the mod_rewrite
extension, so in linux terminal type this :
sudo a2enmod rewrite
sudo service apache2 restart