environment variable files and configuration in Linux

Source: Internet
Author: User
Tags tomcat server apache tomcat

Introduction of environment variable file

Transferred from: http://blog.csdn.net/cscmaker/article/details/7261921

Environment variables in Linux include system-level and user-level, system-level environment variables are system variables to be read by every user logged into the system, and user-level environment variables are the environment variables that are loaded when the user uses the system.
Therefore, the management environment variable files are also divided into system-level and user-level, the following posted on the Internet to find a more clear description of the document (slightly modified) [1]:

1. System level:
(1)/etc/profile: This file is the first file that is used when the user logs on, the operating system customizes the user environment, and applies to every user who logs on to the system. This file is typically called the/ETC/BASH.BASHRC file.
/ETC/BASH.BASHRC: System-level BASHRC file.
(2)/etc/environment: The second file that the operating system uses when logging on, the system sets environment variables for environment files before reading your own profile.

2. User level (these files are in the home directory):
(1) ~/.profile: Each user can use this file to enter the shell information dedicated to their own use, when the user log on, the file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file. This is where personal settings are recommended.
(2) ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell. It is not recommended to put it here, because every time you open a shell, the file will be read once and the efficiency must be affected.
~/.bash_profile or ~./bash_login: There is no reference to the author here, the following will mention
~/.pam_environment: User-level environment variable settings file, did not do the test, do not know whether the tube is used.


Through the above file introduction, we can understand that we need to set the environment variables when the need to modify what files, in order to be effective for all users, it is necessary to set the system-level environment variables. Conversely, you need to modify the user-level files (preferably modify the. profile file for the reason above).

In addition, I am using Ubuntu10.04, previously in the search data set user-level environment variables, there is data to modify the ~.bash_profile file, but in the ubuntu10.04 system is not the file. This document was found on the Ubuntu website [2]:

~/.bash_profile or ~./bash_login-if One of the these file exist, bash executes it rather then ~/.profile if it is Starte D as a login shell. (Bash would prefer "~/.bash_profile" to "~/.bash_login"). However, these files won ' t influence a graphical session by default.

This means that when the file is present, the./bash_profile file is read when you log in to the shell, not the. profile file. I think the purpose of this file is the same as the. profile file, when you need to modify the. bash_profile file, but you don't have the file, you can also modify the. Profile to complete the implementation.

[1]http://cab402.appspot.com/2010/05/1/ubuntuenvironmentvariablesset.html

[2]https://help.ubuntu.com/community/environmentvariables

Second, the configuration environment variable actual combat

1. Configure Java Environment variables

(1) First download the JDK installation files on the official website, I downloaded as: jdk-7u5-linux-i586.tar.gz, of course, can also download. bin format files, but this file with the tar format described in this article is different in terms of decompression, here is no longer described in detail;

(2) Unzip the file, the extracted file name is: jdk1.7.0_05; copy it to a file directory, I put in:/home/stopit/software directory, so the current JDK path is/home/stopit/software/ Jdk1.7.0_05, here will/home/stopit/software/jdk1.7.0_05 with XXX replacement;

(3) According to several Linux environment variable files described above, we select the profile file to write our environment variables, open the file with the Suodo gedit/etc/proifle command, and enter the following command:

#修改java运行环境
Export java_home= "XXX"
Export path= "$PATH: $JAVA _home/bin"
Export jre_home= "$JAVA _home/jre"
Export Classpath= ".: $JAVA _home/lib: $JRE _home/lib"

(4) After the completion of the modification, use the source/etc/profile command to update;

(5) The following steps are important, because OPENJDK is preinstalled on many Linux systems, so even if these settings are set up above, the default is not what we want to set up, and if you want to actually use our own JDK, you need to take steps:

sudo update-alternatives--install/usr/bin/java Java xxx/bin/java 300

sudo update-alternatives--install/usr/bin/javac javac Xxx/bin/javac 300

(The 300 here is just a sign, it doesn't make sense, it's just the next step )

sudo update-alternatives--config java

Performing this step will list all installed Java on the system , then choose the one that is the last 300

sudo update-alternatives--config javac

Ditto

