URL for laravel app on MAMP - apache

I am a total noob at this. Got MAMP, Laravel. My webroot is /Applications/MAMP/htdocs. Normally to hit my laravel application I have to go to:
http://localhost:8080/myapp/public/index.php
What files do I have to configure to be able to access it like this:
http://myapp.com/index.php
I've read docs about adding an entry into my hosts file but when I tried adding the following entry 127.0.0.1 myapp.com I still have to do http://myapp.com/myapp/public/index.php.
What am I missing?

You need to edit your .htdocs file to forward myapp.com to 127.0.0.1 and then set up a DocumentRoot in your httpd.conf file. You can set up multiple redirects if you do it properly.

Related

How do I find out where my root URL is being served from in Apache?

I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!

serving laravel with apache vhost

I followed instructions and added in my httpd-vhost.conf file
<VirtualHost *:80>
ServerName project-laravel-learn.my
DocumentRoot "/srv/http/project-laravel-learn.my/public/"
</VirtualHost>
also added like for other local projects, map in hosts file so that
project-laravel-learn.my goes resolves to 127.0.0.1
http (web user), has all permissions to write and read on that public
folder,
also app/storage is rw- for http,
however, when I visit project-laravel-learn.my I get page saying
Whoops, looks like something went wrong!
What might be the problem? Also how I can get more detailed error message as
this one above isn't that much useful.
Just to add, app was working fine before I moved it to /srv/http/, while developing and using php artisan serve command.
EDIT: Ok it works, I forgot to start my local web server instance, however now routing does not work, I get only homepage, but clicking on any link gives 404 object not found error!?
How to fix that?
Found solution here..
http://www.epigroove.com/blog/laravel-routes-not-working-make-sure-htaccess-is-working
I will leave it for a future reference.

XAMPP is looking for images in htdocs instead of domain folder

I am running XAMPP 1.8.2
Inside of htdocs folder I have a several sites.
Now I downloaded a working website from my hosting/server and found out that the identical copy of that website run on Xampp [http://localhost/mysite] can not find the images.
It is looking for images on
[http://localhost/img/myimage01.jpg] instead of
[http://localhost/mysite/img/myimage01.jpg]
I read some solutions but they all come to pointing the whole thing to [http://localhost/mydomain]
I would prefer if I can tell XAMPP to look for files for every domain from it's own root directory.
How can I do this?
Thanks
The easiest way is to create separate virtual host for each site folder in /htdocs
So you will access the http://mysite.local instead http:// localhost/mysite
There are two things to do:
1. edit C:\xampp\apache\conf\extra\httpd-vhosts.conf (by default) adding something like
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot C:/XAMPP/htdocs/mysite
</VirtualHost>
2. edit c:\windows\system32\drivers\etc\hosts adding
127.0.0.1 mysite.local
restart xampp and try http://mysite.local
You generally can't move a whole website from http://<somedomain> to http://<somedomain>/<somefolder>. Things are bound to go wrong with links between pages in the site and links within pages to images.
Let's say you are displaying images within HTML web pages using image tags like this:
<img src="img/myimage01.jpg"></img>
This will probably work as the browser will look for the img folder in the same folder as the web-page.
On the other hand if your image tag looks like this (note the extra /) you will have the problem you describe:
<img src="/img/myimage01.jpg"></img>
The extra / means the browser will look for the img folder at the root of the domain.

MAMP just ONE virtual host not working

I wanted to start a (my first) wordpress project on my mac.
I run apache with MAMP, and wanted to make another (I allready have a few) virtual host for this particular project.
I added the host to my httpd.conf and etc/hosts file as i've done many times before.
When I browse to the url i've chosen I just end up in the directory that i've specified as root folder in my MAMP settings.
Apache seems to ignore the changes made in the httpd.conf file, but if I remove (rename) the httpd.conf file (to _httpd.conf) it apache doesn't start. so it looks like changes to this file are ignored, BUT if I put something wrong in the file apache doesn't start either...
this is what I put in the httpd.conf file to add a virtual host:
<VirtualHost *>
DocumentRoot "/Users/username/Sites/site_dir/"
ServerName local.sitename.com
<Directory "/Users/username/Sites/site_dir/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
can this have anything to do with WP?
greets,
R.
On Windows:
Try putting it in the conf/extras/httpd-vhosts.conf instead and try
where port 80 is whatever port you have apache running on (:80 by default on windows)
and try not to use .org .com or any ending common on the web in your server name/alias use if you are developing the project on your localhost use something like sitename.local instead.
On Mac:
Not sure how it would work
On Ubuntu 11.04:
I just:
Set up a different vhost file for each site inside of /etc/apache2/sites-available
Then enable the site via a2ensite or just make a copy to the file using cp to the sites-enabled folder (all this is done via the ssh or a terminal on mac)
I then reload and restart apache and wallah!
I'm having a similar problem on one of my ubuntu servers. I'm doing something that I've done several times but all of a sudden it doesn't work. Go figure, lol! Typo? Who knows, definitely scour the web, an answer is sure to surface.

Codeigniter basepath issue on xampp

I've been working in a local dev environment for some time now with Codeigniter v1.7.1, and I recently installed xampp to replace it. Before, I had modified my hosts file and added a the virtualhost in my httpd.conf file, and my website was running at dev.mysite.com.
After installing xampp, the html is displaying when I go to the url localhost/mysite, however, none of the paths are working correctly, because they are formatted relative to the site root, which apparently is not being set correctly.
For instance:
<script type="text/javascript" src="/public_scripts/homepage.js"></script>
is pointing toward the URL localhost/public_scripts rather than localhost/mysite/public_scripts.
I went into config.php and changed the base_url to a number of different things, such as mysite/, but nothing worked.
What can I do to get CI to use localhost/mysite as the root, so that relative paths formatted like /public_scripts/script.js use mysite as the base url and not localhost?
Thanks!
In your hosts file (C:\WINDOWS\system32\drivers\etc\hosts) add
127.0.0.1 dev.mysite.com
In your virtual host file for that site check the DocumentRoot has 'mysite' in it
c:\xampp\apache\conf\extra\mysite.com.conf
DocumentRoot C:/path_to_my_website/site/www/htdocs/mysite/
Are you using the base_url in your views?
<script type="text/javascript" src="<?=base_url()?>public_scripts/homepage.js"></script>
This is just about your /etc/hosts and xampp httpd conf file - you must set up mapping 127.0.0.1 dev.mysite.local or whatever the local domain should be and then add virtualhost like you did before, no way to do this in CI or .htacces.