Community

Forums » SEPHP Help and Tips

Instant SocialEngine on NGINX with Modern DevOps

    • 18 posts
    December 4, 2018 8:48 PM EST

    Just in time for the holidays, I've put together a project which I hope will be a gift for everyone. I've already asked a number of dumb questions here and probably will ask more, so I'm contributing this back to the community... Enjoy! I've licensed social-nginx as open source through an Apache license. Feel free to use it.

    I had a number of objectives:

    1. I wanted to run SE on NGINX
    2. I wanted to store my SE implementation in a version-control system
    3. I wanted my site to be instantly reproducible, including test versions, branches, rollbacks, etc.
    4. I wanted to be able to instantly run it on a cloud server, or on my laptop
    5. I wanted to support modern DevOps and Continuous Integration / Delivery.
    6. I wanted it to be able to easily scale in a cluster

    The first goal (NGINX) isn't directly related to the others, but I can say that SE is noticeably faster on NGINX.

    The result is social-nginx. Social-nginx is a Docker container that is configured to run SocialEngine on NGINX with PHP-FPM. It knows how to quickly set up a local database for super fast, super easy development and testing- or use an existing database connection in production. By storing my entire SocialEngine site, including the database, in a Github repository it is instantly reproducible from any branch or version. (Note: social-nginx is a public project. My SocialEngine site, however, is a private repository because, of course, SE is a commercial product). Because this is a docker container, it runs in the exact same environment on my laptop that runs on a cloud server or a cluster. No surprises! No environment changes that are only made in one place! No one-off server changes that I don't remember, having to figure them out all over again when I change things later. Docker brings huge benefits to developing and operating a modern web application.

    It's still rough around the edges, but I have this working. I can easily and effortlessly create a feature branch, launch my SE site on my laptop, make my changes (including adding plugins or themes), push changes to version control and test the changes in the cloud, then merge the branch into my main branch and redeploy my production server (there is still some work to fully automate everything, but I'm working on that). I can also give contract developers access, let them make changes in isolation, and review and test their changes before merging and deploying using the same workflow.

    In the Github repo, I've posted full instructions for testing this out yourself. Let me know what issues you encounter, or if you find this useful.

    Check it out! 
    https://github.com/TheTinkery/social-nginx

    Thanks!

    Eric


    This post was edited by Donna at December 5, 2018 5:13 AM EST
    • 59 posts
    December 4, 2018 9:09 PM EST

    Off to a good start!

    We use GitHub to push changes also to production servers also and a few other DevOps tools for our separate clusters. You have made a great contribution here!

    • 2607 posts
    December 5, 2018 5:14 AM EST

    Thanks for the post. We do have improvements coming for the development process as mentioned in your other thread. 

    I'm sure your GitHub will be helpful to others. Thank you for not including SE files in it. :)


    This post was edited by Donna at December 5, 2018 6:09 AM EST
    • 69 posts
    December 5, 2018 11:34 AM EST
    This is exciting.
    • 18 posts
    December 5, 2018 3:06 PM EST

    I just noticed the URL rewriting in the NGINX config isn't working - I must have changed something that affected that. I'll fix that!

    • 69 posts
    December 5, 2018 3:30 PM EST

    Not sure whether you want questions here or on the git. 

     

    step 14 when you mention copying the template out of /social-engine/site-template  , is this to the projects folder created in step 12 ? 

     

    is also step 15 and 16 to be extracted to step 12 folder? 

     

    Thanks 

    • 18 posts
    December 5, 2018 4:05 PM EST

    This is copying to the socialengine folder inside the project folder, creating a skeleton directory that is expected by the other parts of the script.

    So using the directory names I had it is the same as

    cp -R ~/se-nginx-test/social-nginx/site-template/. ~/se-nginx-test/socialengine/

    I was just using relative directories based on the current directory from the previous steps.

    • 18 posts
    December 5, 2018 11:08 PM EST

    I've updated the git repository (and docker image) with a few updates- primarily fixing the NGINX URL rewrite rules that stopped working.

    I've taken a narrow approach- most NGINX conf files for SE I've found are flexible about allowing external calling of PHP files. I've taken a different approach- I don't allow external calling of php files except where SE makes those calls. Currently I've only found one case of this- SE pages (or maybe my them) call css.php directly. So I carved out an exception for that. 

    So if something isn't working, and google dev tools how that you're getting a 404 on some php file, let me know and I can edit the nginx-site.conf to allow it.