Note: Some articles say that you can only use the following statements:
sudo update-alternatives–config Java, I have not tried!

(6) Done, use the java-version command to view our Java environment variables and display the following:

Java Version "1.7.0_05"
Java (TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot (TM) Server VM (build 23.1-b03, Mixed mode)

2. Configuring the Tomcat environment variable

(1) Download the Tomcat package from the official website.

http://tomcat.apache.org/

Click on the left of a version of the download, I chose the tomcat6.x, you can choose to install according to their actual situation, click the hyperlink, select Binary Distributions under the tar.gz (PGP, MD5) compressed package, to download

(2) After downloading to the local, the decompression

#tar ZXVF apach-tomcat-6.0.16.tar.gz

#mv apach-tomcat-6.0.16/usr/local

(3) Configure the Tomcat environment (if JDK installation is required)

sudo geidt/etc/profile

Enter the following content

Export TOMCAT_HOME=XX

xx Ibid, for your Tomcat installation path

Save exit

(4) # Source/etc/profile//Let current configuration take effect immediately

(5) Start the Tomcat server and run the following:

sudo xx/bin/startup.sh

Note: (Cannot manually double-click the file under the startup.sh execution), temporarily do not know whether it is feasible

The following will appear on my computer:

Using catalina_base:/usr/local/apache-tomcat-6.0.16

Using Catalina_home:/usr/local/apache-tomcat-6.0.16

Using Catalina_tmpdir:/usr/local/apache-tomcat-6.0.16/temp

Using Jre_home:/usr/local/jdk1.6.0_04

(6) Enter http://localhost:8080/in the browser to see Tomcat's log.

The installation of Tomcat ends here.

(7) If you encounter problems, refer to: http://forum.ubuntu.org.cn/viewtopic.php?t=183813

(8) Subsequent configuration:

--Stop the Tomcat service
$sudo/opt/tomcat/bin/shutdown.sh


--Get MySQL JDBC and enter HTTP in the address bar of the Firefox browser://dev.mysql.com/get/downloads/connector-j/ Mysql-connector-java-3.1.10.tar.gz/from/http://mysql.cbn.net.id/to get the software.


--Installing JDBC
$tar-ZXVF mysql-connector-java-3.1.10.tar.gz
$sudo CP Mysql-connector-java-3.1.10/mysql-connector-java-3.1.10-bin*.jar/usr/lib/j2sdk1.5-sun/lib

--Configure the port of Tomcat

The Ubuntu-brought Tomcat opens the 8180 port, which is neither regular nor beneficial. We can make some simple modifications to let Tomcat use the other ports for service. In terminal, enter
sudo gedit/usr/share/tomcat5/conf/server.xml

Look in the configuration file
<connector classname= "Org.apache.coyote.tomcat5.CoyoteConnector" port= "8180"

and replace 8180 of them with the required ports. In general, it can be replaced by 80 or 8080. If set to 80, you can access the Tomcat page by typing http://localhost directly into the browser. Restart Tomcat to take effect.

--Set up Tomcat Administrator account

Tomcat's user account information is stored in the Tomcat-users.xml file and runs
sudo gedit/usr/share/tomcat5/conf/tomcat-users.xml

Add a line before the </tomcat-users> label
<user username= "User name" password= "password" roles= "Admin,manager"/>

Save and close. Rerun Tomcat to enter the user name and password and log into the Tomcat administration page.

--Install the latest version of Tomcat

We next introduce the Tomcat software that downloads and uses the latest version of 5.5.17 directly from the Apache Tomcat home page, which is quick and easy and does not affect the stability of the system.

From the official download page of Tomcat http://tomcat.apache.org/download-55.cgi

After downloading the zip or tar.gz package in the Binary->core category, local unzip and rename the newly generated directory to Tomcat for ease of use. Move this folder to a path path/. Refer to the above setting environment variables and port settings, and so on! Run directly


PS, start with Apt-get installation tomcat5.5, always appear unable to install success, in shutdown, out Java exception, finally there is no way, with
sudo apt-get remove tomcat5.5
Let's unload it. Download and install again without apt-get

environment variable files and configuration in Linux

Related Article

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.