How create beta (testing) website? - php

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.

Related

Setting Up PHP Push/Pull With Ubuntu Server

Bear with me here ... I can't show exact examples or provide a link to the web server for security reasons. If anything more is needed I will gladly provide it.
What I HAVE:
I have a server that hosts an internal networked intranet for my company.
Coded with PHP, MySQL, HTML, etc
Ubuntu 14.04LTS
Normal Apache Web Server Configuration
Login access
Couple hundred PHP files for different pages/features needed for the company
Maintenance
FTP into the directories (shown below)
Manually edit PHP files with Notepad++
Test in Beta Directory -> move to -> Secure (overwriting current file there)
I know this procedure for maintaining is horrible so I'm trying to come up with a better solution
What I NEED:
Features
IDE Connectivity (Aptana,Eclipse,etc)
Commit/Push/Pull Capable with Server from IDE
Version Control
Keep backups for Rollbacks
Test & Main Server
Like how I have a Beta and Secure Directory for testing and releasing to everyone
What needs to be done on the Ubuntu Server in order to accept push/pull requests, store multiple versions, and store commit messages?
Do I need to install anything on the Ubuntu server in order to communicate with the remote computer I'm trying to access from?

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

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.

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.

Moving PHP site from one server to another

I have no idea about PHP.
I have PHP site hosted on Server A. Now I want to transfer the hosting to another company having Windows hosting on Server B.
Can I just transfer all the contents of WWWROOT folder of Server A to Server B? Will the site work that way? Or I do have to get the source, compile and publish it?
Thanks!
the process is this:
copy the content from server A to B (also db dump)
make sure your site is working on server B correct
set a redirect on server A to server B (usually in .htaccess file)
edit DNS entries to point to server B
wait that DNS changes have been picked up (note: as suggested by Emil you can reduce this time by lowering TTL setting on the DNS entries)
remove content from server A (end hosting)
PHP is not (usually) compiled, you should be able to simply copy the files and directories over and they should at least run. You may have to set up a database and connections to it, change some configuration in the scripts and you may or may not run into incompatibilities between different PHP versions and/or UNIX/Windows problems though, depending on how portable the scripts were written.
you don't need to compile anything. it's enough to copy project directory from one server to another. one thing can cause your project not working on ohter hosting, if there will not be installed some php-extensions that are required for you project.
and of course, if your project uses some databases, they must be created on new server
PHP scripts are source code and are compiled when needed. Simply moving the files is enough. Problems may occur if it is a package that has been isntalled on that server and may have some properties in various files about absolute paths to other files.
Also, issues will occur if the files are talking to a local SQL server or the such.
Many hosting companies offer a free (or sometimes payed) service to copy your website accross including any databases. Ask your hosting company for help.
No need to compile, however you have to make sure that the new server meets all the requirements of your application (e.g. server modules) and that paths are correctly configured. Also under some circumstances the PHP version can matter as well. Only one way to find out!

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