Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

General questions about development, hosting (Apache) and deployment practices

Options
  • 16-09-2012 7:59pm
    #1
    Closed Accounts Posts: 27,857 ✭✭✭✭


    Hey folks,

    This post turned into a very, very long one, so sorry for that! :D If you wanna skip to the bullet points, maybe you can answer them rather than reading through everything. BTW if anyone has any ebooks that they'd recommend for this stuff, let me know!

    So I've just made the exciting move from shared hosting to my very own VPS courtesy of Blacknight :D I mainly got the VPS because I want/need to get my hands dirty working with a server of my own, play around with Apache, cron, shell scripting, and stuff of that nature. I'm a PHP/MySQL developer with a small bit of experience, but never really had much need to get into the hosting side of things so far. So really while I'm okay navigating around a Linux machine and using the command line, I'm coming to Apache and hosting with virtually no prior knowledge!

    Anyway, what I'm interested in now is:
    1. Establishing and following best practice for maintaining an Apache server with multiple websites hosted on it
    2. Establishing a solid and sensible workflow that allows me to develop and test sites locally, and then deploy them to a live server

    1. I'm aware that some developers walk into a company and have to deal with a server that has been updated and maintained by multiple previous developers of varying competencies, and it can end up being a bit of a mess. Given that I'm starting off from scratch here, I'm wondering what things I need to consider when hosting a site on the server, so that I can set off on the right track from the start. Similarly, rather than working with whatever mess was there when I start at a company, I'd like to have some idea of how I would go about cleaning things up.

    For example, 2 questions that popped up today:
    • I put a site live as a test today, and to do so I added a new VirtualHost within /etc/apache2/sites-available. However I'm wondering is it standard to create a separate file for each site, or should I be trying to keep it all within /etc/apache2/sites-available/default ?
    • Does it matter where on the server I host the files, is there an advantage to doing it a particular way? Currently I'm just going with /var/www, which seems sensible. I've seen others suggest using /home instead.


    2. My current setup is pretty old school and not sustainable in any way! I'm on a Windows machine...
    • I use XAMPP to run a local Apache server, so any new sites I do I stick them in C:/xampp/htdocs/newsite.ie
    • I don't really use version control, or if I do I'll push it to my GitHub account, which is public
    • I FTP the sites up to the shared hosting I have with Blacknight
    • If I'm replacing an existing or old site, I'll have the old site up locally in some stupid way like _newsite.ie_BAK_16092012

    I'd like to move to a more robust system whereby I would keep everything under version control locally, push it to a remote repo on my server, conduct automated testing, and deploy code using a tool like Capistrano instead of FTPing it up, etc. Where do I start with this?! What's your current setup, or a well regarded one?

    And I have a couple of questions from what I encountered today:
    • If there is a current website -- say a "coming soon" page even -- and you're replacing it with a new one, where do you keep the old one? And how do you 'archive' it? Keep it in a separate Git branch maybe?
    • If you're working on a site locally, using a local database, and you want to push it up to a live server, it'll often have different database details. How do you deal with this without having to change them every time? The way I've done it before would be to check if the host == 'localhost', and use different DB details depending. But if for example I'm working on a Wordpress site, I'd ideally like to avoid editing the config files from the original structure/layout. Is there a better way?
    • I should be using a staging server before pushing to the live server I presume. I won't be doing this for now, but would this just be a separate VPS which matches the production server as closely as possible?

    Thanks!

    Dave


Comments

  • Registered Users Posts: 342 ✭✭adm


    the kohana framework (and others) has a nice way of checking if you
    are in development , staging or live mode:

    Put this line in .htaccess file
    SetEnv KOHANA_ENV "development"
    


    Then in config files you can check for it:

    [PHP]if (isset($_SERVER))
    {
    Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER));
    }


    //Kohana::$environment is now Kohana::DEVELOPMENT

    if (Kohana::$environment === Kohana::DEVELOPMENT){

    ....

    } [/PHP]


    You can adapt this method. Then you dont change the php code - just the .htaccess files


    In general:
    use yum
    consider a nice and easy web-based control panel such as webmin


Advertisement