Deploy
These instructions describe installing JuxtaPage on a Google Cloud Virtual Machine Instance. If using another cloud provider, apart from setting up the Virtual Machine, the rest of the instructions should be similar.
Checklist
- Create Virtual Machine
- Install Linux Dropbox client
- Install JuxtaPage
- Install Runcertbot
Detailed Instructions
Create Virutal Machine
In your Google Cloud Platform account, navigate to "Compute Engine" then select "Create Instance".
You will need to modify the Boot disk settings - select Ubuntu 18.04 LTS Minimal.
Also under the Firewall settings check the "Allow HTTP traffic" and "Allow HTTPS traffic".
The rest of the defaults that are provided will be sufficient, but you might want to select a region that is closer to you and a cheaper machine type. I find the micro is more than enough to start with, and you can easily upgrade the VM later.
See image of an example configuration.
Install Linux Dropbox client
Note, this is only required if you intend to use Dropbox to synchronise websites to your JuxtaPage server.
In your home directory, download and decompress the Linux Dropbox client.
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
Next, you will need to associate the Linux Dropbox client with an account. The following will run the Dropbox client, which will display a URL that you can use with a web browser to connect this machine to a new or existing Dropbox account. Once the account is connected, press Control + C to stop the dropbox client.
.dropbox-dist/dropboxd
Once the account is linked, press control and C to terminate the dropbox daemon.
CTRL + C
So that Apache can access the content in the Dropbox directory, you will need to change its file permissions:
chmod 0755 Dropbox
Finally, create an '/etc/rc.local' file that will start the Linux Dropbox client at boot as your user account. Warning, these instructions overwrite the '/etc/rc.local' file. First, confirm that the file is empty using the following:
cat /etc/rc.local
export username=`whoami` export userhome=~ sudo username=$username userhome=$userhome bash echo -e '#!/bin/sh -e' "\n\n""su - $username -c $userhome/.dropbox-dist/dropboxd &""\n\n""exit 0" > /etc/rc.local chmod 0755 /etc/rc.local exit
Install JuxtaPage
The following commands can be used to install JuxtaPage. First, in your home directory, download the JuxtaPage archive file. Second, change to, and then extract that archive into /srv. Finally, a symbolic link is created that maps from latest to the installed version.
cd ~ && wget https://juxtapage.org/resources/downloads/JuxtaPage-latest.tar.bz2 cd /srv sudo mkdir JUXTAPAGE cd /srv/JUXTAPAGE sudo tar jxvf ~/JuxtaPage-latest.tar.bz2 cd /srv/JUXTAPAGE/JuxtaPage sudo ln -sf * latest
A '/srv/JUXTAPAGE/Sites' directory is created that will contain websites. This may either be a normal directory, or it may be a symbolic link to a Drobox directory. See above for detailed instructions on setting up Dropbox on Linux.
Standard directory
sudo mkdir -p /srv/JUXTAPAGE/Sites
Dropbox link
sudo chmod -0755 /home/[account]/Dropbox ln -sf /home/[account]/Dropbox /srv/JUXTAPAGE/Sites
If they have not yet been installed, the following commands will install Apache, PHP, and the required PHP modules.
sudo apt update sudo apt install apache2 sudo apt install php libapache2-mod-php php-mysql
The following will enable the Apache modules that are required if they are not already enabled:
sudo a2enmod expires sudo a2enmod headers sudo a2enmod rewrite sudo a2enmod ssl
Once Apache is installed,
you will also need to edit the '/etc/apache2/apache2.conf' file to enable the '/srv' directory.
Uncomment the following by removing the '#' characters:
#<Directory /srv/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory>
sudo apt-get install nano sudo nano /etc/apache2/apache2.conf
Only if you want to enable the execution of versioned php files such as ".php3" within your resource directory to generate CSS and javascript resources, you will also need to edit the "/etc/apache2/mods-enabled/php7.2.conf" (or similar) file. The bold sections below defined the regular-expressions that are used to match the file names that are considered to be PHP files.
{FilesMatch ".+\.ph(p[3457]?|t|tml)$"} SetHandler application/x-httpd-php {/FilesMatch} {FilesMatch ".+\.phps$"} SetHandler application/x-httpd-php-source # Deny access to raw php sources by default # To re-enable it's recommended to enable access to the files # only in specific virtual host or directory Require all denied {/FilesMatch} # Deny access to files without filename (e.g. '.php') {FilesMatch "^\.ph(p[3457]?|t|tml|ps)$"} Require all denied {/FilesMatch} # Running PHP scripts in user directories is disabled by default # # To re-enable PHP in user directories comment the following lines # (fromto .) Do NOT set it to On as it # prevents .htaccess files from disabling it. {IfModule mod_userdir.c} {Directory /home/*/public_html} php_admin_flag engine Off {/Directory} {/IfModule}
Configuring Websites
Note: for now it is recommended that you run these scripts manually, however, instructions for setting up cron is below.
Run the 'generate_apache_configuration.sh' script to generate any required Apache configuration files for websites shared into ~/Dropbox.
sudo /srv/JUXTAPAGE/JuxtaPage/latest/juxtapage/cron/generate_apache_configurations/generate_apache_configurations.sh /srv/JUXTAPAGE/Sites /srv/JUXTAPAGE /etc/apache2
You will need to run 'sudo service apache2 restart' after 'generate_apache_configuration.sh' in order to activate the generated configuration file.
Setup Crontab
To setup cron, edit the 'root' account's crontab so that the 'generate_apache' script is run periodically.
Note: when run from cron you must explicity specify the fully-qualified path of the Sites directory.
sudo crontab -e
Enter the following two lines into the crontab file - Make sure you replace [username] with your Virtual Machines account name.
* * * * * /srv/JUXTAPAGE/JuxtaPage/latest/juxtapage/cron/generate_apache_configurations/generate_apache_configurations.sh /srv/JUXTAPAGE/Sites /srv/JUXTAPAGE /etc/apache2 >> /var/log/juxtapage.log
Reboot
Finally, reboot the Virtual Machine, so that the Linux Dropbox clients starts again.
sudo shutdown -r now
Install Cerbot
Please following the instructions at the following website to install 'runcertbot', which is a convenience cron script that will automatically use certbot to generate SSL certificates.