Multiple Website Environment: Virtual hosts vs All websites inside 'htdocs' - php

I am using MAMP in my Mac for local website testing.
Now, I've always set up multiple websites in the same root folder: 'htdocs'. Ex: htdocs>project1; htdocs>project2.
However I am reading about virtual hosts and how to use a different root for each website.
Is there any huge advantages of doing so apart from:
having a different url - ex: www.localhost2.example? (if localhost2 name is possible)
having a different database environment for each website? (although I typically use just one database per website and I don't mind having all databases in the same PHPMyAdmin)
What are the practical advantages?

It is a good idea for creating a test environment but it has pros and cons, If you're going to instantiate one vm per website then you will find resources problems when making them work all at once.
I usualy instantiate a virtual machine when a need to have a specific machine config for the web app (i.E. Linux specific software like WHMCS or so..), but for regular testing of websites I do deploy them on the localhost, they consume less resources that way.

Related

3 Magento Servers Migrated To 1 - Product Imagery

I recently started working for a company that sells a large amount of products online. As the business grew, instead of looking towards a more scalable solution for their hosting they have just added VPS instances with their hosting provider, created an SSH tunnel between the now three VPS machines to facilitate a local MySQL connection and assigned different domains to different VPS machines.
I've sorted out a large, scalable server that we're now migrating to and have setup the new server to be configured in the same way as the three VPS servers we have.
I had rsync'd the contents of one server's Magento installation down to my local machine, did some testing, changed some configuration options and everything works on the new server once uploaded. The issue that I'm having is that with some sites (there are around 15 spread across the three VPS machines), there are no product images.
I assume this is because Magento has put these product images in the file system of the server that domain is assigned to.
My question really is, is it safe to rsync the contents of ./media/catalog from each VPS server to the main server, or does Magento create a file-structure of its own and in doing that may overwrite things?
Hope you guys can point me in the right direction.
Cheers,
Dave
I work with a similar set up. We have a minimum 3 load balanced servers that operate from one database with an SSH tunnel.
You're right about where Magento is storing the images. When Magento creates images in /magento/media/ it will create two folders with the first two characters of the filename. eg a file named "Image1.jpg" uploaded to the catalog will go to:
/path/to/magento/media/catalog/i/m/Image1.jpg
Instead of rsyncing all the other servers back, we have set up our admin area to resolve directly to the main server, and rsync the media files from the main server out to the others every 5 minutes or so.
It's not a perfect solution by any means, but it works for us at the moment. We've looked at sharing a file system between the servers, but that has it's own drawbacks.
Hope this helps.

What is the simplest way to work on a project from different computers?

I have two computers that I use for development, one at home and one at the office. I use Aptana Studio 3 on both machines and would like to be able to easily work on a single project from both computers.
What are some easy ways to transport the project between computers. Right now I am just using a USB drive to transfer the files between computers.
Also, I'm using a local apache server on one computer, and a local IIS server on the other.
I think you should use something like SVN, GIT, Mercurial and so on. I suggest you this software to manage your project:
Tortoise
You might try connecting remotely (via Remote Desktop Connection for example) from home to the office computer and in this way you will only work on the office one and there will be no need for file transfer.
Alternatively, you can setup a source control server (by using SVN for example) and commit your projects to it. This way, you will be able to work on them from multiple locations.
if you have the opportunity to use a (virtual) server, and remote desktop from both computers, you won't come back to another solution. Overall with a server-side language like php, it's ideal, as you have your repository on your test web server (lamp/wamp) directly. That ensure ONE version for all your tools, easy and faster backups, synch, etc.
If I had no access to a virtual remote server, I would use github as an alternative, for the sake of code base security, and decent synch times. But I'm no expert on github.
Staging Environment
The best situation in your case will be to have a separate staging machine which is accessible to all three development machines. This can be another machine you control, one of the development boxes available to all of the others, or an external host - you can get a dedicated virtual machine from cloud providers for as little at $10/month, or if your project is simple enough use a plain web host even more cost-effectively.
Source Code Manager
A source code manager is a good start - SVN is common and free. Git is another and can even be set up to do remote deployments. These tools will give you two benefits:
Shared code between all environments, always up to date
Protection against data loss and error - if something major breaks revert to a working copy
File Synchronization
Finally, a tool like Dropbox can synchronize your files across all three systems as you make changes. Again, this one is free and can be installed on most operating systems.

How create beta (testing) website?

How create beta (testing) website use same webroot and cake folder ?
That beta (testing) website probably is at http://beta.example.com or http://example.com/beta
A method I have been using for a couple of years is to set up staging server instances. These could be either separate physical servers, or on the same server using hostname checks. However, it is good practice to have separate web roots and separate databases under each instance. You'll be asking for trouble if different aspects of your site are shared between staging instances!
My setup is the following:
Development (a computer with the source code on, set up to serve to http://websitename.dev (a local domain).
Preview (a separate server, used to provide a preview of a website or a change to a website, before doing the extra work to putting it live). http://websitename.preview.mycompanyname.com
Next (this is on the same server as the live website, under a different web root, and connected to a different database. The reason for this server is because SO MANY TIMES has a site worked on the development machine, but when it is put live, something on the live server makes the site DIE. http://websitename.next.mycompanyname.com
Live (the usual live server setup) http://websitename.com
This is all achieved by assigning DNS records correctly (to point to the correct servers), and using the config script of my web server application, listening to the hostnames and serving the correct web root.
A testing or "staging" server should be set up completely independently of the production server. You should not reuse any component of the live system, which even includes the database. Just set up a copy of the production system with a separate database, separate files, if possible a separate (but identical) server.
The point of a test system is to test code that is possibly buggy and may delete all your live data, shoot your dog and take your lunch hostage. Also, your test system may not be compatible with the production system, depending on what you're going to change down the road.
As such, create a new virtual host in your Apache config (or whatever you're using) and set it up exactly like the production system. Done.

What is the best development environment for Drupal to be able to move it to a different server at go live?

When i've worked on Drupal sites before, if there is internal access to the server, or if remote desktop access is available, i've always developed it on the machine it would be ran from when live, and just not made it public on the server.
However, what is the best thing to do if you don't have access to the server yet, for example if the client hasn't got anything in place?
I need to be able to build and test the solution on my local machine, or on my VPS which I have RDP access to, and be able to move it over with as much ease as possible to the clients server when ready.
Any tips or best practices? As far as i'm aware Drupal doesn't have any specific migration tools? I could be wrong though
I don't work with Drupal, but for Prestashop, Wordpress, Zencart, etc. I always use the same workflow:
I setup a vhost in my virtual sever, usually using a subdomain of my own domain (like customer.mydomain.com). Install the software with its DB etc. on the server. Setup FTP access.
I get a local copy of the files, which I maintain in a local git repository, pushing to github for backup purposes mainly.
I work with ZendStudio and configure a remote server and set it up to upload the files when I save them, so I can check them pretty much as if I were working locally. But the main advantage of this approach is that I can share the project with the customer as it progresses.
When I have to move to final server, at least with Wordpress, I have to search/replace the domain name, which wordpress saves on DB. But I do it locally. I download the entire DB as an SQL file through phpmyadmin, open it, searc-replace and upload it again via phpmyadmin to the permanent server.
With ZenCart and others the problem is the config file, which stores some paths. For long projects or long term customers I modify the config file to use some config details or anothers depending on the server name.
adding to the above comment...
Check the "backup and migrate" module and the "backup files" module. "Backup and migrate" is useful in any setup...
with this I was able to do a barebones drupal install and then migrate/replace the database with the one backed up from my local system... if the databases are named differently you will still need to edit the settings.php
"backup files" is useful for themes and content assets like images etc. but is essentially just a wrapper around gzip
I typically develop on my local machine and then upload to server once complete.
All you need to do is change the folder name in /sites/ and change the settings.php file to reflect the server settings/domain.
Something you should be aware of:
If you are uploading files on your local installation, the file paths will be wrong on the server and you will need to execute a one off mysql replace query.
Make sure you use relative paths in any hard coded links.

MagentoCommerce development environment domain issue

I am working on a ecommerce based on MagentoCommerce. I use 3 environments: dev (on my local machine), staging and production (both on my dedicated server).
The problem is that when I want to switch from local to staging, I have to edit my hosts file to point the domain used by Magento to my server's IP. However, this is time consuming and I was wondering what other magento developers out there were using as a strategy to not always have to change the hosts file when switching from an environment to another. Plus, when my ecommerce goes into production, I'll have to deal with 2 environments on the same IP.
The best would be if Magento had the domain hardcoded in only one file. That way I could keep different config files in each environment. Is that the case ? Otherwise, what places are domains "hard coded" ?
I'm running Magento on a Production server and a number of development and test domains.
The domain isn't hardcoded in any file - the domain is all in the database.
You have to change the secure base url and the unsecure base url when you move from server to server. Both of these are stored in the database and can be changed in the web based administration screens. When moving the database from one host to another, I use a script that does little but update these values. Here's the SQL you need to update these values:
update core_config_data
set value='http://whatever.com/'
where path='web/unsecure/base_url';
update core_config_data
set value='https://whatever.com/'
where path='web/secure/base_url';
You may also want to pay attention to the local.xml file where the database connection is configured. I'm sure that you'll want to have the different instances using different databases. In my configuration, I leave this file out of source control, and configure it just once for each instance.

Categories