Change root folder for XAMP - php

I've got an XAMPP installation running great and I've configured my local machine to be accessed by other users via my IP address using this tutorial here.
However, when I navigate to this page I get the standard XAMP (horrible yellow and orange) homepage.
Where can I change my root directory for my website so I've got a folder called oursite within the htdocs folder of XAMPP which I'd like to load when a user navigates to my page instead of redirecting to the xampp folder.

Just as explained in the tutorial you mentionned, in the file C:\xampp\apache\conf\extra\httpd-vhosts.conf, you should have a VirtualHost definition like this one :
<VirtualHost *:80>
# Just Change the line above so that DocumentRoot point to your "oursite" folder
DocumentRoot "/Applications/MAMP/htdocs/oursite/"
ServerName Whatever.server.name.you.want
</VirtualHost>
Just Change the line above the previous comment so that DocumentRoot point to your "oursite" folder

Related

How to point to project index page by default in XAMPP

i am pretty new this kind of work. I had developed a web app using PHP. i am using XAMPP Server. Now when i am hitting http://www.mywebsite.com/myproject i got my project index page. Now what i looking is if i enter http://www.mywebsite.com it should display myproject's index page.
I am not sure what is this term called. I didn't know how to search for this solution.
Your help will be much appreciated if you can provide the term i should look for or the solution for this.
thanks
When you edit the httpd-vhosts.conf file (which is in C:\xampp\apache\conf\extra), edit the DocumentRoot property accordingly.
Your current settings are probably looking like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName www.mywebsite.com
</VirtualHost>
which directs you to the main htdocs folder. In order to display your project, you use www.mywebsite.com/myproject. You should change the DocumentRoot. For example:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/your-project-folder"
ServerName www.mywebsite.com
</VirtualHost>
Tested on Win 8.1 Pro x64, XAMPP 5.6.21 portable. It's working.
Open the file index.php from the htdocs in xammp ( ..\xampp\htdocs\index.php)
Change the line
header('Location: '.$uri.'/dashboard/');
to
header('Location: '.$uri.'/yoursitefolder/');
this will resolve the issue.

Laravel 5.1 - Remove "public/" of the URL whith Method bind?

