Quantcast
Channel: Websetnet
Viewing all articles
Browse latest Browse all 4268

How to install Hackpad on a CentOS 7 VPS

$
0
0

In this tutorial, we will explain how to install Hackpad on a Centos 7 VPS with nginx as a reverse proxy. Hackpad is a web-based real-time wiki, based on the open source EtherPad collaborative editor. This guide should work on other Linux VPS systems as well but was tested and written for a Centos 7 VPS.

Login to your VPS via SSH

ssh root@vps

Update the system and install necessary packages

[root]$ yum -y update
[root]$ yum install git wget

Create a new system user

Create a new user for the Hackpad:

[root]$ adduser \
   --comment 'Hackpad User' \
   --home-dir /home/hackpad \
   hackpad

Install Oracle JDK 7

Hackpad requires JDK 7. Use the command below to download the latest Oracle JDK 7 from the command line using wget:

[root]$ wget --no-cookies \
    --no-check-certificate \
    --header "Cookie: oraclelicense=accept-securebackup-cookie" \
    "http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.rpm" \
    -O jdk-7u80-linux-x64.rpm

Once the rpm package is downloaded, install it with:

[root]$ yum install jdk-7u80-linux-x64.rpm

To check if JAVA has been properly installed on your CentOS box run java -version, and the output should be similar to the following:

[root]$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Install Scala

To download and install the latest scala version from the official website, run:

[root]$ wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.rpm

Once the rpm package is downloaded, install it with:

[root]$ yum install scala-2.11.7.rpm

Now if you run scalac -version, you should get something like this:

[root]$ scalac -version
Scala compiler version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL

Install MariaDB

MariaDB 5.5 is shipped in the default CentOS 7 repository, to install it just run:

[root]$ yum install mariadb-server

To start the MariaDB service and enable it to start on boot, execute the following commands:

[root]$ systemctl start mariadb.service
[root]$ systemctl enable mariadb.service

Run the following command to secure your installation:

[root]$ mysql_secure_installation

Install Hackpad

The following commands are run as hackpad user. To switch to hackpad user run:

[root]$ sudo su - hackpad

Clone the Hackpad source code to the /home/hackpad/hackpad directory.

[hackpad]$ git clone https://github.com/dropbox/hackpad.git ~/hackpad

Edit the file ~/hackpad/bin/exports.sh as follows:

...
export SCALA_HOME="/usr/share/scala/"
export SCALA="$SCALA_HOME/bin/scala"
export SCALA_LIBRARY_JAR="$SCALA_HOME/lib/scala-library.jar"
...
export JAVA_HOME="/usr/java/jdk1.7.0_80"
export JAVA="/usr/bin/java"
...
export MYSQL_CONNECTOR_JAR="/home/hackpad/hackpad/lib/mysql-connector-java-5.1.34-bin.jar"
...

and run:

[hackpad]$ cd ~/hackpad
[hackpad]$ bin/build.sh

To create a database for our Hackpad instance, run:

[hackpad]$ contrib/scripts/setup-mysql-db.sh

And enter MySQL root password when prompted.

Copy the default settings configuration file etherpad/etc/etherpad.localdev-default.properties to etherpad/etc/etherpad.local.properties and set the etherpad.superUserEmailAddresses and topdomains, for example:

etherpad.isProduction = true
etherpad.superUserEmailAddresses = name1@example.com,name2@example.com
topdomains = yourdomainname.com,localhost

Start hackpad for the first time:

[hackpad]$ bin/run.sh

If there are no errors, you may continue with the next step.

Create a systemd service

To create a new systemd service for Hackpad, open your editor of choice as a root or sudo user and create a new file:

[root]$ vim /etc/systemd/system/hackpad.service

and add the following code lines:

[Unit]
Description=Hackpad
After=syslog.target network.target

[Service]
Type=simple
User=hackpad
Group=hackpad
ExecStart=/home/hackpad/hackpad/bin/run.sh
Restart=always

[Install]
WantedBy=multi-user.target

Start the Hackpad service and set it to start automatically on boot:

[root]$ systemctl enable hackpad.service
[root]$ systemctl start hackpad.service

To verify the unit started, run journalctl -f -u hackpad.service and you should see something like below:

[root]$ journalctl -f -u hackpad.service
Aug 22 10:42:09 vps run.sh[3080]: dropbox: 2015-08-22 10:42:09.375-0500        Starting dropbox sync
Aug 22 10:42:09 vps run.sh[3080]: dropbox: 2015-08-22 10:42:09.382-0500        Done with dropbox sync

Install and configure Nginx

Nginx is not available by default in CentOS 7 so we will use the official Nginx repository:

[root]$ wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root]$ yum install nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root]$ yum install nginx

Next, create a new Nginx server block:

[root]$ vim /etc/nginx/sites-available/yourdomainname.com.conf
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
  server_name yourdomainname.com;

  location / {
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $host;
    proxy_redirect off;
    proxy_read_timeout 300;
    proxy_pass http://localhost:9000/;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
  }
}

Activate the server block by restarting Nginx:

[user]$ systemctl restart nginx

That’s it. You have successfully installed your Hackpad. To access it, open http://yourdomainname.com/ in your browser. For more information about Hackpad, please refer to the official Hackpad website.




FacebookTwitterDiggStumbleUponGoogle Plus



RSS Feed Powered by MaxBlogPress Bring My Blog Visitors Back

Viewing all articles
Browse latest Browse all 4268

Trending Articles