Linux java environment installation

I did it myself. share with everyone, 

 

1.jdk installation

 

download jdk-7u67-linux-x64.tar.gz

oracle download URL click to open the link
There may be some updates, download the official website click to open the link
sudo mkdir /usr/lib/jvm
sudo tar zxvf jdk-7u67-linux-x64.tar.gz -C /usr/lib/jvm 
 set up
environment variable:
1. Terminal execution: sudo gedit /etc/environment or sudo vi /etc/environment

Add the bin directory of jdk after the existing PATH variable, pay attention to separating it from the existing variable with a colon

Add the CALSSPATH and JAVA_HOME variables again

My situation is as follows:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/tecn/jdk1.7.0_55/bin"

CLASSPATH="/home/tecn/jdk1.7.0_55/lib:." Note that there is a dot behind

JAVA_HOME="/home/tecn/jdk1.7.0_55/"

After setting, logout or restart to make the environment variable take effect!

2.
sudo gedit /etc/profile 
Add environment variable content
#set java environment
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH  
 
 Set default JDK
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_67/bin/java 300  
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_67/bin/javac 300  
test
java -version
 
2.tomcat installation:
 1) Download tomcat

       http://tomcat.apache.org/

Download the tar.gz file under the core. Tomcat 6/7 will do.

              2) Unzip

       Right-click to use the archive manager to open and drag it out. Unzip using the command.

      Switch to the download directory of tomcat on the terminal, and then enter

     tar -vzxf XXX-tomcat-XXX.tar.gz

 

 3) Configure the environment

Open the tomcat directory and enter the bin directory. Use right-click to open the startup.sh file with gedit and add at the bottom of the file:

 

#JAVA_HOME is the installation path of JDK

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_76

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

#TOMCAT_HOME is the decompression path of tomcat

TOMCAT_HOME=/atools/tomcat8081

 


4) Start and close tomcat

      Right-click in the bin directory of tomcat and open it in the terminal. After opening the terminal, enter the following command to start the server:

              sudo ./startup.sh


      Enter the following command to shut down the server:

              sudo ./shutdown.sh

 3. Install mysql:

Update source list

Open the "Terminal Window", enter "sudo apt-get update" --> Enter --> "Enter the password of the root user" --> Enter, that's it. If you do not run this command and install mysql directly, there will be an error message that "there are several packages that cannot be downloaded, you can run apt-get update------", resulting in failure to install.

 

Installing mysql on ubuntu is very simple and can be done with just a few commands.

     1.apt-get update

 

  2. apt-get install mysql-server
 
  3. apt-get install mysql-client
 
  4. apt-get install libmysqlclient-dev
During the installation process, you will be prompted to set a password or something. Be careful not to forget the settings. After the installation is complete, you can use the following command to check whether the installation is successful:
 
   sudo netstat -tap | grep mysql
 
  After checking through the above command, if you see that the mysql socket is in the listen state, the installation is successful.
 
  To log in to the mysql database, use the following command:
 
   mysql -u root -p 
 
  -u means to select the user name to log in, -p means the user password to log in, after the above command is entered, you will be prompted to enter the password, at this time, you can log in to mysql by entering the password.
 
Then through  show databases ; you can view the current database.
  We select the mysql database and proceed to the next step. Use the use mysql  command to display the form of the current database: show tables  .
 
Finish.
 MySQL installation layout under ubuntu:
/usr/bin client program and mysql_install_db
/var/lib/mysql database and log files
/var/run/mysqld server
/etc/mysql configuration file my.cnf
/usr/share/mysql character set, benchmark program and error messages
/ etc/init.d/mysql start mysql server
 
Remote access to mysql:
 
1. root123 is the password
GRANT root can log in to MySQL on any IP, grant all privileges on *.* to root@'%' identified by ' root123 ';
flush privileges;
2. Modify the /etc/mysql/my.cnf file on the cloud host and comment out bind_address=127.0.0.1. This sentence is ok.
 
or:
For example, if you want myuser (username for remote connection) to use mypassword (password for remote connection) to connect to mysql server from any host.   
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WI   
TH GRANT OPTION;   
If you want to allow user myuser (username for remote connection) from ip 192.168.1.6 (on your test computer IP) to connect to the mysql server and use mypassword (the password for the remote connection) as the password   
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.6' IDENTIFIED BY   
'mypassword' WITH GRANT OPTION;   
flush privileges;
 
 
 
 Chinese garbled in the database solution:

Set the character set used by server level, db level and table level to utf8.

Setting method:

Check the mysql character set status:

First use the client tool mysql to log in: 

mysql> status

Set the server-level character set:

Edit the /etc/mysql/my.cnf file

 

 [client]
