ubuntu raid

https://java.qbytesworld.com/post/WebMin-for-Ubuntu.aspx

http://www.havetheknowhow.com/Configure-the-server/Install-Webmin.html

https://localhost:10000/

root@qberry-backup:~# sudo /usr/share/webmin/changepass.pl /etc/webmin root password

Updated password of Webmin user root

root@qberry-backup:~# sudo /etc/init.d/webmin restartStopping Webmin server in /usr/share/webmin

Starting Webmin server in /usr/share/webmin


=======================================================================

Grep

-h Show filename

-n Show line number

-i Ignore case

-c Count

-F String is not a RegEx (faster)

Contiously look at a file for 500

tail -f access.log | grep " 500 "

Find the occurence of 02/Jun/2012:15 or 02/Jun/2012:16

grep " 500 " access.log | egrep "02/Jun/2012:15|02/Jun/2012:16"

Using cron to run a script each time the server starts

Often you want to run a script each time your server boots. For example, in the How to run VNC on startup guide we wrote a script to launch VNC. One way to get this script to run on boot is to add it as a cron job. This is very easy to do using Webmin. So, within Webmin click on System and then Scheduled Cron Jobs. Then click the Create a new scheduled cron job option at the top of the screen that opens.

Click the button next to the Execute cron job as and choose the username you created when you installed Ubuntu. Hint: your username appears in a Putty/Terminal session prompt. eg. yourusernameappearshere@MyMediaServer.

Note: If the script you've written needs to be run as root then obviously you'd choose root in the Execute cron job as section instead of your username. If the script needs to be run as any other user then obviously enter that username instead.

Enter the name of your script including the full pathname eg. /home/htkh/MyScripts/StartVNC.sh >/dev/null into the Command box, replacing htkh with your own username, MyScripts with the name of the folder you created to store your scripts and StartVNC.sh with the script name. The >/dev/null parameter will discard any output the script may produce. If your script actually needs to produce any output then it should be piped to a file. See the Monitor server temperatures scripts for an example of piping output to a file.

Enter a suitable description in the Description field.

In the When to Execute – Simple schedule drop-down list choose When system boots then click the Create button at the bottom of the screen.

Now's probably a good time to test it. I'd recommend first testing that you've set the job up correctly in Webmin. You can do this by clicking on the job you've just created from the long list of cron jobs. Then click the Run Now button at the bottom of the screen. You should see a message similar to the one you saw when you tested it from a Putty/Terminal session. If you don't then go back and check your settings.

Network File System (NFS)

http://www.google.com/#sclient=psy-ab&hl=en&source=hp&q=ubuntu%20nfs%20share%20server&pbx=1&oq=ubuntu%20NFS%20share%20server&aq=0v&aqi=g-v1g-b2&aql=&gs_sm=11&gs_upl=6740l8393l0l12683l4l4l0l0l0l1l546l1746l3-1.2.1l4l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=3214e37cdfe9fa8f&biw=1280&bih=854&pf=p&pdl=300

https://help.ubuntu.com/11.04/serverguide/C/network-file-system.html

http://www.youtube.com/watch?v=NR9Ts8GV5Bo&feature=related

http://www.youtube.com/watch?v=iJqVT0KsoZs&feature=relmfu

NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.

Some of the most notable benefits that NFS can provide are:

  • Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.

  • There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.

  • Storage devices such as floppy disks, CDROM drives, and USB Thumb drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.

Installation

At a terminal prompt enter the following command to install the NFS Server:

sudo apt-get install nfs-kernel-server

Configuration

You can configure the directories to be exported by adding them to the /etc/exports file. For example:

/ubuntu  *(ro,sync,no_root_squash)/home    *(rw,sync,no_root_squash)

You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount.

To start the NFS server, you can run the following command at a terminal prompt:

sudo /etc/init.d/nfs-kernel-server start

NFS Client Configuration

Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt:

sudo mount example.hostname.com:/ubuntu /local/ubuntu

The mount point directory /local/ubuntu must exist. There should be no files or subdirectories in the /local/ubuntu directory.

http://ubuntuhandbook.org/index.php/2014/08/map-network-drive-onto-ubuntu-14-04/

