Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a development server

Tags:

php

When developing PHP applications, it's best to have a server you develop/test on, and then a live server you put everything once it's ready.

OK, but how?

If you are hosting through a hosting company how can you setup your own development server to test on that mimics all the LAMP settings as your live server? Because if they differ then testing on one that isn't identical to the live one, defeats the purpose right?

Is it better use another server through the same hosting company and ask them make both the development and live ones have the exact same settings?

Also what is the best work-flow to use to check files out from "live server" work on them in the "development server", then check them back into the live server?

Thanks!!

like image 836
JD Isaacks Avatar asked Feb 22 '10 20:02

JD Isaacks


People also ask

What is a development server?

A development server is a type of server that is designed to facilitate the development and testing of programs, websites, software or applications for software programmers. It provides a run-time environment, as well as all hardware/software utilities that are essential to program debugging and development.

How do I setup a local development server?

Install the LWC Local Development Server#Run sfdx plugins --core to see if the plug-in is installed. If yes, try to start the Local Development server. If successful, you're good to proceed. After you select SFDX: Preview Component Locally, the Command Palette displays a list of preview options.


2 Answers

Two points from my daily work:

  • XAMPP is your one-stop shop for setting up a Apache/mySQL/PHP stack on Windows. I develop with it and deploy to Linux machines, no problem.

  • If you want to set up a Linux environment on a home server or virtual machine, I asked a question a while ago that may interest you: Pre-installed Linux for Web Developers?

Is it better use another server through the same hosting company and ask them make both the development and live ones have the exact same settings?

If you can afford a second server, it may well be the best way to go. On the other hand, a local machine you could upgrade and fiddle around with at will, and all that at a fraction of the long-term cost of a second rented server. If in doubt, I would go for a local machine.

Don't forget PHP is a very portable language. If you don't use any specific command-line tools or totally exotic extensions, making a PHP application work across Linuxes, and even on Windows is a question of some settings and details, but not really a big deal any more.

Also what is the best work-flow to use to check files out from "live server" work on them in the "development server", then check them back into the live server?

There are many, many opinions and practices in this field. For me personally, the following workflow has turned out to be ideal wherever I've used it - I am still in the process of implementing this myself in all projects and for all clients.

  1. Edit files locally in IDE

  2. Upload to development server via built-in FTP function of IDE

  3. Test on development server

  4. Once a feature is tested and works on the development server (i.e. it's "finished"), check the whole package into a Subversion (or other) repository

  5. On the live server, have a build script check out the latest revision from the repository, download it to a directory with the revision number, and when finished, change a symbolic link that pointed to the previous revision to the latest one.

That way, every change you make to the live environment is logged in the version control system, and reverting to the previous revision is a question if seconds. To me, this was a huge relief compared to working with pure FTP everywhere.

Possibly also interesting question: Setting up a deployment / build / CI cycle for PHP projects

like image 92
Pekka Avatar answered Oct 28 '22 16:10

Pekka


You can check all the production server's setup via phpinfo() and copy them on your development environment, no need for them to be on the same provider.

I usually commit the code to source control, and checkout in the production environment, hiding all the repository information via .htaccess, for example, see here.

Another (less recommended) option is to just have your master source in the development machine, and once it's ready FTP it up, there are various free tools that will only upload changed files.

like image 34
Vinko Vrsalovic Avatar answered Oct 28 '22 17:10

Vinko Vrsalovic