Install and Configure Ubuntu Server
Ubuntu is a free and open-source Linux distribution based on Debian developed by Canonical Ltd. From 2012-2014, I'm using Ubuntu as my main server. In the beginning, I'm using version 12.04 LTS precise. But when trusty is released, it's not long for us to upgrade our servers to trusty version. In this post, I'll share my step by step to configure my server until it's ready to host my application server (Tomcat and Apache).
First, you need to download and install Ubuntu server from this link. Which image to choose?
Ubuntu Server vs Desktop
Ubuntu Server is a part of the larger set of Ubuntu products and operating system. It's worth noting that other than the kernel settings (before version 12.04), Ubuntu desktop and server are essentially the same distribution, use the same packages and repositories, just with different default package selection.
difference between Ubuntu desktop and server from ubuntu page:
- The first difference is in the CD contents. The "Server" CD avoids including what Ubuntu considers desktop packages (packages like X, Gnome or KDE), but does include server related packages (Apache2, Bind9 and so on). Using a Desktop CD with a minimal installation and installing, for example, apache2 from the network, one can obtain the exact same result that can be obtained by inserting the Server CD and installing apache2 from the CD-ROM.
- The Ubuntu Server Edition installation process is slightly different from the Desktop Edition. Since by default Ubuntu Server doesn't have a GUI, the process is menu driven, very similar to the Alternate CD installation process.
- Before 12.04, Ubuntu server installs a server-optimized kernel by default. Since 12.04, there is no difference in kernel between Ubuntu Desktop and Ubuntu Server since linux-image-server is merged into linux-image-generic.
- For Ubuntu LTS releases before 12.04, the Ubuntu Desktop Edition only receives 3 years of support. This was increased to 5 years in Ubuntu LTS 12.04 In contrast, all Ubuntu LTS Server Edition releases are supported for 5 years.
So, for server we are using server image (Similarly, if you need a Ubuntu desktop, choose one of desktop image). I'm using latest server ISO, in this case is ubuntu-14.04.5-server-amd64.iso. After standard installation (which I'll skip here) now we start for configuration:
do apt-get update »
% sudo apt-get update
It updates the package lists for packages that need upgrading, as well as new packages that have just come to the repositories.
Install mc - Midnight Commander »
% sudo apt-get install mc
GNU Midnight Commander is a visual file manager, licensed under GNU General Public License and therefore qualifies as Free Software. It's a feature rich full-screen text mode application that allows you to copy, move and delete files and whole directory trees, search for files and run commands in the subshell. Internal viewer and editor are included.
Install lynx - text-base browser »
% sudo apt-get install lynx
Lynx is a text web browser. In text-only environment (like server's console) this browser can help you complish many things, including testing.
Install webmin »
Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.
To install webmin, open the terminal and run the following command
% sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
Now you need to dpwnload webmin deb package using the following command
% wget http://prdownloads.sourceforge.net/webadmin/webmin_1.680_all.deb
Install downloaded package using the following command
% sudo dpkg -i webmin_1.680_all.deb
For internal server only
Setup samba server to allow network mapping
note: this is to allow windows client to map to linux server using common windows folder mapping
- login to https://<yourserver>:10000/
- go to "Servers" -> "Samba Windows File Sharing"
- Click "Create a new file share."
- Create a "Home Directories Share"
- After created, back to list and choose "homes"
- On "Other Share Options" choose "Security and Access Control"
- Change to "Writeable" and set "<user>" to "Valid users" and "Valid groups"
- Now you will able to map to your homes directory from M$ Windows using your account (<user>)
Install and configure mysql »
% sudo apt-get install mysql-server-5.6
Edit mysql configuration at /etc/mysql/my.cnf
Open /etc/mysql/my.cnf with text editor
% sudo nano /etc/mysql/my.cnf
look up for: [mysqld]
add this right below it:
lower_case_table_names = 1
look up for: bind-address = 127.0.0.1
comment out this line to allow connection from remote host, so it will be:
#bind-address = 127.0.0.1
Save changes, and restart mysql service
% sudo service mysql restart
Install apache2 »
% sudo apt-get install apache2
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
If Tomcat is our application server, Apache is our web server.
Install and Configure phpmyadmin »
phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement.
This is optional and not recommended for Production Server. Users can use phpMyAdmin to query even backup their MySQL database.
To install phpmyadmin:
% sudo apt-get install phpmyadmin
login to phpmyadmin http://<servername>/phpmyadmin
and add new user [email protected]%
Install tomcat7 (and tomcat7-admin) »
% sudo apt-get install tomcat7 tomcat7-admin
The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are developed under the Java Community Process.
Setup Oracle's Java SDK »
Instead of using OpenJDK, we are using official JDK released by Oracle; In case of my application that time, the application is tested in jdk-7u55 (Yes, Java 7).
Download jdk-6u35-linux-x64.bin from oracle website (archive)
Move jdk-6u35-linux-x64.bin to /usr/lib/jvm folder
% cd /usr/lib/jvm/ % sudo mv ~/jdk-7u55-linux-x64.gz .
% sudo tar zxvf ./jdk-7u55-linux-x64.gz
folder jdk1.7.0_55 created
Configure JDK and Tomcat »
Edit /etc/environment file
% sudo nano /etc/environment
Add JAVA_HOME, CATALINA_HOME, and CATALINA_BASE in the environment, after PATH
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_55 CATALINA_HOME=/usr/share/tomcat7 CATALINA_BASE=/var/lib/tomcat7
save changes (and you need to restart server)
% sudo nano /etc/default/tomcat7
Since previously Tomcat installation comes with OpenJDK, we need to change JAVA_HOME
Uncomment JAVA_HOME and set to /usr/lib/jvm/jdk1.6.0_35
JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC"
JAVA_OPTS="-Djava.awt.headless=true -Xms2048m -Xmx2048m -XX:PermSize=1024m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC"
(Optional) What Next?
- Change log directory of Tomcat, configure CATALINA_OUT
- Configure Tomcat users in $CATALINA_BASE/conf/tomcat-users.xml
- Configure your database JNDI in $CATALINA_BASE/conf/context.xml
- Change max upload/limit size for tomcat's manager in /usr/share/tomcat7-admin/manager/WEB-INF/web.xml
JCE is Java Cryptography Extension. Get JCE from:
extract and copy to mapping folder
Copy two *.jar file to /usr/lib/jvm/jdk1.7.0_55/jre/lib/security