This document describes how to install and deploy ssh, jdk, MySQL, and tomcat programs in Ubuntu. The environment and the programs to be installed are as follows:
Install ssh
1. Run the which command to check whether ssh is installed.
Which ssh
2 which sshd
By default, the ssh client is installed in Ubuntu, but the ssh server is not installed.
2. Install with apt-get:
Ubuntu is easy to use because it inherits the debian apt system, but apt depends on the network.
Sudo apt-get install openssh-server
Ubuntu automatically downloads and installs openssh server, solves all dependencies, and automatically starts the service after the installation is complete.
3. Modify the ssh server configuration
In the SSH service, all content is encrypted and secure. However, if you can use the certificate for authentication, the security will be further improved, and after some settings, you can also achieve the effect of automatic login for certificate authentication. Modify the configuration file/etc/ssh/sshd_config to change the configuration of the ssh server and enable the certificate authentication option:
RSAAuthentication yes
2 PubkeyAuthentication yes
3 AuthorizedKeysFile % h/. ssh/authorized_keys
Save and restart the ssh service:
Sudo/etc/init. d/ssh restart # restart
2 # sudo/etc/init. d/ssh start # start
3 # sudo/etc/init. d/ssh stop # stop
Restart the ssh service after modification.
4. Create a private key and public key for an ssh user
Since the private key and public key are created for the user, of course you need to log on to the account (such as the hadoop user) that requires the key, and then run:
Ssh-keygen-t rsa
Here, we store the generated key in the default directory (~ /. Ssh. The passphrase will be prompted during the creation process, which is equivalent to adding a password to the certificate, which is also a measure to improve security, so even if the certificate is accidentally copied away, it is not afraid. Of course, if this field is left blank, the client can automatically log on through certificate authentication.
The ssh-keygen command generates two keys: the private key id_rsa and the public key id_rsa.pub. If no key exists ~ /. Ssh/authorized_keys file, rename the id_rsa.pub file ~ /. Ssh/authorized_keys file, append the content of the public key id_rsa.pub file:
Mv ~ /. Ssh/id_rsa.pub ~ /. Ssh/authorized_keys # Rename
2 cat ~ /. Ssh/id_rsa.pub> ~ /. Ssh/authorized_keys # append
Now you can use the command
Ssh localhost
If you log on to the local machine without a password, a prompt will appear when you log on for the first time. Once you confirm the authorization, the prompt will not appear again, as shown in the figure below:
Of course, it does not make sense to log on to the local machine only. We need to log on to other servers from the local machine without a password. Copy the public key authorized_keys from the local machine to another server ~ /. Ssh, you can log on to another server without a password.
Similarly, if you want other machines to access the local machine without a password, copy the id_rsa private key to the path of another machine ~ /. Ssh.
Install jdk
1. First download the jdk installation file
Take the bin file as an example, such as the version jdk1.6.0 _ 45 (the last version of Java SE 6, no longer updated) binfile, the downloaded installation file jdk-6u45-linux-i586.bin placed in the path/tmp.
2. Execute commands in the shell to grant the executable permission to the shell.
Sudo chmod u + x/tmp/jdk-6u45-linux-i586.bin
3. Install it in the current directory (/usr/app /)
Cd/usr/app/
2 sudo/tmp/jdk-6u45-linux-i586.bin # execute installation
3 sudo mv/usr/app/jdk1.6.0 _ 45/usr/app/jdk1.6 # Rename the folder
So far, jdk has been installed.
4. Set environment variables
You can set environment variables in Linux using the following methods:
/Etc/environment is used to set the environment of the entire system. It has nothing to do with the login user.
/Etc/profile is used in the environment of all users and is executed upon logon.
~ /. Profile is used to set the environment of the current user. It is executed at login.
~ /. Bashrc is dedicated to the bash information of the current user's bash shell. Each time a new shell is opened, the file is executed
When logging on to the system, the shell reads:/etc/profile & rarr;/etc/enviroment & rarr ;~ /. Profile & rarr ;~ /. Env (if any), the logon prompt is displayed in English when export LANG = zh_CN is added to/etc/profile, and the logon prompt is displayed in Chinese when LNAG = zh_CN is added to/etc/environment.
4.1 add the following content to the file/etc/environment to set the system environment variables:
PATH = "... :/Usr/app/jdk1.6/bin"
2 CLASSPATH = ".:/usr/app/jdk1.6/lib"
3 JAVA_HOME = "/usr/app/jdk1.6"
Save and use the source command to make it take effect:
Source/etc/environment
4.2 add the following content to the file/etc/profile to modify the environment variables of all users:
Export JAVA_HOME =/usr/app/jdk1.6
2 export JRE_HOME =$ {JAVA_HOME}/jre
3 export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
4 export PATH =$ {JAVA_HOME}/bin: $ PATH
Save and use the source command to make it take effect immediately:
Source/etc/profile
~ /. Profile and ~ The/. bashrc file is modified in the same way.
4.3 execute the following command in shell to set the variables temporarily:
Export JAVA_HOME =/usr/app/jdk1.6
2 export JRE_HOME =$ {JAVA_HOME}/jre
3 export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
4 export PATH =$ {JAVA_HOME}/bin: $ PATH
This method is only for temporary use. It is troublesome to reset it every time you open the shell.
5. Configure the default java interpreter and compiler
If multiple JDKs are installed in the system, you must run the following command to set the default jdk:
# Add a link value for java and javac commands
2 sudo update-alternatives -- install/usr/bin/java/usr/app/jdk1.6/bin/java 300
3 sudo update-alternatives -- install/usr/bin/javac/usr/app/jdk1.6/bin/javac 300
4 # select a link value for java and javac commands
5 sudo update-alternatives -- config java
6 sudo update-alternatives -- config javac
6. Configure the JVM priority.
Add
/Usr/app/jdk1.6
7. Run the following command to test whether the installation is successful.
Java-version
The system uses the jdk We just installed, as shown in the figure below:
Install tomcat
1. First download the tomcat installer
The latest tomcat 6 version is 6.0.36. Place the downloaded tomcat package apache-tomcat-6.0.36.tar.gz under the path/tmp.
2. Decompress the package to the specified directory.
Sudo tar zxf/tmp/apache-tomcat-6.0.36.tar.gz-C/usr/app/
2 sudo mv/usr/app/apache-tomcat-6.0.36 // usr/app/tomcat6
3. Set environment variables
Modify the tomcat6/bin/catalina. sh script and add the following content at the beginning of the file:
JAVA_HOME =/usr/app/jdk1.6
2 JAVA_OPTS = '-Xms128M-Xmx512M-XX: MaxNewSize = 256 m-XX: MaxPermSize = 256m'
Set the environment variable JAVA_HOME and startup parameters:
-Xms: jvm initial memory
-Xmx: maximum jvm memory
-XX: MaxNewSize: maximum heap memory occupied by the new generation
-XX: MaxPermSize: the maximum value of Perm (commonly known as the method area) in the whole heap memory
Now, Tomcat 6 has been installed. You can use the command
Sudo/usr/app/tomcat6/bin/startup. sh
2 sudo/usr/app/tomcat6/bin/shutdown. sh
Start and close the tomcat program,
After tomcat is started, visit http: // localhost: 8080 in the browser to view the tomcat page.
In fact, the environment variable JAVA_HOME has been set in/etc/envirment. If it is not set in catalina. sh, the error still persists and tomcat cannot be started, as shown in the following figure. The cause is unknown.
4. Set the Tomcat administrator account
Tomcat user account information is saved in the tomcat6/conf/tomcat-users.xml file, add
<User username = "tomcat" password = "tomcat" roles = "admin, manager"/>
You can add the username and password as the administrator account of tomcat. You can log on to and manage tomcat on the web.
Install MySQL
1. First download the MySQL installation file
MySQL has released many official versions, but not for ubuntu. Therefore, you can only select the binary distribution version and source code distribution version. The file name format of the MySQL binary distribution is mysql-version-os.tar.gz, where version is the version number (such as 5.6.11), OS represents the operating system type of the distribution installation (such as linux-glibc2.5-i686), this article takes the mysql-5.6.11-linux-glibc2.5-i686.tar.gz as an example, download and place it in the path/tmp.
2 ,........
--------------------------------------------------------------------------------
Network Configuration
1. First, configure the network address and other information of the NIC.
Add the following content to the/etc/network/interfaces file:
Auto eth0
2 iface eth0 inet static
3 address 192.168.16.110
4 netmask 255.255.252.0
5 gateway 192.168.16.1
Modify the IP address according to the actual situation. Of course, if the server uses DHCP to allocate IP addresses, you only need to write
Iface eth0 inet dhcp
No need to set address/netmask/gateway. If multiple NICs exist, configure eth0 and eth1 in sequence.
2. Modify the DNS server
Modify the/etc/resolv. conf file and add the DNS server address:
Nameserver 202.96.209.5
2 nameserver 202.113.16.11
3. Restart the networking service.
Sudo/etc/init. d/networking restart
In this way, you can connect to the network. If you are using ADSL, you may need to install pppoe and other things.