A complete tutorial on building a JavaWeb project on a Window10 server

content

The use of window10 remote desktop connection tool

window10-64-bit server installs Redis and starts automatically with the system

Install the database

Configure the Java runtime environment on the server

Install static file server Nginx

Deploy the front-end and back-end of the JavaWeb project

The use of window10 remote desktop connection tool

  1. How to open the window10 remote desktop connection tool: use the shortcut key combination win+r, open the run, and enter mstsc to open the tool; or search directly in the search window.
  2. Use the "Remote Desktop Connection Tool" that comes with win10 to connect to the server (the system version of the server should be win10 professional version or higher, otherwise the remote desktop connection cannot be used), open the tool as shown below:

window10-64-bit server installs Redis and starts automatically with the system

  1. You can download the window version of redis through the official website and GitHub, but it may be slow to download in this way. You can download it from my Baidu cloud: link: https://pan.baidu.com/s/1--9OQDpPC12LBxTH6VtccQ
    Extraction code: ylt9, version is redis-5.0.9
  2. Unzip the downloaded installation package to your favorite disk location, find the directory you just unzipped through cmd, and enter the following command
  3. redis-server redis.windows.conf  //Enter this startup command in the command line
  4.  
  5. The above picture is only a temporary start, the program is not in the window service, when the command line is closed, the program will be automatically closed; so it should be configured to start automatically.
  6. set up redis service, command:
    redis-server --service-install redis.windows-service.conf --loglevel verbose
    // After running, there is no error prompt to prove that the setting is successful, and the redis service can be seen in the system service
  7. Content reference https://www.cnblogs.com/yunqing/p/10605934.html Blogger article, more use of redis can refer to Chinese website http://www.redis.net.cn/
  8. Common redis Operation command: 
    Uninstall the service: redis-server --service-uninstall
    
    Start the service: redis-server --service-start
    
    Out of service: redis-server --service-stop

Install the database

  1. Install the corresponding database according to your needs
  2. For example: SQL server database, MySQL database, Oracle database, pay attention to the version problem during installation, the installation process will not be repeated here, you can query the tutorial on Baidu.

Configure the Java runtime environment on the server

  1. To determine the Java-JDK version used by your own JavaWeb program, here is JDK1.8, the specific version is: jdk-8u271-windows-x64; you can go through the link: https://pan.baidu.com/s/ 1SSVcGzKLQ7l4FFoQOcdoAQ
    Extraction code: fb4c to download.
  2. Keep clicking Next to install. After the installation is complete, you must configure the environment variables, otherwise it will not work normally.
  3. // To add system environment variables CLASSPATH and JAVA_HOME, the corresponding values ​​are as follows:
    CLASSPATH    .;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar
    
    JAVA_HOME    D:\Program Files\Java\jdk1.8.0_144 // Fill in your own installation path
    
    // Add configuration to PATH system environment variable
    PAHT   %JAVA_HOME%\bin

     

  4. There is no error message when entering Java and Javac on the command line, which proves that the Java runtime environment is successfully installed. 

Install static file server Nginx

  1. Nginx is mainly used to run files packaged by vue-cli
  2. nginx-1.14.2 version nginx can be downloaded through the link: https://pan.baidu.com/s/1E-U-gILKtHU1j0otsuwd5w Extraction code: 8cdu
  3. After the download is complete, unzip it to your favorite folder, double-click the ngxin.exe command, start nginx, and enter 127.0.0.1 in the browser to see the nginx welcome page.
  4. If you can't see the welcome page, it proves that the port 80 monitored by nginx is occupied, you need to modify the nginx.conf configuration file, and modify the prompt location in the following figure:
  5.    location / {
    
    	root   C:\program\dist; // The disk location of the packaged dist folder of vue-cli, which contains the index.html file
    	try_files $uri $uri/ /index.html; // Find the index.html file, the entry file of the vue project
        index  index.html index.htm;
    
       }
    
    
        // Here is the cross-domain configuration of my project, which can be reserved or removed for reference. The location configuration above must have
       location /prod-api/{
        
    	proxy_set_header Host $http_host;
    	proxy_set_header X-Real-IP $remote_addr;
    	proxy_set_header REMOTE-HOST $remote_addr;
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    	proxy_pass http://localhost:8080/;
    
       }
  6. Put the vuecli packaged dist folder in the specified location, and click nginx.exe again to start the service. 

Deploy the front-end and back-end of the JavaWeb project

  1. For the packaging process of the Vue project, please refer to the official website. The generated dist folder is placed in the correct location configured by the nginx.conf configuration file.
  2. Java projects can be typed into Jar packages, and the following commands can be executed directly in the command prompt to start:
    java -jar The name of the packaged file.jar
     

 

 

Tags: server

Posted by unkwntech on Sat, 07 May 2022 04:09:31 +0300