An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted.

The general syntax for the line in /etc/fstab file is as follows:

example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr

If you have trouble mounting an NFS share, make sure the nfs-common package is installed on your client. To install nfs-common enter the following command at the terminal prompt:

sudo apt-get install nfs-common

HTTPD.CONF virtual directory

# To see the listing of a directory, the Options directive for the
# directory must include "Indexes", and the directory must not contain
# a file matching those listed in the DirectoryIndex directive.
#

#
# IndexOptions: Controls the appearance of server-generated directory
# listings.
#
#IndexOptions FancyIndexing HTMLTable VersionSort

# We include the /icons/ alias for FancyIndexed directory listings. If
# you do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
# Options Indexes MultiViews
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Mono project – ASP.NET on Linux


ASP.NET

WineHQ (MS on Linux)

SQL Server Express Edition

Microsoft SQL Server Desktop Engine

Microsoft SQL Server Management Studio Express

Apache – Tomcat – PROXY PASS


Steps for proxy a request to SimpleServlet.com


hosts file:

$ nano /etc/hosts
127.0.0.1 SimpleServlet.com


Tomcat changes:

on my deploy, the webapps directory is: :/var/lib/tomcat6/webapps

$ nano /etc/tomcat6/server.xml

#### Inside of the <Engine> tag add below:
<!– SimpleServlet.com –>
<Host
name="SimpleServlet.com"
appBase="webapps/SimpleServlet"
unpackWARs="true"
autoDeploy="true">

<Context
path=""
docBase=""
debug="1"
reloadable="true"/>

<Valve
className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="tomcat_access_"
suffix=".log"
pattern="common"
resolveHosts="false"/>
</Host>

#### After the </Engine> tag add the below.
#### Each Virtual Host Proxy must be on a different port, remember this for your SimpleServlet.com Apache2 entry
<Connector port="9282" proxyPort="80" proxyName="SimpleServlet.com"/>


Apache2:

$ sudo a2enmod proxy
$ sudo a2enmod proxy_http

$ cd /etc/apache2/sites-available
$ nano SimpleServlet.com

<VirtualHost *:80>

ServerName SimpleServlet.com

<IfModule mod_proxy.c>
ProxyRequests Off

<Proxy SimpleServlet.com>
Order deny,allow
Deny from all
Allow from all
</Proxy>

ProxyPass /index.html !
ProxyPass /sitemap.xml !
ProxyPass / http://SimpleServlet.com:9282/
ProxyPassReverse / http://SimpleServlet.com/

</IfModule>

</VirtualHost>


Restart All:

$ /etc/init.d/apache2 reload

$ a2ensite SimpleServlet.com
$ sudo /etc/init.d/tomcat6 restart
$ /etc/init.d/apache2 restart

This works – Apache + Tomcat + mod_jk

Good YouTube : http://www.youtube.com/watch?v=Njx1V4ZW_g0

Good YouTube w/LoadBalance : http://www.youtube.com/watch?v=yNuuoQLw0tA

This is a compact step-by-step guide for installing Tomcat with Apache and mod_jk on a Ubuntu 10.10 system considering following components

Apache 2, MySQL 5, PHP 5, PhpMyAdmin, Sun Java JDK 1.6, Tomcat 6.0, Tomcat-Admin, mod_jk

Important note: This is just the first version of this guide. It does not consider any previous configured or installed components


…Greyed out indicates should try, not tested…


http://java.qbytesworld.com/post/-Ubuntu-Server-Setup-.aspx

Server setup would allow for skipping steps:

  • 1 as we do not want MySQL on the same server and Apache2 is in setup (needs cleaned up)
  • 2 as we do not care about PHP (and already skipping)
  • 4 as we have it in the Setup

1 LAMP – Apache, MySQL, PHP (Add Tomcat)

$ sudo apt-get install tasksel
$ sudo tasksel

Remember your MySQL password.

Now create a test page


$ sudo nano /var/www/info.php

and insert following code

<?php
phpinfo();
?>

Restart Apache

/etc/init.d/apache2 restart

and check if everything went fine


2 PHPMyAdmin

