DocumentRoot for PrestaShop - prestashop

In tutorials, I have seen prestashop installed in at least three different DocumentRoot's:
/var/www/html/
/var/www/html/prestashop/
/var/www/html/prestashop/public_html
Is there any logical reason to prefer one location over the others? In my case, there is an Apache server and I will have two different websites (two domains).

/var/www/html is the default directory for apache default config.
Prestashop is meant to be used at the web root, so no matter what you choose you must adapt the apache configuration to match the directory where prestashop actually is.
That being said, you should go for /var/www/yourdomain.com or /opt/website/yourdomain.com (I think it fits more the File Hierarchy Standard).
People sometimes use /var/www/domain.com/public_html so they can put some private content in /var/www/domain.com that can be used by their website but is not facing the web.
Do use nested subdirectories if you don't have a reason for it. Go for the most straightforward way.

Related

What determines where the browser starts looking for pages?

Sorry if I used the wrong terminology, I'm really new to web development/server stuff outside of Wordpress. I just made a DigitalOcean server and followed a bunch of tutorials to get it setup. I got my LAMP stack setup, but I got to the point in the tutorial where I created a quick php page and added it into /var/www as info.php. But when I go to my server IP/info.php, it couldn't find the page. It was only able to find the page when I moved it inside of /var/www/html which also contained index.html. My question is, what makes the browser/server look inside of html for files instead of /var/www?
My best guess is some apache config file that I'm not familiar with but I really have no idea.
Look in your apache httpd.conf file, most likely in /etc/httpd/conf on your server, for this command:
DocumentRoot "/var/www/html"

mod_proxy to another directory / user in the same server?

I currently have a small team (2 people) working on project one of my site:
http://www.example.com/one/
I want to be able to assign more teams to future projects, such as team 2 for project two:
http://www.example.com/two/
It's sort of like how big corporate sites such as Microsoft.com is being built and managed, different sub-directory (projects) for different teams. Each of the teams has the privileges to run and manage their own project as a sub-directory of the root domain.
After some searches, I came about the mod_proxy module of Apache. It seems a perfect fit. However as I currently only has one team, or there might be other projects for more teams but the overall traffic is not so much as to need a whole new other server, my question is, how to relay the requests to another directory in the same server?
I know I can just set up different directories under different users but I want to be easily scaling out when the traffic actually takes off so I'd prefer using mod_proxy for this because I can actually add more servers when I need to.
ProxyRequests Off
ProxyPass /foo http://internal/bar
ProxyPassReverse /foo http://internal/bar
Wherein internal/bar is located at /home/team1/public_html
Is this possible? How to make this happen?
Or as per my need, is there any way that's fundamentally better than the mod_proxy approach?
There are a few ways to do this but you probably don't have to use reverse proxy unless your keen on having the projects on different ports/host names and don't want the user to know. Other wise just use Alias
If using mod_proxy you would want to put the reverseproxy directives in a www.example.com vhost entry, you could also specify a document root for it. Then setup more vhosts for each of your projects, e.g. one.example.com. Each vhost can have a different DocumentRoot specified. Note you could accomplish something similar to reverseproxy via Redirect permanent however this would require a dns being setup for the subdomains. With your mod_proxy solution you can just add the subdomains to the hosts file.
Use one of the methods mentioned here: https://httpd.apache.org/docs/1.3/urlmapping.html
Alias directive, ScriptAliasMatch, User Directories with AliasMatch

What's the directory structure should be for multiple domains under a single user? (apache)

