Virtual host in laravel-4 - laravel-4

How Can i setup virtual host for laravel-4 ?
Previously I wrote some code and routes looked like -
Route::get('/', 'PageController#home');
Route::get('/home', 'PageController#about');
when I gave the url - "http://localhost/laravel-master/public/" I can see the home page but when tired "http://localhost/laravel-master/public/about" i got error saying url not found.
I tired configuring virtual host but ended up with the error - You don't have permission to access"url" on this server.
What is the correct way to do this ??
the path to my laravel folder is "C:\wamp\www\laravel-master"
and instead of using "http://localhost/laravel-master/public/" i wish to use url like "myapp" or so, So that when i use myapp I can see the home page and when I use "myapp/about" I can see the about page.

You need to add your virtualhost and host file.Make your apache listen to your Url.
Something like in your virtualhost file
<VirtualHost laravel>
DocumentRoot "C:/wamp/www/laravel-master/public"
ServerName laravel
</VirtualHost>
And in your host file:
127.0.0.2 laravel
make apache restart and your clean URL will work.

Related

Alias in virtual host using xamp in Laravel 5.6 project

I created a virtual host in xampp for my Laravel 5.6 project.
I did this way:
I added 127.0.0.1 project.com in the hosts file in
C:\Windows\System32\drivers\etc
I changed the port 80 to 8003 in the httpd.conf file in C:\xampp\apache\conf (I changed everything from 80 to 8003 in this file)
I added this:
<VirtualHost *:8003>
DocumentRoot "C:/xampp/htdocs/project/public"
ServerName project.com
</VirtualHost>
in the httpd-vhosts.conf in C:\xampp\apache\conf\extra
I would like to use an alias because I do not want to use the url with the number port at the of the url. I just can access with this url: http://project.com:8003.
I want to enter to my project with the url like this: http://project.com
If you don't want to specify the port, you'll have to use port 80, as it's the standard for the http:// scheme. The browser doesn't magically know on what port a given service is running nor it scans all of them.
Also, the .dev tld is also a real domain and will most likely cause problems.

Laravel 5 - how to change route() and assets() url

When I use the following helpers:
assets('css/app.css');
route('home');
..it generates this URL: "http://myapp.vagrant/css/app.css"
However, I want to change the URL to generate "http://192.168.1.134:8088" as, in my case, a network IP is what I need.
I can find where "myapp.vagrant" is set though. I've change Homestead.yaml and .env files, I've destroyed then vagrant up again. I've tried grep to locate where else this domain might be defined.
Any suggestions? The URL http://192.168.1.134:8088 is pointing correctly to the site but the urls that are generated are using the wrong URL (myapp.vagrant)
Btw here's my apache config file (/etc/apache2/sites-available/myapp.conf):
<VirtualHost *:8088>
ServerName mydomain.com
ServerAlias www.mydomain.com
ProxyPass "/" "http://myapp.vagrant/"
ProxyPassReverse "/" "http://myapp.vagrant/"
</VirtualHost>
So http://192.168.1.134 is the host machine, and I want port 8088 to point to http://myapp.vagrant/ (/etc/hosts points this domain to the vagrant IP) .. unless Laravel is picking up this domain from here?
you can use .env file to set it
APP_URL=http://192.168.1.134:8088

Tomcat 7 - Ubuntu : create a domain name instead of IP:8080/appName

I have deployed my webapp on an Ubuntu server in my company.
the war is in the folder :
/var/lib/tomcat7/webapps
Tomcat7 has deployed the archive in the folder
/var/lib/tomcat7/webapps/bioApp/
My problem is that to access the web app I need to type the url :
http://IP_OF_SERVER:8080/bioApp
I would like the users to type :
www.bioApp.com
I have tried many solutions (modifying server.xml, hosts file, etc).
None of them work.
If anyone has a working solution...
Thanks
The first thing you need is a local dns server in your company. In your dns server add a rule to route your ip (IP_OF_SERVER) to the local domain name
IP_OF_SERVER bioApp.com
If you had an apache server, you must add a virtualhost in your conf file (See this page for more information)
<VirtualHost *:80>
ServerName bioApp.com
ProxyPass / http://IP_OF_SERVER:8080/bioApp
ProxyPassReverse / http://IP_OF_SERVER:8080/bioAppr
</VirtualHost>
If you don't have a apache server, you can change your tomcat listen port.(See this post).

how to redirect example.com to 127.0.0.0/main/test?

i'm using wamp 5, windows XP. i have edited my host file in my local disk like the code below and it works
127.0.0.0 example.com
but i'd like to redirect to a particular folder, if i change it to the code below, it dont work
127.0.0.0/main/site example.com
how to redirect example.com to 127.0.0.0/main/site locally in my PC?
btw, i dont want to install any new software to solve this prob
You need to create a Virtual Hosts
Leave the HOST file as
127.0.0.1 example.com
When you define a Virtual Host you also tell it which folder is its DocumentRoot so that will send it to the right place when you use the address example.com in the browser.
Check out wampserver.com

Issue with Virtual Host on Zend Server CE and Mac OSX

I'm using Zend Server CE 5.6.0 on Mac OSX.
My httpd.conf has the following line, adding the virtual hosts file:
Include conf/extra/httpd-vhosts.conf
At that file, I have the following:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localtextil.drupal.lh
DocumentRoot /usr/local/zend/apache2/htdocs/Obiz/LocalTextil-Portal/drupal
</VirtualHost>
So, by definition, when I try to access localtextil.drupal.lh, it should redirect me to its document root.
The problem is, when I try to access that host, I got an error.
And when I simply access localhost, I go to the site located on /usr/local/zend/apache2/htdocs/Obiz/LocalTextil-Portal/drupal.
What am I doing wrong here?
Two things - first is that the virtualhost definitions (as I understand it) override apache's mappings between directories and servernames. The first defined virtualhost is what apache will use as a default when it can't find a map - so it should be a generic setup (reflecting your original domainname, in your case, localhost) first, then your specific setup following it.
Second is that if your folder is outside of where you have given apache permissions to read, then you may get an error. The directory permissions are set by a DocumentRoot directive - however:
Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then
it will look at each section with a matching IP address
and try to find one where the ServerName or ServerAlias matches the
requested hostname. If it finds one, then it uses the configuration
for that server. If no matching virtual host is found, then the first
listed virtual host that matches the IP address will be used.
As a consequence, the first listed virtual host is the default virtual
host. The DocumentRoot from the main server will never be used when an
IP address matches the NameVirtualHost directive. If you would like to
have a special configuration for requests that do not match any
particular virtual host, simply put that configuration in a
container and list it first in the configuration file.
The Apache document page on name based virtual hosting is here, it should help give some ideas. Basically you need to look at the definitions you have for DocumentRoot and the servernames, and go through them making sure they are all "ok".

Resources