菜单

Ubuntu_22.04安装文档

下载

Ubuntu_22.04安装文档

一、安装JDK

1.1 在线安装

有互联网环境的服务器,在安装时可以接使用apt命令安装

sh 复制代码
#使用命令查看相关包,此项目安装JDK8.
sudo apt-cache search jdk
image-20230815190144110
sh 复制代码
#安装需要的版本号。
 sudo apt-get install openjdk-8-jdk
 #成功后使用命令查看版本号,确认是否安装成功。
 java -version
image-20230815190712952

1.2 离线安装

在无网络环境部署时,可先在有网络的环境,使用apt --download-only参数,只下载不安装命令把需要的包下载到本地。

一定是无网络环境的操作系统版本与有网络版本一至,否则可能会有些依赖包版本冲突

sh 复制代码
#使用apt-cache search jdk命令查询可安装的版本。
sudo apt-cache search jdk
image-20250730105321860
sh 复制代码
#使用下载命令,把包下载到本地是使用。
sudo apt --download-only install openjdk-8-jdk
#所有的依赖和包都会下载到/var/cache/apt/archives/下
cd  /var/cache/apt/archives/
image-20250730113343474
sh 复制代码
#可使用tar命令把所有的deb包打包到目录下以传递至无网络环境使用。
tar zcvf jdk8.tar.gz *.deb
#clean命令可清除/var/cache/apt/archives/路径下哦缓存包。
apt clean
image-20250730113757209
sh 复制代码
#把下载好的jdk的tar包上传至无外网的服务器,解压后使用dpkg命令安装使用。
tar xvf jdk8.tar.gz
#安装JDK,*代表全部。
sudo dpkg -i *.deb
#验证JDK安装是否成功
java -version
image-20230306210202652

二、安装Nginx

2.1 在线安装

sh 复制代码
#服务器在联网环境下,可直接使用apt安装nginx。
#新安装系统需先执行
sudo apt-get update
#安装命令
sudo apt-get  install nginx
#执行期间会提示是否安装,Y同意,N不同意。
y
#等待安装结束即可。

2.2 离线安装

在无网络环境部署时,可先在有网络的环境,使用apt --download-only参数,只下载不安装命令把需要的包下载到本地。

一定是无网络环境的操作系统版本与有网络版本一至,否则可能会有些依赖包版本冲突

sh 复制代码
#使用apt list nginx命令查询可安装的版本。
sudo apt list nginx
image-20250730114516480
sh 复制代码
#使用下载命令,把包下载到本地是使用。
sudo apt --download-only install nginx
#所有的依赖和包都会下载到/var/cache/apt/archives/下
cd  /var/cache/apt/archives/
image-20250730114630518
sh 复制代码
#可使用tar命令把所有的deb包打包到目录下以传递至无网络环境使用。
tar zcvf nginx.tar.gz *.deb
#clean命令可清除/var/cache/apt/archives/路径下哦缓存包。
apt clean
image-20250730114744050
sh 复制代码
#把下载好的nginx的tar包上传至无外网的服务器,解压后使用dpkg命令安装使用。
tar xvf nginx.tar.gz
#使用dpkg命令安装所有包。" *  代表所有文件"
sudo dpkg -i *.deb
#等待安装完成即可。
image-20250730115005714

2.3 nginx命令

sh 复制代码
#启动NGINX
sudo systemctl start  nginx.service
#重启NGINX
sudo systemctl restart  nginx.service
#停止NGINX
sudo systemctl stop nginx.service
#查看服务状态 
sudo systemctl status nginx.service
#加入到开机自启动
sudo systemctl enable  nginx.service 
image-20230306180345751

2.2 修改配置文件

sh 复制代码
#将标准配置文件替换现有Nginx配置文件。
#备份现有配置文件。
cd /etc/nginx
mv ngnx.conf nginc.conf.bak
#替换下行中的配置,替换后重启nginx,等待部署nVisual前端。

以下是nginx配置文件内容,可直接复制使用。

nginx 复制代码
#全局块-------------------------------------------------------------------------------------------------
user  root;
worker_processes  auto;
worker_cpu_affinity auto;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;  #(或/run/nginx.pid实际需要根据nginx安装路径调整)