I have an account on some VPS(friend's apache server with cPanel) and there I have one public_html directory.
We have in there about 5-6 websites:
/home/myusername/public_html/domain-1.name/index.php
/home/myusername/public_html/domain-2.name/index.php
but I don't like this way, I'd like to orginise it better and be able to separate and isolate some stuff for each website.
So what if I create like that:
/home/myusername/websites/domain-1.name/public_html/index.php
/home/myusername/websites/domain-2.name/public_html/index.php and so on
Would it be a correct way of structurising web directories?
And would apache work like that?
Perhaps there are out there some other conventions or common workarounds?
Thanks
This is perfectly fine. In fact I'd highly recommend against using the domain folder as the document root as typical web application will also contain data that is not publically accessable (e.g. configuration files, management scripts, version control files, etc.)
Personally I prefer the name htdocs and I keep my sites under /srv/http
For example:
/srv/http/user1/domain1/htdocs/
/srv/http/user1/domain2/htdocs/
/srv/http/user1/domain3/htdocs/
/srv/http/user2/domain4/htdocs/
/srv/http/user3/domain5/htdocs/
That way you can set the DocumentRoot to the htdocs directory and put other stuff that is not meant to be delivered by the web server in a different sub directory of the domain directory.
Ok, I want just to conclude and to outline the way I went with.
Thanks to #bikeshedder for ideas!
So having a single account(none-root) /home/myusername/ under linux VPS server, I didn't want to abstract completely from existent directory structure, but at the same time I wanted to create proper environment to isolate and separate clients and their spaces.
Main goals were:
* The new directory structure should help to keep all files and folders in a nice and clear order.
* Easy to navigate and browse.
* Each developer or client would have access only to their space.
The structure:
/home/myusername/http/client-1/domain-1/public_html/index.php
/home/myusername/http/client-1/domain-1/resources/
/home/myusername/http/client-1/domain-1/configuration.php
/home/myusername/http/client-1/domain-2/public_html/index.php
/home/myusername/http/client-1/client's_resource_dir/
/home/myusername/http/client-2/domain-3/public_html/index.php
/home/myusername/http/client-2/domain-3/subdomain/public_html/index.php
As result:
* We have isolated client's space and isolated domain space. That makes enough room for any type of web projects.
* Files and dirs are not mixed up with other projects, domains and clients anymore.
* For subdomain paths it can be
- as subdirectories /domain-3.name/subdomain/public_html/
- or additional subdomain directory /subdomain.domain-3.name/public_html/depending on requirements or size of subdomain website.
* Public_html is going to be a DocumentRoot for each website.
I did not go for srv/ and var/www dirs, cuz to me it sounds like server in the server and also I don't feel variable data var/ in current setup falls under web stuff.
Though it may make sense for our coming soon local web/file sharing server
But here now I have another question:
How would I specify new path to be a default one for cPanel? and only for my user?
Cuz now there is going to be multiple DocumentRoot directories in one user space.
Is that possible by Apache design?
I better create new question :) And then will edit my question with answer
Any suggestion welcome!
Normally go with this once hosting from 5-30++ sites, depending on complexity of content, traffic, perceived future migration strategies to more dedicated virtual or bare metal servers/instances.
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<#|subdomain|www|others>/assets/...

How do I set up virtual host directories for sub-subdomains same as subdomains?

I currently use mod_vhost_alias with a wildcard ServerAlias to catch all subdomains for the domain I use to hold development versions of websites.
This works great, but I reach an issue when I need to test websites that have 'm.' subdomain flexibility for mobile versions. In a live environment, this subdomain would still use the same directory as the normal domain, but I am unable to achieve this in development.
Example:
website.devdomain.com goes to /var/www/website.devdomain.com, and m.website.devdomain.com goes to /var/www/m.website.devdomain.com, but preferably this should go to /var/www/website.devdomain.com
Is there a way to make sub-subdomains go to their parent's directory? The current VirtualDocumentRoot snippet I use is VirtualDocumentRoot /var/www/%0/
I can create custom document roots on a per-site basis to achieve this, but if there is an automated way with VirtualDocumentRoot it would be much more practical.
I used to have the same problem, and found a simple solution: Symbolic Links!
If you're using a Linux system, you can create a symbolic link from your mobile document root to your main document root, like so:
ln -s /var/www/example.com /var/www/m.example.com
If you're on Windows, the solution is a little trickier, since Windows doesn't have an easy symlink command.
mklink /D C:\var\www\m.example.com c:\var\www\example.com
Note that the Windows version parameters are backwards from the Linux ones; Go figure.

Configuring Drupal to work with an existing webapp

I have an existing web application which I have been building with an ant script and deploying as a .war file to Tomcat.
I am trying to add Drupal to my current technology stack to provide CMS and general UI-related functionality so that I don't have to write my html pages by hand and rather use templates.
During the installation of Drupal7, some of the instructions suggest that I go to this directory:
/etc/apache2/sites-available
and change the DocumentRoot to
/home/myuser/drupal/drupal7
If I make the docroot a basic directory on the file system, how will this impact how the application will work? In addition to Apache, I also have Tomcat server. My goal is to get them to all play nice together. How is this best accomplished?
If I make the docroot a basic directory on the filesystem
I'm not sure what you mean by this. There's no qualitative difference between /var/www and /home/mysuser/drupal/drupal7. The latter is longer and in the user's home directory, but assuming this user would be administering the service anyway that doesn't matter.
Next, the best way to make Tomcat and Apache get along is probably to run one of them on different subdomains. You could use the same domain, but that'd mean you had to run one of the daemons off a nonstandard port and that looks strange and might run into firewall trouble with some users.