Summary of configuration of tomcat6 + mysql5 in Ubuntu Server

Source: Internet
Author: User
Tags apache tomcat

In ubuntu server, Tomcat 6 and mysql5 are all from the network.

I. Network Configuration

Check Network Configuration
$ Ifconfig

Configure the DHCP Client
$ Sudo VI/etc/Network/interfaces
Add iface eth0 Inet DHCP

Configure static IP addresses
$ Sudo VI/etc/Network/interfaces
The eth0 configuration is as follows:
Auto eth0
Address 192.168.0.88
Netmask 255.255.255.0
Gateway 192.168.0.1

Make the new configuration take effect
After saving and exiting, restart the networking command to make the new configuration take effect:
$ Sudo/etc/init. d/networking restart
You can also restart the NIC to make the new configuration take effect. The advantage is that it does not affect other network interfaces:
$ Sudo ifdown eth0
$ Sudo IFUP eth0

Temporarily change IP Address
$ Sudo ifconfig eth0 192.168.1.111 netmask 255.255.255.0
After the system is restarted, the configuration in interfaces will be restored.

You can set the default gateway in either of the following ways:
1. Set it in the interfaces file.
$ Sudo VI/etc/Network/interfaces
Add gateway to the eth0 configuration, for example:
Auto eth0
Iface eth0 Inet static
Address 192.168.1.123
Netmask 255.255.255.0
Gateway 192.168.1.1
----------------------------------------------------------------->

Ii. Install sysv-RC-conf (Service Management)
Sudo apt-Get install sysv-RC-Conf

It is mainly used to set server auto-start

Iii. Samba Configuration:
It is easy to upload programs or files developed under Windows to Ubuntu.

1. Installation of Samba:

# Sudo apt-Get install samba

# Sudo apt-Get install smbfs

2. Create a shared directory:

# Mkdir/home/Willis/share

# Sudo chmod 777/home/Willis/share

3. Create a samba configuration file:

1. Save the existing configuration file

# Sudo mV/etc/samba/smb. conf/etc/samba/smb. conf. Bak

2. Create a New Samba configuration file

# Sudo gedit/etc/samba/smb. conf

############### SMB. conf #######################

[Global]

; Create a work group

Workgroup = mygroup

In security mode, we set the minimum security level

Security = Share

; Whether to allow access by the guest user

Guest guest K = Yes

[Share]

; Shared Folder path

Path =/home/Willis/share

; Read permission

Browseable = Yes

; Write permission

Writeable = Yes

Iv. Test file configuration results

# Testparm

5. Restart the samba Service

#/Etc/init. d/samba restart or ubuntu12.04 run #/etc/init. d/smbd restart

You can view the shared folder on the Ubuntu server in the network neighbor of window.

You can also install the graphical interface as follows:

Install the Ubuntu Samba graphic Management Interface
# Sudo apt-Get install system-config-samba

Start the samba graphic Management Interface
# Sudo system-config-samba

4. install Java environment support

Open the terminal, run the following command, or use adept/new software manager, where search for "sun-java6-jre" and "sun-java6-jdk" and tag the installation.

Sudo apt-Get install sun-java6-jre

If the space is rich, we recommend that you install a JDK.

Sudo apt-Get install sun-java6-jdk

Tip: During the installation process, you need to answer whether you agree to use the Protocol (the red-blue prompt page in the terminal). Press the tab key to OK, and press enter to install it normally.

Set the current default Java interpreter:

Sudo Update-alternatives -- config Java

The following figure is displayed after execution:

There are 2 alternatives which provide 'java '.

Selection alternative
-----------------------------------------------
1/usr/bin/gij-wrapper-4.1
* + 2/usr/lib/JVM/Java-6-sun/JRE/bin/Java

Press enter to keep the default [*], or type selection Number:

Enter the number before the row containing "Sun. As shown above, enter 2 and press enter to confirm.

Configure Java environment variables:

Sudo gedit/etc/environment

Add the following two lines:

Classpath =.:/usr/lib/JVM/Java-6-sun/lib
Java_home =/usr/lib/JVM/Java-6-sun

Sudo gedit/etc/JVM

Convert

/Usr/lib/JVM/Java-6-sun

Enter this line at the top of the configuration block.

Test: Java-version

-------------------------------------------------------------------------------

5. install Tomcat

1. Install

Download the tomcate2 package apache-tomcat-6.0.20.tar.gz in windows and copy it to the share directory in the Ubuntu of the network neighbor.
Extract
Tar zxvf apache-tomcat-6.0.20.tar.gz
Move to/usr/lib
# Sudo mV/home/lhgs/share/Apache-Tomcat-6.0.18/usr/lib/Apache-Tomcat-6.0.18
Start Tomcat
Sudo/usr/lib/Apache-Tomcat-6.0.18/bin/./startup. Sh
Then Tomcat can be started normally.
2. Set tomcat to start automatically

According to the official document of Tomcat, jsvc can be used to set Automatic startup in Linux (which is included in the Tomcat package)

Set tomcat to run as an independent user (to prevent running as root, the permission is too large)

Shell> sudo useradd-D/usr/local/tomcat6-S/usr/sbin/nologin Tomcat

The preceding command adds a system user Tomcat and sets it to not be logged on to the system.

Set Tomcat's access permissions to Tomcat 6.

Shell> sudo chown-r Tomcat: tomcat/usr/local/tomcat6

Shell> sudo chown-r Tomcat: tomcat/opt/Apache-Tomcat-6.0.18

Install jsvc

The premise requires the system to install GCC (the system is generally installed by default), Autoconf, libc6-dev