Install via apt-get

$ sudo apt-get install phpmyadmin

Choose Apache, and insert credentials

Now create a soft-link to make phpmyadmin-sources available in /var/www

$ sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

Now open a browser and see if it’s working

http://[MY_IP]/phpmyadmin

(use the credentials you defined shortly before)


3 JAVA

Due Sun’s java is not provided by the repository anymore, we have to add it manually:

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:sun-java-community-team/sun-java6
$ sudo apt-get install sun-java6-jdk

Usually this should already be everything what we have to do. Try it by typing

$ sudo java -version

4 TOMCAT – Commons and Admin/Manager

Install both tomcat-common and tomcat-admin via apt-get

$ sudo apt-get install tomcat6
$ sudo apt-get install tomcat6-admin
$ sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-docs tomcat6-examples tomcat6-user

For accessing the Tomcat-admin we need to add our own manager-user

$sudo nano /etc/tomcat6/tomcat-users.xml

And add the new user

<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="my_secret" roles="admin,manager"/>

Finally restart Tomcat

$ sudo /etc/init.d/tomcat6 restart

Try if it works

http://[MY_IP]:8080/manager/html


5 Mod JK

Install via apt-get

$ sudo apt-get install libapache2-mod-jk

Now create our own workers.properties file for Apache.
Open or create

$ sudo nano /etc/apache2/workers.properties

and paste:

workers.tomcat_home=/var/lib/tomcat6
#workers.java_home=/usr/lib/jvm/java-6-sun
workers.java_home=/usr/lib/jvm/default-java
ps=/
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.default.lbfactor=1
Now tell the Apache to use this worker
$ sudo nano /etc/apache2/apache2.conf

and add following lines

<IfModule>
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
LockFile ${APACHE_LOCK_DIR}/accept.lock
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w %V %T"
</IfModule>

Finally configure which URLs Apache should pass through the Tomcat

Serving our Tomcat pages
$ sudo nano /etc/apache2/sites-enabled/000-default
JkMount /mytomcatwebappname* worker1
JkMount /docs* worker1
JkMount /examples* worker1
JkMount /manager* worker1

JkMount /sample* worker1
This means, that every URL that contains the key mytomcatwebappname gets handled by Tomcat instead of Apache.