#events块-----------------------------------------------------------------------------------------------
events {
    worker_connections  1024;
}


#http全局块---------------------------------------------------------------------------------------------
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   60000;
    types_hash_max_size 2048;
		client_max_body_size 100M;
	
	gzip on;
	gzip_min_length 1k;
	gzip_comp_level 6;
	#gzip_proxied any;
	gzip_types text/plain application/json application/javascript application/x-javascript text/javascript text/xml text/css;
	gzip_vary on;
	gzip_buffers 16 8k;
	gzip_http_version 1.1;

	proxy_read_timeout 100000;
	proxy_send_timeout 100000;
    proxy_buffering on;
    proxy_buffer_size 4k;
    proxy_buffers 4 4k;
    proxy_busy_buffers_size 8k;
    #proxy_temp_file_write_size 2048k;
    proxy_max_temp_file_size 128m;
    #proxy_temp_path /etc/nginx/temp;
    #proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
	
#http全局块-server块-------------------------------------------------------------------------------------
    server {     
	#listen  443;
	listen	80;
	#server_name ;
	root  /home/nvisual-frontend/dist;   #前端服务文件路径。
        
	#ssl on;
	#ssl_certificate ssl/nvisual.com.pem;
	#ssl_certificate_key ssl/nvisual.com.key;
	#ssl_session_timeout 5m;
	#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
	#ssl_prefer_server_ciphers on;

	proxy_redirect https:// http://;
	
#http全局块-server块-location块-实际项目除调整后端接口地址外,以下部分无须调整,---------------------------------
	location / {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods *;
        add_header Access-Control-Allow-Headers *;
        index index.html;
        try_files $uri $uri/ /;
		}

	location /report {
        index report.html;
        try_files $uri $uri/ /report.html;
		}

	location /message {
        index message.html;
        try_files $uri $uri/ /message.html;
		}

	location /modelLibrary {
        index  modelLibrary.html;
        try_files $uri $uri/ /modelLibrary.html;
		}

	location /recycle {
        index  recycle.html;
        try_files $uri $uri/ /recycle.html;
		}

	location /account {
        index  account.html;
        try_files $uri $uri/ /account.html;
		}

	location /setting {
        index  setting.html;
        try_files $uri $uri/ /setting.html;
		}

	location /dataExchange {
        index  dataExchange.html;
        try_files $uri $uri/ /dataExchange.html;
		}

	location /relationalView {
        index  relationalView.html;
        try_files $uri $uri/ /relationalView.html;
		}

	location /access {
        index  access.html;
        try_files $uri $uri/ /access.html;
		}
		
	location /business {
            index business.html;
            try_files $uri $uri/ /business.html;
        }
				
	location /attributeStatistics {
        index  attributeStatistics.html;
        try_files $uri $uri/ /attributeStatistics.html;
	}

	location /netWorkTool {
        index  netWorkTool.html;
        try_files $uri $uri/ /netWorkTool.html;
		}

	location /workOrder {
        index  workOrder.html;
        try_files $uri $uri/ /workOrder.html;
		}
	location /systemLog {
        index  systemLog.html;
        try_files $uri $uri/ /systemLog.html;
		}

	location /globalSetting {
        index  globalSetting.html;
        try_files $uri $uri/ /globalSetting.html;
		}

	location /reportAdapter/ {
		proxy_pass http://127.0.0.1:8081/;
		}
	location /reportApi/ {
		proxy_pass http://127.0.0.1:8081/;
		}
	location /diagramApi/ {	
		proxy_pass http://127.0.0.1:8081/;
		proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
		}	
	location /managementApi/ {	
		proxy_pass http://127.0.0.1:8081/;
		}
	location /netWorkToolApi/ {
		proxy_pass http://127.0.0.1:8081/;
		}
	location  /apidoc/ {
		proxy_pass http://127.0.0.1:8081/;
		}
	location /vjmapApi/ {
		proxy_pass http://172.18.20.233:27660/;
	}
	location  /wapi/ {
		proxy_pass http://127.0.0.1:8081/wapi/;
	}
	location  /ig/ {
    	proxy_pass http://172.18.20.232:1880/;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
     }
     ## 独立项目接口配置
     # 项目
     location /projectApi/ {
        proxy_pass http://127.0.0.1:8030/;
     }
     # 工单
     location /workOrderApi/ {
        proxy_pass http://127.0.0.1:8032/;
      }
      
      # 业务
      location /businessApi/ {
         proxy_pass http://127.0.0.1:8033/;
      }
 
      # 资产
      location /billsManagementApi/ {
         proxy_pass http://127.0.0.1:8034/;
      }
      ## 独立项目接口配置
	location /version {
		return 200 2.0.33.3;
	}
}


}

