<\/span><\/h2>\nEtherpad requires Node.js version 8.9.0 or higher, so in this tutorial, we will install the latest version of Node.js (at the time of writing this tutorial).<\/p>\n
Enable the NodeSource repository with the following curl command:<\/p>\n
curl -sL https:\/\/deb.nodesource.com\/setup_11.x | sudo bash -<\/pre>\nNow, you can install Node.js with the following command:<\/p>\n
apt install -y nodejs<\/pre>\nYou can verify the nodejs and npm versions by using the commands below.<\/p>\n
nodejs --version\r\nnpm --version<\/pre>\n<\/span>Step 4: Install and Configure MySQL<\/span><\/h2>\nA database server is one of the requirements to run Etherpad. You can install MySQL, which is a great open-source database server. Type the following command to install MySQL on your server:<\/p>\n
apt install mysql-server mysql-client<\/pre>\nOnce MySQL is installed on your server, you can use the commands below in order to stop, start, and enable the MySQL service.<\/p>\n
systemctl start mysql\r\nsystemctl stop mysql\r\nsystemctl enable mysql<\/pre>\nThe next command is optional, but recommended by us. You can run the command if you want to secure the MySQL server by disallowing remote root access, removing the test database, and setting a root password for MySQL.<\/p>\n
mysql_secure_installation<\/pre>\nWhen prompted, answer the questions below by following the guide.<\/p>\n
Enter current password for root (enter for none): Just press the [Enter] key, as no password is set by default.\r\nSet root password? [Y\/n]: Y\r\nNew password: Enter your password\r\nRe-enter new password: Repeat your password\r\nRemove anonymous users? [Y\/n]: Y\r\nDisallow root login remotely? [Y\/n]: Y\r\nRemove test database and access to it? [Y\/n]: Y\r\nReload privilege tables now? [Y\/n]: Y<\/pre>\nRestart the MySQL server so the changes will take effect.<\/p>\n
systemctl restart mysql<\/pre>\nNow you should be able to log in to the MySQL shell with the command:<\/p>\n
mysql -u root -p<\/pre>\nThen type the password you created above to sign on. Once you are in the MySQL shell, you can use the following command and create a database called etherpad_db<\/code> for the Etherpad application.<\/p>\nCREATE DATABASE etherpad_db;<\/pre>\nTo grant the user etherpad_user with full access to the etherpad_db run the command:<\/p>\n
GRANT ALL PRIVILEGES ON etherpad_db.* TO etherpad_user@localhost IDENTIFIED BY 'Str0n9Pas$worD<\/span>';<\/pre>\nNOTE:<\/strong>\u00a0Don’t forget to replace ‘Str0n9Pas$worD<\/span>‘ with a unique, strong password. Now you can use the flush privileges operation to reload the grant tables, after which you can exit from the MySQL shell.<\/p>\nFLUSH PRIVILEGES;\r\nEXIT;<\/pre>\n<\/span>Step 5: Download and Install Etherpad<\/span><\/h2>\nWith the following commands, you will create a new user called etherpad and switch to that user.<\/p>\n
useradd -m -s \/bin\/bash etherpad\r\nsu - etherpad<\/pre>\nRun the git command below and clone the etherpad repository.<\/p>\n
git clone git:\/\/github.com\/ether\/etherpad-lite.git<\/pre>\nAfter you successfully clone the etherpad repository, you can enter the etherpad-lite directory and run the bin\/run.sh<\/code> script to start Etherpad.<\/p>\ncd etherpad-lite\/\r\nbin\/run.sh<\/pre>\nEtherpad has now been temporarily started. To see the Etherpad home page you can open your preferred web browser and type your server’s public IP address with port 9001.<\/p>\n
http:\/\/server_IP_address:9001\/<\/code><\/pre>\nYou should be able to see the Etherpad home page.<\/p>\n
<\/p>\n
To stop the application, you can press ‘Ctrl+c’ in your terminal. The problem with this is that the service only runs temporarily – only while it’s open in your terminal session. In order to have the server persistently run, you need to create a service for it. This is explained in\u00a0Step 7<\/strong>.<\/p>\n<\/span>Step 6: Configure Etherpad<\/span><\/h2>\nFollowing this step from the article, you will perform some basic configuration of the Etherpad editor.<\/p>\n
Login to the etherpad user and enter the etherpad-lite directory.<\/p>\n
su - etherpad\r\ncd etherpad-lite\/<\/pre>\nOpen the settings.json<\/code> configuration file with your preferred text editor. In our example, we will use nano as the text editor of choice.<\/p>\nnano settings.json<\/pre>\nChange the IP address in the configuration file to ‘server_IP_address<\/span>‘, and optionally you can change the listening port to non-default. In our example, we will use the default port.<\/p>\n\"ip\": \"server_IP_address\",\r\n\"port\" : 9001,<\/pre>\nDisable the ‘dirty’ database which is the default in the configuration file by using the comment tags \/*<\/code> and *\/<\/code> as shown in the example below.<\/p>\n\/*\r\n\"dbType\" : \"dirty\",\r\n\"dbSettings\" : {\r\n\"filename\" : \"var\/dirty.db\"\r\n},\r\n*\/<\/pre>\nNow uncomment the MySQL database configuration and enter the MySQL information you created in the fourth step of this article.<\/p>\n
\"dbType\" : \"mysql\",\r\n\"dbSettings\" : {\r\n\"user\" : \"etherpad_user\",\r\n\"host\" : \"localhost\",\r\n\"port\" : 3306,\r\n\"password\": \"Str0n9Pas$worD\",\r\n\"database\": \"etherpad_db\",\r\n\"charset\" : \"utf8mb4\"\r\n},<\/pre>\nYou can enable the admin user by removing the comment from those lines and replace\u00a0Str0n9Pas$worD<\/code> with a password of your choice.<\/p>\n\"users\": {\r\n\"admin\": {\r\n\/\/ \"password\" can be replaced with \"hash\" if you install ep_hash_auth\r\n\"password\": \"Str0n9Pas$worD<\/span>\",\r\n\"is_admin\": true\r\n},\r\n\"user\": {\r\n\/\/ \"password\" can be replaced with \"hash\" if you install ep_hash_auth\r\n\"password\": \"Str0n9Pas$worD\",\r\n\"is_admin\": false\r\n}\r\n},<\/pre>\nOnce you have finished all the modifications, you can save the configuration file and exit.<\/p>\n
<\/span>Step 7: Setup Etherpad as a Service<\/span><\/h2>\nMethod 1: Systemd<\/h3>\n
In this step, you will configure Etherpad to run as a systemd service on your Debian 9 system.<\/p>\n
Run the following command so you can create a new service file named ‘etherpad.service’.<\/p>\n
cd \/etc\/systemd\/system\/ && nano etherpad.service<\/pre>\nThen paste the following configuration.<\/p>\n
[Unit]\r\nDescription=etherpad-lite (real-time collaborative document editing)\r\nAfter=syslog.target network.target\r\n\r\n[Service]\r\nType=simple\r\nUser=etherpad\r\nGroup=etherpad\r\nWorkingDirectory=\/home\/etherpad\/etherpad-lite\r\nEnvironment=NODE_ENV=development\r\nExecStart=\/usr\/bin\/nodejs \/home\/etherpad\/etherpad-lite\/node_modules\/ep_etherpad-lite\/node\/server.js\r\nRestart=always # use mysql plus a complete settings.json to avoid Service hold-off time over, scheduling restart.\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\nYou can then save the configuration file and exit. Use the command below to reload the systemd service list on your server.<\/p>\n
systemctl daemon-reload<\/pre>\nNow you can use the systemctl<\/code> command so that you can start and enable the Etherpad application easily and persistently. When the service is enabled, it will start automatically every time the system is booted.<\/p>\nsystemctl start etherpad\r\nsystemctl enable etherpad<\/pre>\nMethod 2: Init.d<\/h3>\n
If you prefer to use init, then you can create a new initial script with the following command.<\/p>\n
nano \/etc\/init.d\/etherpad<\/pre>\nPaste the following script.<\/p>\n
#!\/bin\/sh\r\n\r\n### BEGIN INIT INFO\r\n# Provides: etherpad-lite\r\n# Required-Start: $local_fs $remote_fs $network $syslog\r\n# Required-Stop: $local_fs $remote_fs $network $syslog\r\n# Default-Start: 2 3 4 5\r\n# Default-Stop: 0 1 6\r\n# Short-Description: starts etherpad lite\r\n# Description: starts etherpad lite using start-stop-daemon\r\n### END INIT INFO\r\n\r\nPATH=\"\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\/opt\/node\/bin\"\r\nLOGFILE=\"\/var\/www\/etherpad-lite\/etherpad-lite.log\"\r\nEPLITE_DIR=\"\/var\/www\/etherpad-lite\"\r\nEPLITE_BIN=\"bin\/safeRun.sh\"\r\nUSER=\"etherpad\"\r\nGROUP=\"etherpad\"\r\nDESC=\"Etherpad Lite\"\r\nNAME=\"etherpad-lite\"\r\n\r\nset -e\r\n\r\n. \/lib\/lsb\/init-functions\r\n\r\nstart() {\r\n echo \"Starting $DESC... \"\r\n\r\n start-stop-daemon --start --chuid \"$USER:$GROUP\" --background --make-pidfile --pidfile \/var\/run\/$NAME.pid --exec $EPLITE_DIR\/$EPLITE_BIN -- $LOGFILE || true\r\n echo \"done\"\r\n}\r\n\r\n#We need this function to ensure the whole process tree will be killed\r\nkilltree() {\r\n local _pid=$1\r\n local _sig=${2-TERM}\r\n for _child in $(ps -o pid --no-headers --ppid ${_pid}); do\r\n killtree ${_child} ${_sig}\r\n done\r\n kill -${_sig} ${_pid}\r\n}\r\n\r\nstop() {\r\n echo \"Stopping $DESC... \"\r\n while test -d \/proc\/$(cat \/var\/run\/$NAME.pid); do\r\n killtree $(cat \/var\/run\/$NAME.pid) 15\r\n sleep 0.5\r\n done\r\n rm \/var\/run\/$NAME.pid\r\n echo \"done\"\r\n}\r\n\r\nstatus() {\r\n status_of_proc -p \/var\/run\/$NAME.pid \"\" \"etherpad-lite\" && exit 0 || exit $?\r\n}\r\n\r\ncase \"$1\" in\r\n start)\r\n start\r\n ;;\r\n stop)\r\n stop\r\n ;;\r\n restart)\r\n stop\r\n start\r\n ;;\r\n status)\r\n status\r\n ;;\r\n *)\r\n echo \"Usage: $NAME {start|stop|restart|status}\" >&2\r\n exit 1\r\n ;;\r\nesac\r\n\r\nexit 0<\/pre>\nSave and close the file. Make the script executable by changing the file’s permissions, and enable it to start on boot.<\/p>\n
chmod +x \/etc\/init.d\/etherpad\r\nupdate-rc.d etherpad defaults\r\n\/etc\/init.d\/etherpad start<\/pre>\nYou can verify that the application is up and running on port 9001 with the following commands.<\/p>\n
systemctl status etherpad\r\nand\r\nnetstat -tunlp | grep 9001<\/pre>\n<\/span>Step 8: Setting up a Reverse Proxy<\/span><\/h2>\nBecause Apache and Nginx are one of the most popular web servers on the internet, in this step we will show you how to create a reverse proxy for them so that you can open the website containing Etherpad with a domain name. This additionally has the benefit of not requiring a port number to be specified in order to access Etherpad.<\/p>\n
We assume that you have already installed Apache or Nginx on your server. You can check the web server status with the commands below.<\/p>\n
For Apache2:<\/p>\n
systemctl status apache2<\/pre>\nFor Nginx:<\/p>\n
systemctl status nginx<\/pre>\nIf you have Apache2 installed on your server you can create a new virtual host configuration file so that you can access Etherpad application with a domain name.<\/p>\n
nano \/etc\/apache2\/sites-available\/domain_name<\/span>.conf<\/pre>\nadd the following content to the file:<\/p>\n
<VirtualHost *:80>\r\n ServerName domain_name.com<\/code> ServerAlias www.domain_name.com<\/code> ServerSignature Off <IfModule mod_proxy.c> ProxyVia On ProxyRequests Off ProxyPass \/ http:\/\/server_IP_address<\/span>:9001\/ ProxyPassReverse \/ http:\/\/server_IP_address:9001\/ ProxyPreserveHost on <Proxy *> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all <\/Proxy> <\/IfModule> <\/VirtualHost><\/pre>\nOf course, you will need to replace domain_name.com<\/span> with your actual registered domain name, as well as replacing server_IP_address with your server’s public IP address. Once you are finished with editing the configuration file, save the file and exit.<\/p>\nThe following Apache modules must be installed:<\/p>\n
a2enmod proxy\r\na2enmod proxy_http\r\na2enmod headers<\/pre>\nIn order to enable the virtual host you have just created, run the a2ensite<\/code> command:<\/p>\na2ensite domain_name<\/span><\/pre>\nFor the changes you made to take effect, you need to restart Apache:<\/p>\n
apache2ctl restart<\/pre>\nIf you have Nginx installed on your server, you can create a new server block so that you can access the Etherpad application with a domain name and no port number.<\/p>\n
Create the new etherpad server block with the command:<\/p>\n
nano \/etc\/nginx\/sites-available\/etherpad.conf<\/pre>\nadd the following content to the file:<\/p>\n
server {\r\n listen 80;\r\n server_name domain_name.com<\/span>;\r\n location \/ {\r\n proxy_pass http:\/\/server_IP_address<\/span>:9001\/\r\n proxy_set_header Host $host;\r\n proxy_buffering off;\r\n }\r\n }<\/pre>\nYou will need to replace domain_name.com<\/span> with your actual registered domain name, as well as replacing server_IP_address<\/span> with your server’s public IP address. When you finish with editing the configuration file, save the file and exit.<\/p>\nTo activate the etherpad virtual host you can create a symlink with the command:<\/p>\n
ln -s \/etc\/nginx\/sites-available\/etherpad \/etc\/nginx\/sites-enabled\/<\/pre>\nOnce that’s done, test the Nginx configuration.<\/p>\n
nginx -t<\/pre>\nBefore you start and enable the Nginx service, you need to make sure that there are no errors during the Nginx configuration test. If it all checks out, you can run the following commands:<\/p>\n
systemctl restart nginx\r\nsystemctl enable nginx<\/pre>\n