Shell> sudo apt-Get install .....

Decompress jsvc.tar.gz and prepare for compilation.

Shell> Cd/usr/local/tomcat6/bin

Shell> sudo tar zxvf jsvc.tar.gz

Shell> Cd jsvc-Src

Shell> sudo sh support/buildconf. Sh

If the command succeeds, the following command is output:

Support/buildconf. sh: configure script generated successfully

Add execution permission for configure

Shell> sudo chmod 755 configure

Compile

Shell> sudo./configure-with-Java =/usr/lib/JVM/Java-6-Sun (Java installation path)

Shell> sudo make

If no error occurs, jsvc is successfully installed.

Set the Startup Script

Copy the tomcat5.sh script of jsvc to/etc/init. d/and change it to Tomcat.

Shell> sudo CP/usr/local/tomcat6/bin/jsvc-src/native/tomcat5.sh/etc/init. d/tomcat

Modify the/etc/init. d/tomcat File

Shell> sudo gedit/etc/init. d/tomcat

 

The content of the file is as follows (color and annotation are included in the modification ):

#! /Bin/sh

######################################## ######################################

#

# Copyright 2004 the Apache Software Foundation.

#

# Licensed under the Apache license, version 2.0 (the "License ");

# You may not use this file before t in compliance with the license.

# You may obtain a copy of the license

#

# Http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# Distributed under the license is distributed on an "as is" basis,

# Without warranties or conditions of any kind, either express or implied.

# See the license for the specific language governing permissions and

# Limitations under the license.

######################################## ######################################

#

# Small shell script to show how to start/stop Tomcat using jsvc

# If you want to have Tomcat running on port 80 Please modify the server. xml

# File:

#

# <! -- Define a non-ssl http/1.1 Connector on port 80 -->

# <Connector classname = "org. Apache. Catalina. connector. http. httpconnector"

# Port = "80" minprocessors = "5" maxprocessors = "75"

# Enablelookups = "true" redirectport = "8443"

# Acceptcount = "10" DEBUG = "0" connectiontimeout = "60000" type = "codeph" text = "codeph"/>

#

# That is for Tomcat-5.0.x (Apache Tomcat/5.0)

#

# Adapt the following lines to your configuration

Java_home =/usr/lib/JVM/Java-6-sun # Set this location to the JDK location of the machine.

Catalina_home =/usr/local/tomcat6 # tomcat installation location (soft link)

Daemon_home =/usr/local/tomcat6/bin # location of Tomcat Startup Program

Tomcat_user = Tomcat # Tomcat user

 

 

# For multi instances adapt those lines.

Tmp_dir =/var/tmp

Pid_file =/var/run/jsvc. PID

Catalina_base =/usr/local/tomcat6 # tomcat installation location

 

# Comment down this sentence

# Catalina_opts = "-djava. Library. Path =/home/jfclere/Jakarta-Tomcat-connectors/JNI/native/. Libs"

# Add the following sentence

Catalina_opts =

Classpath =

$ Java_home/lib/tools. jar:

$ Catalina_home/bin/commons-daemon.jar:

$ Catalina_home/bin/Bootstrap. Jar

 

 

Case "$1" in

Start)

#

# Start Tomcat

#

$ Daemon_home/jsvc-src/jsvc # Set the location of the correct jsvc Program

-User $ tomcat_user

-Home $ java_home

-Dcatalina. Home = $ catalina_home

-Dcatalina. base = $ catalina_base

-Djava. Io. tmpdir = $ tmp_dir

-Wait 10

-Pidfile $ pid_file

-OUTFILE $ catalina_home/logs/Catalina. Out

-Errfile '& 1'

$ Catalina_opts

-CP $ classpath

Org. Apache. Catalina. startup. Bootstrap

#

# To get a verbose JVM

#-Verbose

# To get a debug of jsvc.

#-Debug

Exit $?

;;

 

 

Stop)

#

# Stop Tomcat

#

$ Daemon_home/jsvc-src/jsvc # Set the location of the correct jsvc Program

-Stop

-Pidfile $ pid_file

Org. Apache. Catalina. startup. Bootstrap

Exit $?

;;

 

 

*)

Echo "usage tomcat. Sh start/stop"

Exit 1 ;;

Esac

If the configuration file is correct, run the sudo/etc/init. d/tomcat start command to start the instance.
The Tomcat service is loaded to Automatic startup. In many cases, the chkconfig command is used to load the Tomcat service. In fact, this command is not available in Ubuntu, and it should be loaded using sysv-RC-conf Tomcat on.

Else
6. Install mysql5
Apt-Get install mysql-Server
In ubuntu, MySQL only allows local access by default. If you want other machines to remotely access this MySQL database, you need to make some settings.

Modify the configuration file (if there is no my. conf file, restart Linux)
# Sudo VI/etc/MySQL/My. conf
Find bind-address = 127.0.0.1 and comment out this sentence.
MySQL database Modification
1) [root @ etc] # mysql-uroot-P
Enter password:
2) mysql> use MySQL;
3) mysql> select host, user, password from user;
4) mysql> grant all privileges on *. * To root@192.168.15.101 identified by 'Password'
(1) 192.168.15.101 is the IP address of the client connecting to the MySQL database, rather than the IP address of the database server where the MySQL database is located,
Remember.
(2) password is the password of the root user of the MySQL database, which needs to be modified according to the actual situation.
If you can log on to the MySQL database at any host address, replace the address with "%.
First Change the database
Mysql> use MySQL;
Add User
Mysql> grant all privileges on *. * to root @ "%" identified by 'Password'

Start MySQL
Sudo/etc/init. d MySQL star

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.