三、安装数据库

3.1 安装postgresql-13

3.1.1 在线安装

sh 复制代码
#官网部署说明地址  https://www.postgresql.org/download/linux/ubuntu/ 
#添加官方源并更新源
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get update
#查看可安装版本。
sudo apt list postgresql-13*
#安装postgresql-13。
sudo apt-get -y install postgresql-13
#等待安装完成即可。

3.1.2 离线安装

在无网络环境部署时,可先在有网络的环境,使用apt --download-only参数,只下载不安装命令把需要的包下载到本地。

一定是无网络环境的操作系统版本与有网络版本一至,否则可能会有些依赖包版本冲突

sh 复制代码
#使用下载命令,把包下载到本地是使用。
sudo apt --download-only install postgresql-13
#所有的依赖和包都会下载到/var/cache/apt/archives/下
cd  /var/cache/apt/archives/
image-20250730144335913
sh 复制代码
#可使用tar命令把所有的deb包打包到目录下以传递至无网络环境使用。
tar zcvf postgresql.tar.gz *.deb
#clean命令可清除/var/cache/apt/archives/路径下哦缓存包。
apt clean
image-20250730144352336
sh 复制代码
#把下载好的postgresql的tar包上传至无外网的服务器,解压后使用dpkg命令安装使用。
tar xvf postgresql.tar.gz
#安装所有deb包。
sudo dpkg -i  *.deb
#等待安装结束,可切换至postgres用户并进入到数据库命令行内。
image-20250730145625323

3.1.3 配置数据库密码

sh 复制代码
#进入数据库并设置密码。
#切换至postgres用户。
sudo su  postgres 
#进入数据库。
psql
#设置密码。
alter user postgres with password '新的密码';
#退出PostgreSQL数据库。
"\q" 或 "ctrl+d" 或 "quit" 或 "exit" 

3.1.4 postgresql命令

sh 复制代码
#启动命令。
sudo systemctl start postgresql.service
#重启命令。
sudo systemctl restart postgresql.service
#加入到开机自启。
sudo systemctl  enable   postgresql.service
#查看服务状态。
sudo systemctl  status  postgresql.service

3.2 安装postgis插件(必须)

3.2.1 在线安装

sh 复制代码
#查询可安装版本
sudo apt search postgresql-13 | grep postgis
#安装postgis
sudo apt install postgresql-13-postgis-3
#等待安装完成后看3.2.3。
image-20230821194206055

3.2.2 离线安装

在无网络环境部署时,可先在有网络的环境,使用apt --download-only参数,只下载不安装命令把需要的包下载到本地。

一定是无网络环境的操作系统版本与有网络版本一至,否则可能会有些依赖包版本冲突

sh 复制代码
#使用下载命令,把包下载到本地是使用。
sudo apt --download-only install postgresql-13-postgis-3
#所有的依赖和包都会下载到/var/cache/apt/archives/下
cd  /var/cache/apt/archives/
image-20250730151518998
sh 复制代码
#可使用tar命令把所有的deb包打包到目录下以传递至无网络环境使用。
tar zcvf postgresql-postgis.tar.gz *.deb
#clean命令可清除/var/cache/apt/archives/路径下哦缓存包。
apt clean
image-20250730151600633
sh 复制代码
#把下载好的postgis的tar包上传至无外网的服务器,解压后使用dpkg命令安装使用。
tar xvf postgresql-postgis.tar.gz
#安装postgis。
sudo dpkg -i *.deb
#等待安装完成后看3.2.3。

