Jump to content


Photo

Where should my project folder go ?

document root project folder

  • Please log in to reply
10 replies to this topic

#1 ajoo

ajoo
  • Members
  • PipPipPip
  • Advanced Member
  • 466 posts

Posted 21 February 2017 - 03:25 AM

Hi all !!
 

I have finally setup my ubuntu linux VM on Virtual box for web development. :happy-04:  

 

My document root is /vagrant/myproject.com/public. which is the same as /var/www/myproject.com/public. This is the directory structure by default if i understand correct. 

My project folder which contains the index.php and all other files and folders is in say a folder called Magical. 

 

Now I am supposed to place my project folder at this location: /vagrant/myproject.com/public/Magical. 

 

If I now type, http://myproject/magical in the URL, the index.php inside Magical is invoked correcty and displays the webpage. However this is rather odd and not in accordance with the manner websites are normally invoked. I would like to type, just like everyone else, http://Magical.com to invoke the index.php.

That would be like placing Magical in place of myproject in the folder hierarchy so that the document root is  /vagrant/Magical.com/public. That seems to go against the convention and the tutorial followed. The root folder should be below the public folder.  

 

So what should I do to rectifyy this ? Do I need to change some settings in the conf files or in the placement of my folder so that I just  type http://Macical.com to invoke the index.php ? Please help clarify.

 

Thanks all !

 



#2 kicken

kicken
  • Gurus
  • Wiser? Not exactly.
  • 3,184 posts
  • LocationBonita, FL

Posted 21 February 2017 - 05:13 AM

You need to use separate <VirtualHosts> for each domain you want to have. I do not use vagrant so I have no idea if you can configure multiple domains through it or if you'd have to edit the configuration files yourself.

You'd end up with something like this:
<VirtualHost *:80>
    ServerName magical.com
    DocumentRoot /vagrant/magical.com/public
</VirtualHost>
<VirtualHost *:80>
    ServerName myproject.com
    DocumentRoot /vagrant/myproject.com/public
</VirtualHost>

You'll also need to ensure that your magical.com and myproject.com resolve to the VM's IP so they connect properly. You can change your host's hosts file to change what the names resolve too. Rather than override actual domain names what I prefer to do is create .local equivalents. For example magical.local, myproject.local. That leaves me with the ability to visit the actual .com's if necessary.
Recycle your old CD's, don't trash them!
Did I help you out? Feeling generous? I accept tips via Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#3 ajoo

ajoo
  • Members
  • PipPipPip
  • Advanced Member
  • 466 posts

Posted 21 February 2017 - 06:54 AM

Hi kicken,

 

Thanks for the response.

 

Vagrant is just to set up a VM fast everytime. Once it's installed ubuntu and apache and the required software, it's role is almost over if one wants that. So it's just a ubuntu machine on a VM now. The only thing is that I get a shared folder /vagrant which maps to /var/www. i.e any changes I make to the folder /vagrant/myproject.com/public will reflect in var/www/myproject.com/public. Other than that I can configure the VM it as I like. 

 

So yes I have a virtual host configured exactly as you have shown. I have made changes to the hosts file on windows so that I can check out / try out the website on my host machine and it's working too. Yes I can create local equivalents of domain names but that's not really the issue. 

 

There is no index.html in public folder because my project, as I wrote earlier, is in a folder called Magical. Instead of putting an index.html in the public folder, I need to put my entire project in that folder. So it becomes /vagrant/myproject.com/public/Magical and to access the index.php in this Magical folder the URL becomes  - http://myproject.com/magical. - which is what is odd. What I am looking for is to make whatever changes needed and where ever so that when I type http://www.magical and that should access the index.php from the said folder and display the webpage. 

 

I hope I am able to clearly enunciate my problem. Thanks for the response and looking for some more help here.

 

Thanks loads ! 



#4 requinix

requinix
  • Administrators
  • Confusing Administrator
  • 8,307 posts
  • LocationWA

Posted 21 February 2017 - 07:09 AM

Then you need to change the configuration to use /vagrant/myproject.com/public/Magical as the document root instead. But can I assume you already thought of that?

#5 ajoo

ajoo
  • Members
  • PipPipPip
  • Advanced Member
  • 466 posts

Posted 21 February 2017 - 07:20 AM

