Setting up a development server

前端 未结 5 1799
梦谈多话
梦谈多话 2021-02-02 02:43

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 yo

5条回答
  •  甜味超标
    2021-02-02 03:07

    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

提交回复
热议问题