Set Up Ubuntu 18.04This guide describes how to install and configure commonly used software on Ubuntu 18.04. 0. Install UbuntuDownload and install Ubuntu Server 18.04 or Ubuntu Desktop 18.04. After installation, run the following commands to update the software packages: > sudo apt update
> sudo apt upgrade
Then install some commonly used tools: > sudo apt install mailutils mutt curl vim nmap During installation, when you are asked to select mail server configuration type, choose "Internet Site". 1. Configure Auto Updateunattended-upgrades should already be installed, but if not, install it first: > sudo apt install unattended-upgrades Edit /etc/apt/apt.conf.d/50unattended-upgrades to enable the following:
Then > sudo service unattended-upgrades restart 2. HTTP Server and Common Development ToolsFor HTTP server I recommend Nginx over Apache as Nginx is not only faster, but for common setups Nginx configuration is also easier. > sudo apt install nginx And then some commonly used development tools: > sudo apt install git subversion build-essential 3. Java, Maven, and TomcatFor Ubuntu Server, install openjdk-11-jdk-headless, and for Ubuntu Desktop, install openjdk-11-jdk, e.g. > sudo apt install openjdk-11-jdk-headless Then install Maven and Tomcat: > sudo apt install maven tomcat8 At the time of writing (i.e. 7/2018), there are two bugs in Ubuntu 18.04 packages: a) The cacerts file included in OpenJDK 11 is defective and will cause all Maven dependency downloads to fail due to connection problem to HTTPS of the central repository. According to the discussions here, the easiest and surest way to fix it is to replace /etc/ssl/certs/java/cacerts with the one included in Oralce's JDK 10 for Linux (it's in lib/security after you unzip the tar.gz file). b) The Tomcat 8 service would fail to start because it cannot find JDK. You'll need to edit /etc/default/tomcat8, uncomment the JAVA_HOME line, and set JAVA_HOME to OpenJDK 11:
And then you can start Tomcat 8 with the following command: > sudo service tomcat8 start 4. Node.js and Global PackagesAt the time of writing (i.e. 7/2018), Node.js 10 is not under LTS but will be soon, so we'll install Node.js 10 instead of 8: > curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
> sudo apt install -y nodejs
Using sudo to install NPM global package seems to be discouraged. The NPM documentation recommends using a version manager, but I feel that changing NPM's default directory (the second option in the documentation) is better because it keeps the same command line syntax as on Windows, and it's one less tool to learn or use. So: > mkdir ~/.npm-global
> npm config set prefix '~/.npm-global'
Edit .profile file so the PATH environment variable looks like the following:
then > source ~/.profile And install the following global packages > npm install -g typescript ts-node nodemon @angular/cli pm2 5. MySQL and PostgreSQL
Subversion> sudo apt-get install subversion
> sudo apt-get install xinetd
Create /etc/xinetd.d/svn with the following content: service svn
{ disable = no port = 3690 socket_type = stream protocol = tcp wait = no user = cysun server = /usr/bin/svnserve server_args = -i -r /home/cysun/subversion } then restart xinetd: > sudo /etc/init.d/xinetd restart MySQL and phpMyAdminIf MySQL is not installed already: > sudo apt-get install mysql-server
Log into MySQL and create an account and a database for the user: > mysql -u root -p
mysql> create database cysun;
mysql> grant all privileges on cysun.* to 'cysun'@'%' identified by 'abcd' with grant option;
mysql> flush privileges;
mysql> quit
Note that the GRANT statement will automatically create the user account if it does not exist. Now install phpMyAdmin: > sudo apt-get install phpmyadmin During configuration you'll need to provide the root password of MySQL. After phpMyAdmin is installed, it can be accessed at http://host/phpmyadmin/ . By default MySQL server does not accept remote connections. To enable remote connections (which is necessary for servers like CS3 but not for servers like CSNS), modify /etc/mysql/my.cnf so the following line is commented out: bind-address = 127.0.0.1 then restart the MySQL server: > sudo service mysql restart PostgreSQL and phpPgAdminIf PostgreSQL is not installed already: > sudo apt-get install postgresql Log into PostgreSQL and create an account and a database for the user: > sudo -u postgres psql template1
psql> create user cysun with createdb password 'abcd';
psql> create database cysun with owner=cysun;
psql> \q
Leave out the createdb option in the CREATE USER statement if you do not want to grant the user the privilege to create databases. By default PostgreSQL server does not accept remote connections. To enable remote connections (which is necessary for servers like CS3 but not for servers like CSNS), modify /etc/postgresql/9.1/main/postgresql.conf so: listen_addresses = '*' And modify /etc/postgresql/9.1/main/pg_hba.conf so that: host all all 0.0.0.0/0 md5 To install phpPgAdmin: > sudo apt-get install phppgadmin By default phpPgAdmin only allows local access. To allow remote access, edit /etc/phppgadmin/apache.conf so that #deny from all
#allow from 127.0.0.0/255.0.0.0 ::1/128 allow from all Then restart Apache2. After that phpPgAdmin can be accessed at http://host/phpmyadmin/ . Tomcat> sudo apt-get install tomcat8 Once installed, Tomcat will be running at port 8080. The webapp directory is at /var/lib/tomcat8/webapps/ and the configuration files are under /etc/tomcat8/. On CS3, the instructor of CS3220/5220 may need to restart some applications once in a while, so install the Tomcat Admin package: > sudo apt-get install tomcat8-admin And edit /etc/tomcat8/tomcat-users.xml to add a manager user. Tomcat Manager can be accessed at http://host:8080/manager/html. Install JDBC drivers: > sudo apt-get install libmysql-java
> sudo apt-get install libpg-java
The JAR file will be installed under /usr/share/java with many other JAR files. To make them available to Tomcat, symbolic links to them need to be created under /usr/share/tomcat8/lib: > cd /usr/share/tomcat8/lib
> sudo ln -s ../../java/mysql.jar mysql.jar
> sudo ln -s ../../java/postgresql.jar postgresql.jar
JSTL is still not included in the Tomcat distribution, and there doesn't seems to be a package that provide them, so download it from Apache Jakarta, place jstl.jar and standard.jar under /usr/share/java, then link them from /usr/share/tomcat8/lib like before. ApacheEnable userdir (i.e. public_html): > sudo a2enmod userdir |