default-character-set=utf8
 
[mysqld]
character_set_server=utf8
Note: You can also use default-character-set=utf8 at [mysqld]. If there is an error in starting the mysql service, use character_set_server=utf8.

 

 

Set the db-level character set:

Creating a database is specifying:

mysql> create database mytest character set utf8;

Modify the existing database character set:

mysql> alter database character set utf8; 

 

Set the table character set:

Specify when creating the table:

mysql> create table mytable(id int auto_increment primary key) character set utf8; 

 

Modify the character set of the table:

mysql> alter table mytable character set latin1;

 

If Chinese characters are to be stored in the data, utf8 is recommended.

In addition, modifying the character set is only valid for the data added later, and the existing data will not be changed.

 

 

 

 

Nginx installation:

 sudo apt-get update

 

sudo apt-get install nginx

 

 Ubuntu 14.04 By default, Nginx starts automatically after installation.

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

 

You will get a line or two, try each line in the browser to see if it works.

Another way is to type this line, which should return you the public IP, as seen from another address on the web:

 

After getting your server IP or domain name, enter it into your browser address bar:

http://server_domain_name_or_IP

To stop the web server, sudo service nginx stop

Start the web server sudo service nginx start

 stop and start the server again sudo service nginx restart

It can be confirmed that when the server restarts, the web server will automatically restart:

sudo update-rc.d nginx defaults

 This should be possible by default, so you might see something like this:

System start/stop links for/etc/init.d/nginx already exist.

The file structure after Ubuntu installation is roughly as follows:

  • All configuration files are under /etc/nginx, and each virtual host has been arranged under /etc/nginx/sites-available
  • Program files are in /usr/sbin/nginx
  • The log is placed in /var/log/nginx
  • and have created the startup script nginx under /etc/init.d/
  • The default virtual host directory is set to /var/www/nginx-default (in some versions, the default virtual host directory is set to /var/www, please refer to the configuration in /etc/nginx/sites-available)

Then you can visit, http://localhost/  , and everything works! If you can't access, don't continue, see what is the reason, and then continue after solving. If it shows that port 80 is occupied at startup: Starting nginx: [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) Modify the file: /etc/nginx/sites-available/default, remove listen The preceding # and # are comments in this file, and the port number 80 after listen is changed to your own port, and the port number needs to be added for access.

(If there is a 403 error after installation, it may be that the website path in the nginx configuration file is incorrect)

Add access address:

location /ace/{

            alias /atools/tomcat-ace/imagePic/;

        }

 

Start nginx sudo /etc/init.d/nginx start

 

 

Modify the configuration and add a reverse proxy

1.4 is installed by default, and the nginx->config->nginx.conf file is modified. The reverse proxy does not work. Under win, 1.5 is to modify this configuration file.

Finally, the /etc/nginx/sites-available/default file was modified 

 

 Nginx adds multiple tomcat80 ports:

First change the port to 80

 

 location /ace/{

            alias /atools/tomcat-ace/imagePic/; 

            proxy_pass http://124.57.215.188:8080;

        }

 

        location /star/{

            alias /atools/tomcat8081/imagePic/;

            proxy_pass http://124.57.215.188:8081;

        }

 

         location /testSwfupload/{

            alias /atools/tomcat8082/imagePic/;

            proxy_pass http://124.57.215.188:8082;

        }

 

 If accessing the same app:

upstream star{
        server 124.57.215.188:8080;
        server 124.57.215.188:8081;

}

 

location /Content/ {
        alias /var/www/nancydemo/Content/;
        location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf)$ {
            expires 365d;
        }
    }

 

 location /{

            alias /atools/tomcat8082/imagePic/;

            proxy_pass http://star;

        }

 

 

tomcat domain name access:

tomcat set IP address or domain name access

1. Find the home directory of tomcat, enter the conf folder, find the server.xml file, and open it:

Modify the listening port of tomcat to port 80:

Found in the server.xml file:

    <Connector port="8080" protocol="HTTP/1.1"               connectionTimeout="20000"               redirectPort="8443" />

changed to:

    <Connector port="80" protocol="HTTP/1.1"               connectionTimeout="20000"               redirectPort="8443" />

 

2.

Found in the server.xml file:

      <Host name="localhost"  appBase="webapps"            unpackWARs="true" autoDeploy="true">

Replace localhost in the content found in point 3 with the IP address or domain name address you want to modify. As shown in the figure, it is my modified configuration

 

 

3.

In the middle of the <host></host> tags, add the following:

<Context path="" docBase="/mytestweb"/>

Note: The value of docBase can also be an absolute path.

As shown in the figure, it is my modified configuration:

 

 

 
 
 
 

Guess you like

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