Hi requinix,  

 

Thanks for the reply. 

 

You wouldn't be angry if i told you that I did?  :happy-04:. I did, But i thought that it was also convention  to have the public folder as the last in the document root. i.e. either public or public_html or html, because every search on google showed the document root to end in the public folder. So I thought it was mandatory to have the public folder there and so there was some mechanism for what I wanted. 

 

Just one thought then, what's the use of myproject.com in /vagrant/myproject.com/public. I would rather have /vagrant/magical.com/public/magical. Would that not be more logical and nicer? What do you say?

 

Thanks again ! 


Edited by ajoo, 21 February 2017 - 07:26 AM.


#6 requinix

requinix
  • Administrators
  • Confusing Administrator
  • 8,307 posts
  • LocationWA

Posted 21 February 2017 - 07:57 AM

Conventions are just guidelines. Personally I would make "magical" its own site at /var/www/magical.com but fact is it doesn't really matter. You could have spent the last 4.5 hours working on your site instead of trying to decide where to put the files.

#7 ajoo

ajoo
  • Members
  • PipPipPip
  • Advanced Member
  • 466 posts

Posted 21 February 2017 - 10:32 AM

Hi requinix,

 

I am at a stage where I really want to check whether my website is good for a server and therefore try it out in a real development environment or as close to it. So i have to know how to get my website up and running on a server. So it was important for me to know the where and how on a server. 

 

 

 

 

Personally I would make "magical" its own site at /var/www/magical.com but fact is it doesn't really matter.    

 

I think you mean I don't really need to have these two - /myproject.com/public/ -folders in between. Correct ?! Please affirm. i'll head back to get the site up.

 

Thanks ! 



#8 kicken

kicken
  • Gurus
  • Wiser? Not exactly.
  • 3,184 posts
  • LocationBonita, FL

Posted 21 February 2017 - 10:33 AM

Just one thought then, what's the use of myproject.com in /vagrant/myproject.com/public. I would rather have /vagrant/magical.com/public/magical. Would that not be more logical and nicer? What do you say?


I generally use /var/www/example.com/public_html as my document root format. That keeps it nice and organized by domain. Sub domains end up in a folder under the domain, eg sub.example.com would be located at /var/www/example.com/sub/public_html. I'll adjust the document root if it works out better as something else. For example on a Symfony based site I'd point the root to the web/ folder.

I don't really see the point in the extra /magical at the end of your example path, seems unnecessary.
Recycle your old CD's, don't trash them!
Did I help you out? Feeling generous? I accept tips via Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#9 ajoo

ajoo
  • Members
  • PipPipPip
  • Advanced Member
  • 466 posts

Posted 21 February 2017 - 02:19 PM

Hi kicken, 

 

Thanks for the reply.  :happy-04:

 

It's not that I see any point in the extra /magical folder at the end, it's just that I am trying to figure out where to place my project folder so that when I type magical.com as the URL, it should access the index.php of my project folder. . :confused:

 

All the examples that I came across just show a index.html inside the public folder. None showed how to handle a project folder that contained the index.html and the rest of the project folders and where to place that project folder.  

 

Please show me how best to place my website / project folder in the directory hierarchy so that it may access my project's index.php when I type magical.com in the URL 



#10 requinix

requinix
  • Administrators
  • Confusing Administrator
  • 8,307 posts
  • LocationWA

Posted 21 February 2017 - 03:29 PM

:suicide:
 

It's not that I see any point in the extra /magical folder at the end, it's just that I am trying to figure out where to place my project folder so that when I type magical.com as the URL, it should access the index.php of my project folder. . :confused:

The location of the site code on the server has absolutely no bearing on the domain name. You can put the files anywhere you want so long as you have your virtualhost config set up with the right ServerName and the right DocumentRoot.

#11 benanamen

benanamen
  • Members
  • PipPipPip
  • Master Coder
  • 1,245 posts

Posted 21 February 2017 - 05:37 PM

You could have spent the last 4.5 hours working on your site instead of trying to decide where to put the files. 

 

The Bike Shed Problem 

 

http://it.toolbox.co...d-problem-32923


To save time, let's just assume I am never wrong.

The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.


Make A Donation https://www.paypal.me/KevinRubio




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users