I need some help Please, for I'm beginner with Laravel and MVC.
I want to remove the "public/" of the URL.
The only two "solutions" that I found in Google, are:
Either with .htaccess. But with me (and obviously not with me) it's not working.
Either by putting what is in the "public" folder at the root of the project Laravel. This is not good for security reasons.
There is a real solution to remove the "public/" URL? So that for example this URL:
localhost/Laravel/public/test
Accessible only with this URL:
localhost/Laravel/test
Because if it or has no solution, it is of no use that I continuous to take courses on this Frameworks.
_I had read, that there may be a solution with this in AppServiceProvider:
http://www.creerwebsite.com/medias/upload/larav2.png
Or with this in the Router or a container:
App::bind('path.public', function() {
return base_path().'/public_html';
});
But I am beginner, so I do not find the solution.
Thank you.
The best option is to configure your local installation of WAMP to use Laravel's public folder as the document root. You have two options here:
Option 1. Use wamp just for this project alone
Find your httpd.conf file. This is the server config, and should be located in C:\wamp\bin\apache\Apache2.4.4\conf. (it's a good idea to make a backup of this file before editing)
Open the config file in notepad, find the line DocumentRoot "c:/wamp/www" and change to DocumentRoot "c:/wamp/www/public" (assuming you have your laravel project in the www folder)
save the httpd.conf and restart wamp.
Now when you visit http://localhost you should see the Laravel welcome screen.
Option 2. Set up a virtual host
This option is a bit more complicated, but will allow you to have multiple websites running alongside each other in wamp, each with their own subdomain that you can use to access them in your browser.
1. open the httpd.conf file in notepad and find the line DocumentRoot "c:/wamp/www". Change it to DocumentRoot "c:/wamp/www/default".
2. add the following snippet below this line:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot 'c:/wamp/www'
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName myproject.localhost
DocumentRoot 'c:/wamp/www/myproject/public'
</VirtualHost>
This will create two new virtual hosts running on your local ip. One will work on the domain localhost and serve files from the www/default folder, the other will work on the domain myproject.localhost and serve files from the www/myproject/public folder.
locate your hosts file at C:\Windows\System32\drivers\etc and open it in notepad. add the following lines:
127.0.0.1 localhost
127.0.0.1 myproject.localhost
This will add two domain mappings that point traffic to your local ip for wamp to handle.
Now navigate to the www folder and create C:\wamp\www\default and C:\wamp\www\myproject. Move your laravel project into the \myproject folder ensuring that the public folder is here as well.
finally restart wamp and now you should be able to go to http://myproject.localhost and see your laravel website.
The solution :
_In His Laravel project: Rename the "public" folder like this: "www."
_In An accommodation (example OVH): remove all that is at the root, including the "www" (except: .ovhconfig).
_Send His project on accommodation.
I hope it will not cause conflict. After I think we should also rename in his Laravel the "public/" in "www/".
thank You

Can't View Home Page Wordpress Localhost Mamp

I have set up a local wordpress environment which is a carbon copy of a live site so we can work on a new design.
The live site database has been copied into localhost php myadmin and is working fine.
The localhost site is situated in a folder called /3dfc/ inside the htdocs folder.
So i have a site address of - http://localhost:8888/3dfc -
I can view the whole website no issues, apart from the homepage.
Any ideas on how to fix?
goto wp-admin
setting --> reading
and set your front page to the page which you want to set as home page.
I found the solution. I post a similar question here:
Home Page Wordpress on Free MAMP does not work
after several debug I found that this guide is correct:
http://foundationphp.com/tutorials/vhosts_mamp.php
You need:
1. In /etc/hosts add your virtual hosts like:
127.0.0.1 localhost
127.0.0.1 mywebsite
before I only used localhost because I hoped to use this host in browser but I found it's required to define a new host like mywebsite.
In httpd.conf I activated:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
In this file I have:
NameVirtualHost *:8888
ServerAdmin myuser#gmail.com
DocumentRoot "/Applications/MAMP/htdocs"
ServerName mywebsite
ErrorLog "logs/mywebsite-error_log"
CustomLog "logs/mywebsite-access_log" common

WAMP directory in different location?

I'll start by saying I' completely new to WAMP.
The issue I'm having is that I have my WAMP program director installed in C:\Program Files- however, my C:\ drive is filling up fast and the site I work on is extremely large. Is it possible to have WAMP installed on C:\ but direct WAMP to look for the index file in say E:\www\???
You should be able to edit the DocumentRoot location in httpd.conf
I believe the default is: DocumentRoot "c:/wamp/www"
You should be able to amend this to a new folder: DocumentRoot "E:/www/"
You might need to also change the <Directory "c:/wamp/www"> listing as well.
You can open httpd.conf via the WAMP app. It comes under Apache.
try go to
C:\wamp\bin\apache\Apache2.2.17\conf\httpd.conf
change DocumentRoot "c:/wamp/www/" to DocumentRoot "e:/wamp/www/" (line 178)
For more :- Moving WAMP and Wordpress to another drive

XAMPP localhost returns object not found after installing Laravel

After much faffing about I got laravel to work with XAMPP. However, I can't seem to access directories in the htdocs folder via localhost now. Attempt to access a file returns Object not found! along with The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
The changes I made to get laravel working seems like a blur now. The only thing I remember doing is editing the hosts file to enable the virtual host to work by adding 127.0.0.1 laravel.dev in the hosts file (using a mac btw). I also added a virtual host to the httpd-vhost.conf file.
I did undo the above changes but it didn't make a difference.
Any thoughts on whats gone wrong?
Thanks.
Dispelling Confusion
Just thought I'd clarify what my experience is. Before installing laravel 4 I could access all my projects with localhost/someProjectName but now it fails.
I'm trying to identify what change caused this behaviour. Btw, I have no problems accessing my laravel project (my mapping allows me access to it via laravel.dev)
Look into your /etc/httpd.conf file and see if you have Virtual hosts activated.
If so, check your etc/extra/httpd-vhosts.conf file. You might have set up a VirtualHost already.
EDIT: I have found that once you turn on Virtual Hosts, XAMPP needs a default VirtualHost for your basic htdocs files
Try adding a default VirtualHost (at the bottom of the file) like so:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/htdocs"
<Directory "/Applications/XAMPP/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
It sounds to me like it is a problem with the way your directories are configured. Be sure to create a Virtual Host (if you're using Apache) that points to the public folder within your application directory.
For example, if your Laravel project is under /Applications/XAMPP/htdocs/Laravel then set up a Virtual Host like this:
<VirtualHost *:80>
DocumentRoot /Applications/XAMPP/htdocs/Laravel/public
# Other directives here
</VirtualHost>
Additionaly, if you're working with PHP >= 5.4, SSH into the application folder and run
./artisan serve
(Be sure that your PHP executable is in your PATH variable). Then go localhost:8000 and you should have your application running.
Running this command runs the PHP built-in webserver and saves you the trouble of configuring virtual hosts.
In your Apache's http.conf, find the DocumentRoot line and add the subdirectory /public on the end.
Once that is done and you've restarted Apache, you'll be able to access everything which is contained within your htdocs/public folder (including subdirectories of that folder), along with any routes you've defined in Laravel.
Laravel is designed to be set up this way as to protect the code and files by not having them in the folder which is served out to the web.
I have same issue and found that there are miss configuration in vhost. So that's are correct configuration.
in etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/laravel-master/public"
ServerName laravel.local
ErrorLog "logs/laravel-master-error.log"
<Directory D:/xampp/htdocs/laravel-master/public>
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
In the hosts file
127.0.0.1 laravel.local
I don't know if you're running L4 or L3. However, launch CLI and
$ cd ./path/to/project
Then for L4:
$ php artisan serve
For L3:
$ php -S localhost:8000 -t public
Now you can go to localhost:8000 and see your application.
You're having problem because the object really doesn't exist in your htdocs directory. You don't have to append xampp after localhost or 127.0.0.1 because xampp will treat it as an object or a folder under htdocs.
if you want to access your blog, make sure you have a blog folder under htdocs and put in your URL localhost/blog

Categories