(If you want to pass all requests to the Apache (instead of individual ones), just remove the line
DocumentRoot /var/www
and add following JkMounts:

JkMount / worker1
JkMount /* worker1
)

Serve some Java JSP Site called QBW-Web-Parent.com

$ sudo nano /etc/apache2/sites-available/QBW-Web-Parent.com

<VirtualHost *:80>
DocumentRoot /var/lib/tomcat6/webapps/QBW-Web-Parent
ServerName QBW-Web-Parent.com
JkMount /*.jsp worker1
JkMount /* worker1
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/lib/tomcat6/webapps/QBW-Web-Parent
ServerName QBW-Web-Parent.com
JkMount /*.jsp worker1
JkMount /* worker1
SSLEngine On
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>

=====================================================

And last but not least, we have to enable the redirect port 8443 on Tomcat

$ sudo nano /etc/tomcat6/server.xml

And uncomment / insert / update that following line is present

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Then scroll down and find:

  </Host></Engine>

AFTER the ending </Host> tag, and BEFORE the ending </Engine> tag, insert the following:

<!– QBW-Web-Parent.com –>
<Host
name="QBW-Web-Parent.com"
appBase="webapps/QBW-Web-Parent"
unpackWARs="true"
autoDeploy="true">
<Context
path=""
docBase=""
debug="1"
reloadable="true"/>
<Valve
className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="tomcat_access_"
suffix=".log"
pattern="common"
resolveHosts="false"/>
</Host>

Now we only have to restart first the Tomcat and then the Apache

$ sudo /etc/init.d/tomcat6 restart
$ sudo /etc/init.d/apache2 restart

Et voila, now it should work as expected.


http://www.javathinking.com/2007/10/tomcat-with-apache2-virtual-hosts/

http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2

http://www.tequilafish.com/2007/08/02/apache-virtualhost-on-ubuntu/

6 Setup a new virtual host in Apache2

Create the folders for our new virtual host:

mkdir /var/www/server1.example.com
mkdir /var/www/server1.example.com/htdocs
mkdir /var/www/server1.example.com/logs

Then create a new site in Apache2:

vi /etc/apache2/sites-available/server1.example.com

Then add:

<VirtualHost *:80>JkMount /* defaultServerName server1.example.comServerAdmin webmaster@server1.example.comDocumentRoot /var/www/server1.example.com/htdocsErrorLog /var/www/server1.example.com/logs/error.logCustomLog /var/www/server1.example.com/logs/access.log combined<Directory /var/www/server1.example.com/htdocs>Options -Indexes</Directory></VirtualHost>

Note: JkMount can be setup in different ways.

JkMount /* will use tomcat for all files
JkMount /*.jsp only for .jsp files
JkMount /folder/* for tomcat files in a specific directory

Enable the new virtual host we created, by running:

a2ensite server1.example.com


6 Setup a new virtual host in Tomcat6

Open up the configuration file for Tomcat6:

vi /etc/tomcat6/server.xml

Find the following lines:

<!--<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />-->

And uncomment the connector port, like this:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Then scroll down and find:

  </Host></Engine>

AFTER the ending </Host> tag, and BEFORE the ending </Engine> tag, insert the following:

<!-- server1.example.com -->
<Host
 name="server1.example.com"
 appBase="/var/www/server1.example.com"
 unpackWARs="true"
 autoDeploy="true">
 
<Context
 path=""
 docBase="htdocs"
 debug="0"
 reloadable="true"/>
 
<Valve
 className="org.apache.catalina.valves.AccessLogValve"
 directory="/var/www/server1.example.com/logs"
  prefix="tomcat_access_"
 suffix=".log"
 pattern="common"
 resolveHosts="false"/>
</Host>
 
 

Make sure you replace server1.example.com with your details in all the places.

Now lets create a Catalina folder for our new domain:

mkdir /etc/tomcat6/Catalina/server1.example.com

And copy the original context files to new domain:

cp /etc/tomcat6/Catalina/localhost/* /etc/tomcat6/Catalina/server1.example.com/

But remove the ROOT.xml file, because we don't need that one on our new domain:

rm -f /etc/tomcat6/Catalina/server1.example.com/ROOT.xml


4.5 Create a test file and test our new setup

Create a new test.jsp file for our new virtual host:

vi /var/www/server1.example.com/htdocs/test.jsp

and add:

<html><head><title>Hello World</title></head><body><h1>Hello World</h1>Today is: <%= new java.util.Date().toString() %></body></html>

Save and exit the file.

Finally restart the services, so that the new configuration will load:

/etc/init.d/apache2 stop
/etc/init.d/tomcat6 restart
/etc/init.d/apache2 start

Then use your browser to visit http://server1.example.com/test.jsp and verify that you get the test page we just created.

You should also be able to visit http://server1.example.com/examples which is now also available on our virtual host (/docs, /manager/html and /host-manager/html should also work):


SSL on Apache2

http://java.qbytesworld.com/post/apache-tomcat-ubuntu-1104.aspx


References:

Paths:

Apache2 configuration

/etc/apache2/workers.properties
/etc/apache2/conf.d/mod_jk.conf
/etc/apache2/sites-available/server1.example.com
/var/www/server1.example.com/htdocs/

Tomca6 configuration

/etc/tomcat6/tomcat-users.xml
/etc/tomcat6/server.xml
/etc/tomcat6/Catalina/server1.example.com/

Tomca6 webapp path

/var/lib/tomcat6/webapps/QBW-Web-Parent

Tomca6 Cache

/var/cache/tomcat6/Catalina/localhost

Restart Apache2 and Tomcat6

/etc/init.d/apache2 stop
/etc/init.d/tomcat6 restart
/etc/init.d/apache2 start


Information via: http://blog.cwill-dev.com/2011/04/07/installing-apache2-and-tomcat6-with-mod_jk-on-ubuntu-10-10/

Installing Apache2 and Tomcat6 with mod_jk on Ubuntu 10.10


Tag Cloud