404 Error in laravel 5.1 Wamp - laravel

I am beginner in Laravel. I used Laravel 5.1 in Wamp Server (Apache/2.4.9 (Win64) PHP/5.5.12)
I received the 404 Not Found Error, when I called the page like
http://localhost/laravel/public/login
Route::get('login', function() {
//return View::make('login');
return 'Hello World'; });
vhost.conf code
ServerAdmin local#gmail.com
DocumentRoot "C:\wamp\www\laravel\public"
ServerName localhost
ErrorLog "logs/AuthorityController.www-error.log"
CustomLog "logs/AuthorityController.www-access.log" common
<Directory "C:\wamp\www\laravel\public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

Try this: http://localhost/login
may be it helps you, i hope :). And check that you vhost in appache is set to .../your_laravel_project/public folder
UPDATE
Go to C:\Windows\System32\drivers\etc\hosts and add line at the bottom:
127.0.0.1 myproject.dev
Then, in your appache httpd.conf file you shoud uncoment line:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
BONUS: You can also switch directory with you projects in lines (for instance i have my projects in 'F:/Code'):
DocumentRoot "F:/Code"
<Directory "F:/Code">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Next step, in your httpd-vhosts.conf you should have:
<VirtualHost myproject.dev>
DocumentRoot "F:\Code\myproject\public"
ServerName myproject.dev
ServerAlias myproject.dev
<Directory "F:\Code\myproject\public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Then reset appache. And when you go to your browser and put http://myproject.dev you should see your page :)

You don't need to do that anymore. Don't include that. What you do is put a view file (your 404 error view) called 404.blade.php in your resources/views/errors folder and Laravel will handle 404 errors for you.

Related

URL not found on server when uploading Laravel project

I have a Laravel project that is on a live server and I have made a copy to place in a development server. When I try to login, it says The requested URL /xxxx/login was not found on this server..
I am not quite sure what to do, as I changed my httpd.conf to
<Directory "/var/www">
AllowOverride All
Require all granted
</Directory>
and
<Directory "/var/www/html">
AllowOverride All
Require all granted
</Directory>
but I am still getting the same error after restarting apache. Is there any way to solve this?
I think you didn't config for the virtual host or you config it wrong.
You can find that config file under folder /etc/httpd/conf.d/vhosts/ Below are a sample file config:
$ cat /etc/httpd/conf.d/vhosts/yoursife.conf
<VirtualHost *:80>
ServerName yourdomain.com
ServerAdmin youradmin_server_mail
DocumentRoot /your_src_path/public/
<Directory "/your_src_path/public/" >
Options FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /your_src_path/public/logs/error_log
CustomLog /your_src_path/public/logs/access_log combined
</VirtualHost>
You can create a new file if you want.

set virtualhost in apache is not direct to my goal directory of laravel project

OS: Microsoft Windows 10
backend framework: Laravel
my goal: when I access to "http://example.domain", it can direct to laravel index.php.
httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "C:\Apache24\htdocs\NKUST_foodpanda\public"
DirectoryIndex index.php
ServerName example.domain
ErrorLog "C:\Apache24\logs\error.log"
CustomLog "C:\Apache24\logs\access.log" combined
<Directory "C:\Apache24\htdocs\NKUST_foodpanda\public">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I save httpd-vhosts.conf and restart my apache, and now, when I access to "http://example.domain", it will direct to "C:\Apache24\htdocs", not "C:\Apache24\htdocs\NKUST_foodpanda\public".
I have tried with same possible scenario as yours with following entry httpd-vhost.conf. Checked it with both '' and '/' and it is working for me. Make sure to provide proper permission to your directories. If this could not work you need to provide more info.
<VirtualHost example.domain:80>
DocumentRoot "C:\Apache24\htdocs\NKUST_foodpanda\public"
DirectoryIndex index.html
ServerName example.domain
ErrorLog "C:\Apache24\logs\error.log"
CustomLog "C:\Apache24\logs\access.log" combined
<Directory "C:\Apache24\htdocs\NKUST_foodpanda\public">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If you want to set a newer setup in "httpd-vhosts.conf", you have to delete comment out "Include conf/extra/httpd-vhosts.conf" in "httpd.conf".
I have not notice this problem, I comment out "Include conf/extra/httpd-vhosts.conf" and set something in "httpd-vhosts.conf" at the same time, so "httpd-vhosts.conf" doesn't work.

deploy multiple laravel projects in apache virtual hosts