3.2.3 对数据库开启postgis插件

sh 复制代码
#开启postgis插件
--------------------------------------
#切换至postgres用户
sudo su  postgres 
#进入数据库
psql
#开启postgis插件
create extension postgis;   
create extension postgis_topology;   
#查看postgis版本,成功打印出版本号为开启postgis插件成功。
SELECT PostGIS_full_version();
#退出查看模式(键入q就会自动退出。)
q
image-20230821204109575

3.3 安装pgrouting插件(必须)

3.3.1 在线安装

sh 复制代码
#在系统里查看可安装的版本
sudo apt search postgresql-13 | grep pgrouting
#安装
sudo apt install postgresql-13-pgrouting
#等待安装完成后。看4.3.3

3.3.2 离线安装

在无网络环境部署时,可先在有网络的环境,使用apt --download-only参数,只下载不安装命令把需要的包下载到本地。

一定是无网络环境的操作系统版本与有网络版本一至,否则可能会有些依赖包版本冲突

sh 复制代码
#使用下载命令,把包下载到本地是使用。
sudo apt --download-only install postgresql-13-pgrouting
#所有的依赖和包都会下载到/var/cache/apt/archives/下
cd  /var/cache/apt/archives/
image-20250730152040703
sh 复制代码
#可使用tar命令把所有的deb包打包到目录下以传递至无网络环境使用。
tar zcvf postgresql-postgis.tar.gz *.deb
#clean命令可清除/var/cache/apt/archives/路径下哦缓存包。
apt clean
image-20250730152121273
sh 复制代码
#把下载好的pgrouting的tar包上传至无外网的服务器,解压后使用dpkg命令安装使用。
tar xvf postgresql-pgrouting.tar.gz
#安装postgis。
sudo dpkg -i *.deb
#等待安装完成后看4.2.3。

3.3.3 对数据库开启pgrouting

sh 复制代码
#切换至postgres用户
sudo su  postgres 
#进入数据库
psql
#开启pgrouting的插件。
CREATE EXTENSION pgrouting;
#查看pgrouting版本。
select pgr_version();
#打印出pgrouting版本号为开启插件成功。
image-20230821205058708

3.4 测试MVT是否正常启用

sh 复制代码
#非常重要的功能,MVT功能若无法启用,会导致地图上开启矢量模式时,造成错误。
#切换至postgres用户
sudo su  postgres 
#进入数据库
psql
#输入下方SQL,进行查询。
WITH mvtgeom AS ( SELECT ST_TileEnvelope(12,513,412) AS geom ) SELECT ST_AsMVT(mvtgeom.*) FROM mvtgeom;
#返回数据为正常,未返回数据,请按报错信息查询解决方案(返回值是按照地图矢量瓦片(MVT)格式进行编码后的二进制数据。)。
image-20230823185312534

3.5 配置远程连接

sh 复制代码
#配置/etc/postgresql/13/main/pg_hba.conf ,目的是后期更新可从外部用工具访问数据库进行更新,调整数据库参数。
#pg_hba.conf修改项: 
sudo vim /etc/postgresql/13/main/pg_hba.conf 
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
host    all             all             0.0.0.0/0               md5 
image-20250730152508032
sh 复制代码
#配置 /etc/postgresql/13/main/postgresql.conf 
sudo vim /etc/postgresql/13/main/postgresql.conf
#postgresql.conf修改项: 
      #listen_addresses = 'localhost'
#改为
        listen_addresses = '*' 
image-20230306182647370

更多数据库优化选项,访问此网址,填写自己服务器配置,可或取到优化参数。

访问地址:https://pgtune.leopard.in.ua

image-20250730152922713
sh 复制代码
#重启数据库生效。 
sudo systemctl restart postgresql

至此,部署nVisual所需的服务就准备完毕了,可看下篇文章《nVisual-Linux系统部署文档》进行软件的安装部署。

上一个
准备环境
下一个
Windows部署rabbitmq
最近修改: 2025-07-30