Routing error in laravel - laravel

I'm trying to build a web app in laravel 5.2 on windows platform with wamp server installation.
I'm trying to call a dashboard page by following routes:
Route::get('nitsadmin/dashboard', function () {
return view('nitsadmin.dashboard');
});
Following is the route list:
where my file structure is as below:
My virtual host configuration in httd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "c:\wamp\www\nitsedit\public"
ServerName nitseditor.dev
</VirtualHost>
Apache alias:
Alias /nitseditor.dev "C:/wamp/www/NitsEdit/public"
<Directory "C:/wamp/www/NitsEdit/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Don't know where I'm getting problem but I'm getting following error:

You have wrong web server configuration, just point web server to a public directory in Lararel project root and restart web server.

You're using the wrong URL, ditch the "nitsedit\public" part:
http://nitseditor.dev/nitsadmin/dashboard
Apache is already pointing the user to the public folder.

Just commented out Include conf/extra/httpd-vhosts.conf in the file httpd.conf present in folder wamp/bin/apache/apache2.4.9/conf and it worked.

Related

In a Laravel application I am returning phpinfo() when I run the project folder

I installed backup of website from live server to localhost in xampp. But when I run the project I mean that when I type localhost/folder its shows php info file. I don't know why this happening. Can anyone guide me?
You'll have to configure virtual host on xampp in
C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost myproject.test:80>
DocumentRoot "C:\xampp\htdocs\myproject\public"
<Directory "C:\xampp\htdocs\myproject">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also add this to hosts file in
C:\Windows\System32\drivers\etc
127.0.0.1 myproject.test
Change myproject with the name you want.

Laravel deployment via Envoyer to Cpanel

I have a VPS running WHM and Cpanel. I have multiple domains hosted there. Say one of them is example.com
What I am intending to do is have two versions of the application.
Production: example.com > /public_html/
Development: staging.example.com > /public_html/staging/
Right now, I am trying to deploy my application to the development environment, i.e to the staging folder.
Envoyer, with a lot of struggle with my hosting provider, is working fine. It's uploading the files as expected. The only issue now is the symbolic link current
Right now the folder structure is:
-staging
- releases
-release1
-release2
- current
My subdomain clearly points out to the staging folder, which will lead it to display all the contents of the folder rather than the application.
Since the application is inside the release folder, how do I make sure that my application runs when we hit the subdomain.
Do I have to modify my virtual hosts file in Apache?
Laravel requires the root for the domain (configured in the relevant apache vhost conf file) to be it's 'public' folder. This is where it's entry point index.php is.
Edit the apache vhosts conf file as per below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/home/user/public_html/public"
<Directory "/home/user/public_html/public">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName staging.example.com
DocumentRoot "/home/user/public_html/staging/public"
<Directory "/home/user/public_html/staging/public">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
Require all granted
</Directory>
</VirtualHost>
For example.com you install your laravel application into /home/user/public_html folder.
As part of the laravel install it will create the 'public' folder.
For staging.example.com you install your laravel application into /home/user/public_html/staging folder.
Don't forget to restart the web server so it picks up the new configuration.
If you do not have the ability to change the vhost configuration mentioned above, you can use .htaccess file in your public_html folder (note the leading full stop which makes it a hidden file). The following is dependant on your hosting provider allowing .htaccess overrides.
Add the following to the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
If domain has been set up correctly by the host to point to /home/username/public_html when entering http://example.com then it should automatically call public/index.php.
You will need to do the same in public_html/staging folder.

How to set Aliases or VirtualHost to run a laravel project on Apache2

I'm starting to learn how to set up a lamp on a vps, and i'm trying to run a laravel project.
This is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /laravelproject /var/www/laravelproject/public
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I'm trying to access using the /laravelproject and it works cause i'm redirected to a login page ip/laravelproject/login (like I set using the middleware for not logged users and it works on my local homestead virtual machine). But i got a 404 file not found error. Not a pretty designed laravel one, but a raw and ugly server error
Not Found
The requested URL /laravelproject/login was not found on this server.
Apache/2.4.10 (Ubuntu) Server at '' Port 80
Of course i don't have any laravelproject.com domain to set up, i want to access it simply with my_server_ip/laravelproject.
How can i set up a virtualhost or an alias to run it with all the routes working?
You could also try enabling apache mod-rewrite if not enabled yet.
sudo a2enmod rewrite
sudo systemctl restart apache2
You'll need to make sure the /var/www/laravelproject/public directory is set to AllowOverride All (which I believe you have taken care of by setting /var/www to All). Then make sure the .htaccess file in your public directory is correctly set up: https://github.com/laravel/laravel/blob/master/public/.htaccess
this is because Apache is looking for /public/login/index.html which is not a file. Laravel's .htaccess redirects these requests appropriately, but it has to be in your public folder and Apache has to AllowOverride
edit:
<Directory /var/www/laravelproject/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

Laravel on wamp

I've set up wamp and laravel with composer, and virtualhosts too. Whenever I go to my project folder 'localhost/project/', or my vhost 'project.dev', I only see the file directory of the laravel project. Yet if I go to 'project.dev/public' or 'project.dev/server.php' it works. What am I doing wrong?
You need to set your DocumentRoot (in your vhosts file) to C:\location\of\laravel\public instead of C:\location\of\laravel\
Here is an example, dont forget to also tell Apache from where it is allowed to accespt connections as well.
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/laravel/public"
ServerName laravel.dev
Options Indexes FollowSymLinks
<Directory "D:/wamp/www/laravel/public">
AllowOverride all
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>

I can't get VirtualHost (Apache) to work for a Zend Framework project (in MacOSX)

I am trying to create a virtual host for a Zend Framework project, but it is not working.
I added the string "127.0.0.1 mysite.local" to the hosts file (/private/etc/hosts), and this is what I put in httpd.conf:
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Applications/MAMP/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "/Applications/MAMP/htdocs/mysite/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I restarted server, and then I try to access it in browser like: http://mysite.local:8888/, but it takes me to "htdocs" root, not to the Zend Project.
Am I missing something? Did I type something wrong? I'm using MacOSX, I tried putting port 8888 instead of 80 in the VirtualHost definition but it didn't work too.
Thanks

Resources