I have two laravel projects, I deploy on VPS, then I configure the apache virtual host for each project in my /etc/apache2/sites-available.
example:
project1.conf:
Listen 8999
NameVirtualHost *:8999
<VirtualHost *:8999>
ServerName project1.test
ServerAlias www.project1.test
DocumentRoot "C:/laragon/www/data/project1/public"
DirectoryIndex index.php
<Directory "C:/laragon/www/data/project1/public/">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
project2.conf
Listen 8998
NameVirtualHost *:8998
<VirtualHost *:8998>
ServerName project2.test
ServerAlias www.project2.test
DocumentRoot "C:/laragon/www/data/project2/public"
DirectoryIndex index.php
<Directory "C:/laragon/www/data/project2/public/">
#Options Indexes FollowSymLinks MultiViews
AllowOverride All
#Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
in my /windows/system32/drivers/etc/host, I have already made a host for each project.
but I have a problem, which is when I open the first project in the browser and log in, then at the same time I open the second project and login too, when the first project is refreshed, it returns to the login page. Why did it happen ?
Instead of doing it the hard way, you can try to use Laravel Valet, which allows you to link your site to a domain like localhost.test and localhost2.test. It takes care of all virtual host configuration.

How to point multiple laravel projects on same domain?

I want to create two Laravel applications like below:
app1.domain.com -> points to app1 laravel. Here I am allowing multiple subdomains like wildcard subdomains.
app1.domain.com/blog -> should point to blog laravel.
Database is the same for both applications, and session will be the same.
How can point these two like above?
I have pointed like below
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www\app1\public"
ServerName app1.domain.local
ServerAlias *.domain.local
<Directory "C:\wamp64\www\app1\public">
Options Indexes FollowSymLinks
allow from all
order allow,deny
AllowOverride All
</Directory>
## Path to laravel sub-folder
Alias /blog/ "C:\wamp64\www\blog\public"
<Directory "C:\wamp64\www\blog\public">
AllowOverride All
</Directory>
</VirtualHost>
Using above config, app1 is working fine but blog application does not work. It shows forbidden error You don't have permission to access /blog/ on this server.
Solution:
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www\app1\public"
ServerName app1.domain.local
ServerAlias *.domain.local
## Path to laravel sub-folder
Alias /blog/ "C:\wamp64\www\blog\public"
<Directory "C:\wamp64\www\blog\public">
AllowOverride All
</Directory>
<Directory "C:\wamp64\www\app1\public">
Options Indexes FollowSymLinks
allow from all
order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
Now working fine but with in the blog application assets path not working correctly. assets pointing from main domain instead of subfolder.
it should be like
http://app1.domain.local/blog/assets/js/login.min.js?id=c818c905d151b67566ee
but loading from http://app1.domain.local/assets/js/login.min.js?id=c818c905d151b67566ee

Hosting Mutiple laravel project in sub-directory in same server

I am struggling to host the multiple laravel project in same server in sub-directory.
I want to run laravel project in example.com/CoreApp and example.com/DataSync
Project Directory:
- Root directory (example.com): React Js Project
- CoreApp (example.com/CoreApp) : Laravel Project
- DataSync (example.com/DataSync) : Laravel Project
Here is the current issue I am facing now.
example.com/ => It is working fine.
example.com/CoreApp => It is working fine.
example.com/DataSync => It is serving me 404 page whereas its other routes are working fine. Like example.com/DataSync/telescope is working fine.
Note: Also, I have added RewriteBase /DataSync and RewriteBase /CoreApp in respective project in .htaccess
Here's my config:
Server Config:
- Digital Ocean Server
- Apache web server
- Ubuntu 16
Here is what my virtual host look like.
<VirtualHost *:80>
DocumentRoot /var/www/sites/html
Alias /CoreApp /var/www/sites/html/CoreApp
Alias /DataSync /var/www/sites/html/DataSync
<Directory /var/www/sites/html/CoreApp>
AllowOverride All
DirectoryIndex index.php
</Directory>
<Directory /var/www/sites/html/DataSync>
AllowOverride All
DirectoryIndex index.php
</Directory>
ServerName www.example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
<Directory "/var/www/sites/html">
Options Includes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
ServerAlias www.example.com
DocumentRoot /var/www/sites/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateKeyFile /etc/ssl/sites/key/myserver.key
SSLCertificateFile /etc/ssl/sites/certs/example_com.crt
SSLCertificateChainFile /etc/ssl/sites/certs/example_com.ca-bundle
<Directory "/var/www/sites/html">
Options Includes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Change in you virtual host file for Alias as:
Alias /CoreApp /var/www/sites/html/CoreApp/public
Alias /DataSync /var/www/sites/html/DataSync/public
you have to provide location of public folder
You should provide URL up to your-directory/public. If still issue. then provide URL up to your-directory/public/index.php.

Resources