Tencent cloud host - install java development environment under linux system

Reference address: http://blog.csdn.net/huangxingzhe/article/details/45077457

 

The installation system environment is: centos6.5 64-bit

 

1. Install ftp     If ftp is not installed on Linux, it is impossible to upload software;

    Check if the ftp command is installed: rpm -qa | grep ftp

    The command to install ftp: yum install -y vsftpd   (this command downloads and installs ftp directly from the Internet)
    Run the ftp command: /etc/init.d/vsftpd start

 

    If you don't want to use ftp to upload, you can also use SecureCtr to upload and download files from the server.
    First install the lrzsz command: yum -y install lrzsz
    Check if the SecureCtr command is installed: rpm -qa | grep lrzsz
    Download the file on the server to the client command : sz
    upload the file from the client to the server command: rz
    Reference address: http://blog.csdn.net/lioncode/article/details/7921525

 

2. Install jdk

    1. Create the directory /root/javaSet/jdk

 

    2. Add permissions for jdk-6u45-linux-x64.bin, as shown in the figure

   

  

    3. Download the jdk file jdk-6u45-linux-x64.bin , put the file in the /root/javaSet/jdk directory, and then run the file (running this file is to install jdk, run the file in the liunx system to ./file name to run) , as shown in the figure 

   

   

   4. Configure the java environment variables and add the following at the end of the file /etc/profile:

#set java
JAVA_HOME=/root/javaSet/jdk/jdk1.6.0_45;export JAVA_HOME
JRE_HOME=/root/javaSet/jdk/jdk1.6.0_45/jre;export JRE_HOME
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin;export PATH
export CLASSPATH=$CLASSPATH:$PATH:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JRE_HOME/lib:.

    

    5. source /etc/profile (reactivation)
    6. Run java -version to see if it is successful

 

3. Install tomcat

     1. Create the directory /root/javaSet/tomcat

     2. Download the tomcat file: apache-tomcat-7.0.47.tar.gz, copy it to the /root/javaSet/tomcat directory
     3. Unzip the tar -zxvf apache-tomcat-7.0.47.tar.gz, after the file named "tomcat7"

     4. Go to the setclasspath.sh file in the tomcat/bin directory to set the java environment, and add the following two lines (put it at the top of the file, because it needs to be set before the application) :

export JAVA_HOME=/root/javaSet/jdk/jdk1.6.0_45
export JRE_HOME=/root/javaSet/jdk/jdk1.6.0_45/jre

     5. Set the tomcat service to start
     and save the following content to the /etc/init.d/ directory, the file name is tomcat

#!/bin/bash
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat by ton
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.

set -m
CATALINA_HOME="/root/javaSet/tomcat/tomcat7"
if [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
  . /etc/rc.d/init.d/functions
else
  echo -e "/atomcat: unable to locate functions lib. Cannot continue."
  exit -1
be
# running tomcat services
RETVAL=$?
case "$1" in
start)
  if [ -f $CATALINA_HOME/bin/startup.sh ];then
    echo $"Starting Tomcat"
    $CATALINA_HOME/bin/startup.sh
  be
  ;;
stop)
  if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
    echo $"Stopping Tomcat"
    $CATALINA_HOME/bin/shutdown.sh
  be
  ;;
restart)
  if [ -f $CATALINA_HOME/bin/startup.sh ];then
    echo $"Starting Tomcat"
    $CATALINA_HOME/bin/startup.sh
  be
  sleep 5
  if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
    echo $"Stopping Tomcat"
    $CATALINA_HOME/bin/shutdown.sh
  be
  ;;
*)
  echo $"Usage: $0 {start|stop|restart}"
  exit 1
  ;;
esac
exit $RETVAL

    6. Add run permissions to the file
         chmod +x /etc/init.d/tomcat

    7. Start the tomcat service

          service tomcat start

 

