Moss can configure and deploy any PHP application. If it's a WordPress site or the app uses a natively supported framework like Laravel or Symfony, just follow the guidelines you'll find in the corresponding documentation articles. In any other case, keep reading to learn how Moss can set up your PHP application πŸ˜€

Set up your web app

To create your PHP application head to the 'Add site' form and follow the steps below:

  • If you haven't done it yet, choose the server of your workspace that will host your web app.
  • Choose your preferred 'PHP' version as the programming language.
  • Choose 'Other' as the development framework.
  • Provide the name of the site on the server. The base path to the site on your server is /home/<site-user>/sites/<name>.
  • Provide the root domain of your website (e.g. your-site.com). Note that you must either own such domain or use one based on your server's IP address.
  • Choose the git repository that contains your application code. You may select whichever available repo from GitHub, GitLab, Bitbucket, or any other provider. You can also leave this field as 'None' and manage the deployment of your app on your own by means of any other mechanism.
  • Choose the database your application will use. If it doesn't need a database, you may select 'None' as the engine. Otherwise, you can either create a new MySQL database and user on the same server or use an existing database and user. Note that the latter may be hosted on any server of the same workspace - Moss will automatically set up the corresponding firewall rules πŸ˜€
  • Provide the server user that will run your website. Moss proposes one based on the name of your site, but you may create a different user or choose an existing one. If you have multiples websites on a same server, you can isolate them from each other by running them as different users.
  • Choose the SSL certificate that you'll employ for your site. You may tell Moss to generate a free Let's Encrypt certificate or provide your own. If you leave 'None' as certificate, your website won't be reachable through the HTTPS protocol.
  • Check the monitoring box if you want Moss to periodically check the health of your website and send you an alert whenever it's down. Usually you'll want to monitor your websites, unless they're for testing or similar environments.
  • Check the redirect www to root domain box if you want www.your-site.com Β to redirect to your-site.com.
  • Check the allow wildcard subdomains box if your application is served from subdomains like abc.your-site.com, def.your-site.com, etc. This option isn't compatible with Let's Encrypt certificates, so you'll have to own a certificate that allows wildcard subdomains or just get rid of HTTPS (something we don't recommend at all).
  • Check the push to deploy box if you want Moss to deploy your app whenever you perform a 'git push' on the repo and branch/tag you've provided.

In the 'Advanced' section you may also edit the following configs:

  • Choose the web server stack for your site. You can use Nginx on its own or Nginx as a reverse proxy in front of Apache.
  • Provide the root dir of your website. This is the path within your app that hosts the publicly accessible content of your website (e.g. index.php). E.g. if these files are within a public/ subdirectory, Moss will set up Nginx or Apache to serve your site from /home/<site-user>/sites/<name>/current/public.

Once you're done with the previous configuration, click the 'Add' button and wait until Moss finishes the process.

Moss shows the last completed step at any moment so that you can track the progress of the process.

Deploy your web app

Good, Moss has set up your web server to serve your application on the root domain you specified. Now you just need to deploy your app on the server to make it available to the world πŸ˜‰Β 

Moss supports zero-downtime deployments by allowing you to specify both pre-activation and post-activation scripts. Whatever you include within the pre-activation script will be run before your new release activates. During that time your previous release is the one being served by the web server. Usually such script updates your app's dependencies via composer and runs your database migrations. Please edit your deployment flow to provide an appropriate pre-activation script.

Once this script ends successfully the new release activates and becomes available to your users. At that moment, you may want to run a post-activation script to run commands that depend on the new version of your code. If don't need to run anything at this stage, just provide an empty script or leave it as suggested by Moss. Otherwise, please edit your deployment flow to provide an appropriate post-activation script.

If you want to manually deploy your app now, click the 'Deploy' button and Moss will start to work.

Alternatively, you may check the 'Push to deploy' option and force deployment by running a git push against the repo of your web application.

At any moment you can check the output of your latest deployment in /home/<site-user>/sites/<name>/logs/deploy/pre-activation.log and /home/<site-user>/sites/<name>/logs/deploy/post-activation.log.

Check your website is ok

Now it's time to open a browser and visit your site. If you cannot update DNS records at this very moment, you can add a domain alias to browse your website leveraging your server's IP address.

Otherwise, let's update your DNS records. Head to the 'Domain' tab and Moss will show you the records you must set up in your DNS provider. Such records make the canonical domain of your web point to the external IP address of your server.

Once DNS records have been propagated, and provided you're monitoring this website (only if your plan allows it), after a few minutes you can check that your site is globally reachable by heading to the 'Health' tab.

What's next?

Congratulations! Moss set up, deployed, and is monitoring your new web application πŸ˜ƒ . If your application also needs to process background jobs, you can configure them as workers with Moss.

Did this answer your question?