Install Shopware on Ubuntu 18.04 with LAMP — Google Cloud
Install Shopware on Ubuntu 18.04 with LAMP on Google Cloud. In this article you are going to learn how to install Shopware on Google Cloud with Ubuntu 18.04 LTS, Apache, PHP 7.3 and use Cloud SQL for Shopware database.
Support
- You can hire me on Fiverr for $5 for professional Google Cloud services and WordPress website development
- Support me with $1 on Patreon to create more tutorials on Google Cloud and Wordpress
Originally published at https://www.cloudbooklet.com on June 4, 2019.
Prerequisites
- A running Compute Engine, see the Setting up Compute Engine Instance with Ubuntu 18.04
- Initial Ubuntu Server Set up.
- Install and configure Apache, PHP, see Install LAMP on Google Cloud.
- For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain
- A running Cloud SQL instance, see How to set up Cloud SQL in Google Cloud
Setup Installation Directories
Once you have LAMP setup completed and your domain name pointed to Google Cloud, you can proceed to setup web root directories for Shopware installation.
sudo mkdir -p /var/www/html/shopware/public /var/www/html/shopware/logs
Now, you have the directories created and ready to setup virtual host configuration.
Create Apache Virtual Host Config
First you need to disable the default virtual host configuration.
sudo a2dissite 000-default
Create new configuration.
sudo nano /etc/apache2/sites-available/shopware.conf
Paste the following in the file.
<VirtualHost *:80>
ServerAdmin admin@yourdomainname.com
ServerName yourdomainname.com
ServerAlias www.yourdomainname.com
DocumentRoot /var/www/html/shopware/public
<Directory /var/www/html/shopware/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/shopware_error.log
CustomLog ${APACHE_LOG_DIR}/shopware_access.log combined
</VirtualHost>
Hit Ctrl + X followed by Y and Enter to save the file.
Enable the configuration
sudo a2ensite shopware.conf
Enable Apache rewrite module
sudo a2enmod rewrite
Restart Apache.
sudo systemctl restart apache2
Setup Free SSL for Shopware
Now you can install SSL to secure your website.
HTTPS is a protocol for secure communication between a server (instance) and a client (web browser). Due to the introduction of Let’s Encrypt, which provides free SSL certificates, HTTPS are adopted by everyone and also provides trust to your audiences.
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install python-certbot-apache
Now we have installed Cert bot by Let’s Encrypt for Ubuntu 18.04, run this command to receive your certificates.
sudo certbot --apache -m youremail@email.com -d yourdomainname.com -d www.yourdomainname.com
Select all the domains you need to receive the certificate and hit Enter
The Cert bot client will automatically generate the new certificate for your domain.
Now you will be asked to create a redirection to https
Select the appropriate option and hit Enter
Renewing SSL Certificate
Certificates provided by Let’s Encrypt are valid for 90 days only, so you need to renew them often. Now you set up a cronjob to check for the certificate which is due to expire in next 30 days and renew it automatically.
sudo crontab -e
Add this line at the end of the file
0 0,12 * * * certbot renew >/dev/null 2>&1
Hit CTRL+X
followed by Y
to save the changes.
This cronjob will attempt to check for renewing the certificate twice daily.
Download Shopware
To download shopware navigate to the root directory and download the package for the official website.
cd /var/www/html/shopware/public
Download Shopware package. The current latest version is 5.5.8
sudo wget -O shopware.zip https://releases.shopware.com/install_5.5.8_d5bf50630eeaacc6679683e0ab0dcba89498be6d.zip
Extract the downloaded zip file.
sudo unzip shopware.zip
Now you are ready to install Shopware from your web browser.
Install Shopware
Now visit your website in the browser and select the language you would like to use and click Next.
Next is the system requirements check for Shopware. Click Next.
Accept the Terms and Conditions and proceed to Database configuration.
Configure database connections details with the Cloud SQL credentials.
- Database Server: IP address of Cloud SQL
- Database User: Username created in Cloud SQL
- Database Password: Password for the user.
- Database name: Select the database from the dropdown.
Click Next.
Click Start Installation to install Shopware.
Wait for the installation to complete and select the license you are going to use.
Configure your admin login credentials.
Now you have completed the installation and ready to use Shopware.
Conclusion
Now you have installed Shopware on Ubuntu 18.04 with Apache, PHP 7.3 and connected with Cloud SQL. You also secure the installation with free autorenewable SSL certificate from Let’s Encrypt.
Hope this helps to install Shopware on Google Cloud