Fourth, the installation of mysql
    linux is mainly to compile and install, you need to prepare: cmake tool
    1. yum install gcc gcc-c++ ncurses-devel perl (install the tools and libraries required to compile the source code)

    2. Create a directory /root/toolFile

    3. Download cmake-3.0.1.tar.gz , copy to /root/toolFile directory, decompress:
        tar -xzvf cmake-3.0.1.tar.gz

    4. Define the working directory to the decompressed folder
        cd cmake-3.0. 1

    5. Then enter the following command./bootstrap
        ; make ; make install

    6. Add mysql user group and user command:
        groupadd mysql
        useradd -r -g mysql mysql

    7. Create a new mysql installation directory and storage data directory:
        mkdir -p /usr/local/mysql
        cd /usr/local/mysql
        chown -R mysql:mysql . (assign permissions)

        mkdir -p /var/mysqldata
        cd /var/mysqldata
        chown -R mysql:mysql . (assign permissions)

    8. Create a directory /root/javaSet/mysql

    9. Download mysql-5.5.38.tar.gz , and copy it to the created file, decompress it:
        tar -zxvf mysql- 5.5.38.tar.gz

    10. Enter the decompressed folder
        cd mysql-5.5.38 (enter the directory first)

    11. (enter the mysql-5.5.38 directory first) and then execute the cmake command:
cmake -DCMAKE_INSTALL_PREFIX=/ usr/local/mysql \
-DMYSQL_UNIX_ADDR=/var/mysqldata/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY 1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysqldata \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

    12. Recompile:
        make
        make install

    13. Go to the directory /usr/local/mysql and execute:
        cd /usr/local/mysql
        cp support-files /my-medium.cnf /etc/my.cnf

    14. Before executing the initialization database , you
        need to give the scripts/mysql_install_db file execution permission
            chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql / \
--datadir=/var/mysqldata/

    15. Set the startup of mysqld
        cp support-files/mysql.server /etc/init.d/mysql
        chmod 755 /etc/init.d/mysql
        chkconfig mysql on
   
16. Go to the /etc/profile file to configure the MySQL environment variable and
        add
            #mysql
            export PATH=/usr/local/mysql/bin:$PATH
            alias mysql_start="mysqld_safe &"
            alias mysql_stop="mysqladmin -u root - at the end of the profile file p shutdown"
       
        and then reconfigure
            source /etc/profile (restart configuration)

    17. Start mysql service
        /etc/init.d/mysql start
    
    18. Command to check whether
        ps -ef |grep mysql

    19. Log in to mysql
        mysql -uroot -p
        The newly installed mysql does not have a password by default. Here you are prompted to enter a password, just press the space bar.     

    20. Modify the password of the MySQL user root
        The first way, use the command
              mysqladmin -u root -p password 'root' outside the mysql system;
       
         The second way, by logging in to the mysql system
                mysql -uroot -p
                Enter password: [Enter the original password]
                mysql>use mysql;
                mysql> update user set password=passworD("test") where user='root';
                mysql> flush privileges;
                mysql> exit;    

 
    21. Show all databases
        show databases

    22. Select database (use database name)
         use databaseName

    23. Show all tables
          show tables
 
5. Install the decompression software 7z under linux
    1. Online installation command           
        yum -y install p7zip
       
    2. Check whether the installation is successful
        rpm -qa | grep p7zip
       
    3. Unzip the compressed file
        7za x test.7z -r -o./Parameter
       
        meaning:
            x Represents decompressed files, and is decompressed according to the original directory tree (there is also a parameter e that is also decompressed files, but it will decompress all files to the root instead of its own original folder) test.7z is compression File
            -r means to recursively decompress all subfolders
            -o is the specified directory to be decompressed, there is no space after -o, and the directory is directly connected. This needs attention.
       
    4. Compressed files/folders
        7za a -t7z -r test.7z webapps/test/*

        parameter meaning:
            a represents adding files/folders to the compressed package
            -t is the specified compression type, here it is set to 7z, it can be not specified, because The default compression type of 7za is 7z
            -r, which means recursively all subfolders
            test. 7z is the name of the compressed package. You can choose the storage path of the compressed file by adding a path in front of it.
            webapps/test/*: is the compression target.
            Note: The compressed file is in the current working directory by default. 7za not only supports the .7z compression format, but also supports compression types such as .tar.bz2. As mentioned above, you can specify it with -t.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327100861&siteId=291194637