We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Creating a staging site on a separate server

How Do I?

searchdusoleil's avatar
searchdusoleil
5 posts
4 years ago
searchdusoleil's avatar searchdusoleil

Hi, I am looking for some documentation that will help me take a staging copy of a clients site. They only have a live deployment and I need to make changes to some templates. Need to test and don’t want to break anything. Can anyone help, or point me in the right direction?

Thanks.

       
vw000's avatar
vw000
241 posts
4 years ago
vw000's avatar vw000

Are you planning to run this on a local server? Same server or separate server?

       
searchdusoleil's avatar
searchdusoleil
5 posts
4 years ago
searchdusoleil's avatar searchdusoleil

A separate server on my own hosting.

       
vw000's avatar
vw000
241 posts
4 years ago
vw000's avatar vw000

Well usually staging or development should be a mirror even in the server configuration if you want to do this right. That means same PHP versions, same web server configurations, etc. Best approach is cloning the whole server.

All you need to do is copy the files and the database to the new hosting. Then change the EE settings URL and config to match that domain (assuming it’s a new one or subdomain or something else) or update your DNS server for the staging site. And work on that second copy.

It’s not different to any other PHP-MySQL website. The process would be the same. You then just mirror the files and database with some sync tool from server to server. The approach can be as simple or as complex as you want, depending on what IDE you use, if you use a repository for files, etc.

It’s hard to make a specific guide as it depends on what tools you use and have available.

       
Andy McCormick's avatar
Andy McCormick
183 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

@searchdusoleil did you need any more help with this? thanks

       
searchdusoleil's avatar
searchdusoleil
5 posts
about 4 years ago
searchdusoleil's avatar searchdusoleil

Hi, and thanks for the prompt. I am changing approach here, and setting up a stage on the same server as the live site, but with a subdomain. I have copied over the files and database but get the message:

“Your system folder path does not appear to be set correctly”

In the live site in index.php it is set as

$system_path = ‘../control’;

Also, I’m not sure where to make the database configurations?

       
Andy McCormick's avatar
Andy McCormick
183 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

your system_path is where your system folder is located which comes as default with any EE installation. So in this case, if you do not have a system folder and you have one named control, it would seem that someone has renamed the system folder to be called control. This usually done to had a little bit of security (docs reference: https://docs.expressionengine.com/latest/installation/best-practices.html#renaming-the-system-directory.

Since your system_path starts with ../, that’s indicating that on the live server, the system folder is above the web root. A typical structure for this would look something like this:

├── public_html
|   ├── admin.php
|   ├── index.php
|   ├── images
│   └── themes
└── system

(docs reference: https://docs.expressionengine.com/latest/installation/best-practices.html#moving-the-system-directory-above-webroot )

the “system” folder and the “public_html” folder in the example above could be renamed to anything.

So for your site to work locally, you would need to ensure your local server is set the same way.

To learn more about this, you can see Doug’s video on EE:U https://u.expressionengine.com/course/getting-started-with-expressionengine-video-course/getting-started-with-expressionengine-moving-the-system-directory-above-webroot .

       
searchdusoleil's avatar
searchdusoleil
5 posts
about 4 years ago
searchdusoleil's avatar searchdusoleil

Thanks Andy, that all makes sense. My next question is can I use the same “control” folder for my staging site, or am I best to copy that, call it say “stage-control” and then edit my index.php to

$system_path = ‘../stage-control’;

Are there then further configurations within my system/control folder that I need to make? If this were a fresh install then the database would be empty and the wizard would make all the connections, but not sure where I make sure the files won’t point to the live database and change that?

       
Andy McCormick's avatar
Andy McCormick
183 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

No, I wouldn’t rename anything. Ideally, a local and staging site is an exact copy of the production site. Otherwise, you might run into issues in one environment and not the other.

For an EE2 site, database settings are in/system/expressionengine/config/database.php . For EE 3 and up, the configs are in system/user/config/config.php.

Note: In your case, replace system with control.

       
searchdusoleil's avatar
searchdusoleil
5 posts
about 4 years ago
searchdusoleil's avatar searchdusoleil

Because everything is above the web root, (at server root) I will have to copy the folder structure and have no choice but to rename? Unless I place everything on staging within the sub-domain folder - but then I might have issues with file structures and paths? For example, in the control/user/config/config.php file you mention above, there is an include -

include(APPPATH.”../../../app/config/env_config.php”);

…and within THAT file, another include -

include(‘env_database.php’);

It all becomes very complicated if I have to change the paths in files copied to different locations…

       
Andy McCormick's avatar
Andy McCormick
183 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

yes. setups like that can really complicate the process of having local and production environments. I would attempt to keep everything as close to production as you can. Seems like you’re going to have to change some things, but I would only change what you have to. If you’re using Git, you can git ignore the user/cong.php altogether and just have a local version. You can also look at setting up a Multi-Environment config in this article : https://u.expressionengine.com/article/creating-a-multi-environment-config-in-expressionengine-5

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.