Connect to the staging server

Connect to staging.ext.dev using your credentials.

Create a SSL certificate

We need an SSL certificate, so that the new staging website is accessible using HTTPS.

To do so please create a new certificate (make sure to replace {sitename} with the name of the site)

sudo letsencrypt certonly --webroot -w /var/www/html -d {sitename}.staging.ext.dev

This will issue a certificate for {sitename}.staging.ext.dev. The certificate will get renewed automatically.

Add apache configuration file

To have the Apache webserver respond correctly to requests made to {sitename}.staging.ext.dev we need to configure it. We create an apache configuration file 

sudo nano /etc/apache2/sites-available/{sitename}.staging.ext.dev.conf

and paste the following content:

<IfModule mod_ssl.c>
	<VirtualHost *:443>
		ServerName {sitename}.staging.ext.dev
		ServerAdmin [email protected]

		DocumentRoot /var/www/deployments/{sitename}.staging.ext.dev/current/public

		ErrorLogFormat "[%t] [%l] [pid %P] %F: %E: %M"
		ErrorLog ${APACHE_LOG_DIR}/{sitename}.staging.ext.dev-error.log 
		CustomLog ${APACHE_LOG_DIR}/{sitename}.staging.ext.dev-access.log "%u %t \"%r\" %>s %b"

		SetEnv TYPO3_CONTEXT Development
		SetEnv HOSTNAME {sitename}.staging.ext.dev

		SSLEngine on

		SSLCertificateFile      /etc/letsencrypt/live/{sitename}.staging.ext.dev/cert.pem
		SSLCertificateKeyFile /etc/letsencrypt/live/{sitename}.staging.ext.dev/privkey.pem
		SSLCertificateChainFile /etc/letsencrypt/live/{sitename}.staging.ext.dev/chain.pem

		<Directory /var/www/deployments/{sitename}.staging.ext.dev/current/public>
			AllowOverride All
			Options Includes FollowSymLinks MultiViews

			AuthType Basic
			AuthName "Login"
			AuthUserFile /var/www/.htusers
			SetEnvIfNoCase User-Agent .*Google Page Speed Insights* AllowedUserAgent
			# Define proceeding
			Order deny,allow
			Deny from all
			Require valid-user
			Allow from env=AllowedUserAgent
			Satisfy Any
		</Directory>



		<FilesMatch \.php$>
			SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost/"
		</FilesMatch>
	</VirtualHost>
</IfModule>

 

Enable and activate the new site

Tell apache to enable the new site

sudo a2ensite {sitename}.staging.ext.dev

To activate the new apache configuration we need to restart the Apache webesrver gracefully

sudo service apache2 graceful

 

Done

The new staging site is now live at:

{sitename}.staging.ext.dev

And will show content from the folder 

/var/www/deployments/{sitename^}.staging.ext.dev/current/public/

All that we need to now do is

  • configure automatic deployment, so that our code changes get pushed here 
  • copy the static files (fileadmin etc)
  • set up mySQL database
  • configure AdditionalConfiguration.php to use the database