My PHP Dev Environment

Howdy!

Most of the sites I build are in PHP, built on top of WordPress or MediaWiki, as I can build these fairly quickly and host them cheaply, requiring minimal maintenance.

It took me a while to come up with a comprehensive setup, so I hope this helps someone in the future!

  • CodeAnywhere (Starting at $8/month)
    • Online IDE with included online dev server
    • No need to fiddle with a local dev server and it’s easy to edit any old projects even after getting a new laptop
  • CloudWays (Starting at $8/month)
    • Managed PHP Cloud Hosting with staging and tons of other great features
  • Github
    • Online Git repo. I use this both for backing up and as part of the deployment process.
    • Free for open source
    • $7/month for unlimited private repositories

How to configure these to work together. This tutorial is specifically for WordPress, but can be adapted for any PHP application, although DB and content migration might be more manual.

  • Cloudways:
    • Create a WordPress application
    • Create a staging application for the application
    • Connect your Cloudways Application to a Github repository
      • Follow step 1 of this guide on the STAGING application
      • Follow step 2 of the guide but READ THE MODIFICATION BELOW FIRST
      • Follow step 3 of the guide
      • Screen Shot 2019-10-19 at 11.20.46 PM
    • If necessary, enable elastic SMTP on your cloudways server
      Screen Shot 2019-10-19 at 11.58.37 PM
  • CodeAnywhere
    • File –> New Connection –> Github
    • Select the repo. UNCHECK “Autodetect Stack” before clicking next
    • Select “PHP Development Stack” (I use the Ubuntu one, but it’s your preference)
    • Right Click Project –> “Open SSH Terminal”
      • wget http://wordpress.org/latest.tar.gz
      • tar –strip-components=1 -zkxf latest.tar.gz
        • It is expected that you will get “Cannot open: File exists” and “Exiting with failure status due to previous errors” errors
    • Right Click Project –> “Info” –> Open phpmyadmin
      • User: root, Pass: empty
      • Create a database for wordpress
    • Load the sandbox ON HTTPS and go thru the install process
    • Add define( 'FS_METHOD', 'direct' ); to wp-config.php (needed for plugin updates to work)
    • Fix SSL issues: “Really Simple SSL” plugin
      • You will get a fucked up page while getting it set up
    • Install WP Sync https://wp-sync-db.github.io/
      • And wp-sync-db-media-files https://github.com/wp-sync-db/wp-sync-db-media-files
    • Install Better Search Replace https://wordpress.org/plugins/better-search-replace/
    • Submit any updates to git
      git add . && git commit -m “progress” && git push
  • Cloudways
    • Click “Start Deployment” then “Pull” on the staging server
    • Open the staging server site
    • Enable WP Sync DB and WP Sync DB Media Files
    • Migrate the DB to staging
      • Backup the existing DB
      • DISABLE REPLACE GUIDS IN THE ADVANCED OPTIONS
      • Migrate media too
      • Save the profile
    • Migrate DB and Save
    • Confirm the site is working correctly
    • Use the staging application tools in the prod app to migrate
      Screen Shot 2019-10-19 at 11.53.39 PM

Leave a Comment