翼度科技»论坛 云主机 LINUX 查看内容

离线Linux服务器环境搭建

8

主题

8

帖子

24

积分

新手上路

Rank: 1

积分
24
文件上传到服务器先
<img alt="image-20230822143232457" loading="lazy">

一般传到服务器目录
  1. mkdir /usr/local/install_package
复制代码
数据库

版本:Postgresql 9.5.20
检查依赖环境 gcc-c++环境,有日志打印就是有安装,新服务器一般都只有gcc没有g++
  1. gcc -v
  2. g++ -v
  3. rpm -qa | grep gcc-c++
  4. rpm -qa | grep gcc
复制代码
安装,到gcc安装目录下
  1. cd /usr/local/install_package/gcc
  2. rpm -Uvh *.rpm --nodeps --force
复制代码
然后使用检查命令验证
安装Postgresql
解压
  1. cd /usr/local/install_package
  2. tar -zxvf postgresql-9.5.20.tar.gz
  3. cd postgresql-9.5.20
复制代码
编译带上uuid,需要提前装好uuid,注意:
  1. cd /usr/local/install_package
  2. tar -zxvf uuid-1.6.2.tar.gz
  3. cd uuid-1.6.2
  4. ./configure
  5. make && make install
  6. rpm -ivh uuid-1.6.2-26.el7.x86_64.rpm
  7. rpm -ivh uuid-devel-1.6.2-26.el7.x86_64.rpm
  8. rpm -ivh libuuid-devel-2.23.2-65.el7_9.1.x86_64.rpm
  9. # 如果不安装以上的一个包,编译postgresql就会报以下的错误:
  10. # configure: error: library 'ossp-uuid' or 'uuid' is required for OSSP-UUID"
  11. cd /usr/local/install_package/postgresql-9.5.20/contrib/uuid-ossp
  12. # 这是编译的 contrib/uuid-ossp
  13. make && make install
  14. #上边如果不编译uuid-ossp,就会出现下面的错误:
  15. #postgres=# create extension "uuid-ossp";
  16. #ERROR:  could not open extension control file "/usr/local/postgresql/share/extension/uuid-ossp.control": No such file or directory
复制代码
  1. #./configure --prefix=/bigdata/work/postgresql 指定安装路径 默认/usr/local/pgsql
  2. # 编译时候把uuid带上,!!!!!!!,这个害我重装了三次
  3. ./configure --with-uuid=ossp
  4. #然后再继续postgresql的make和make install
  5. make
  6. make install
复制代码
./configure编译要是有报错缺少包,就检查是否有,检查也有的话就是缺少名称-devel的包,去下载,安装
镜像下载站:http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
  1. [root@iZul501d9puehvyajdpb92Z postgresql-9.5.20]# ./configure
  2. .......
  3. checking for library containing readline... no
  4. configure: error: readline library not found
  5. If you have readline already installed, see config.log for details on the
  6. failure.  It is possible the compiler isn't looking in the proper directory.
  7. Use --without-readline to disable readline support.
  8. [root@iZul501d9puehvyajdpb92Z postgresql-9.5.20]# rpm -qa | grep readline
  9. readline-6.2-11.el7.x86_64
  10. [root@iZul501d9puehvyajdpb92Z gcc]# rpm -ivh ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm
  11. Preparing...                          ################################# [100%]
  12. Updating / installing...
  13.    1:ncurses-devel-5.9-14.20130511.el7################################# [100%]
  14. [root@iZul501d9puehvyajdpb92Z gcc]# rpm -ivh readline-devel-6.2-11.el7.x86_64.rpm
  15. Preparing...                          ################################# [100%]
  16. Updating / installing...
  17.    1:readline-devel-6.2-11.el7        ################################# [100%]
复制代码
readline依赖于ncurses,单个安装需要注意依赖顺序安装,
再重新回去执行编译命令 ./configure
这个结尾./configure成功
  1. checking thread safety of required library functions... yes
  2. checking whether gcc supports -Wl,--as-needed... yes
  3. configure: using compiler=gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
  4. configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-alia
  5. sing -fwrapv -fexcess-precision=standard -O2
  6. configure: using CPPFLAGS= -D_GNU_SOURCE
  7. configure: using LDFLAGS=  -Wl,--as-needed
  8. configure: creating ./config.status
  9. config.status: creating GNUmakefile
  10. config.status: creating src/Makefile.global
  11. config.status: creating src/include/pg_config.h
  12. config.status: creating src/include/pg_config_ext.h
  13. config.status: creating src/interfaces/ecpg/include/ecpg_config.h
  14. config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
  15. config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
  16. config.status: linking src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c
  17. config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
  18. config.status: linking src/backend/port/unix_latch.c to src/backend/port/pg_latch.c
  19. config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
  20. config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
  21. config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
复制代码
make成功
  1. cp ../../../contrib/spi/refint.so refint.so
  2. cp ../../../contrib/spi/autoinc.so autoinc.so
  3. make[2]: Leaving directory `/usr/local/install_package/postgresql-9.5.20/src/test/regress'
  4. make -C test/perl all
  5. make[2]: Entering directory `/usr/local/install_package/postgresql-9.5.20/src/test/perl'
  6. make[2]: Nothing to be done for `all'.
  7. make[2]: Leaving directory `/usr/local/install_package/postgresql-9.5.20/src/test/perl'
  8. make[1]: Leaving directory `/usr/local/install_package/postgresql-9.5.20/src'
  9. make -C config all
  10. make[1]: Entering directory `/usr/local/install_package/postgresql-9.5.20/config'
  11. make[1]: Nothing to be done for `all'.
  12. make[1]: Leaving directory `/usr/local/install_package/postgresql-9.5.20/config'
  13. All of PostgreSQL successfully made. Ready to install.
复制代码
make install 成功
  1. make[1]: Leaving directory `/usr/local/install_package/postgresql-9.5.20/src'
  2. make -C config install
  3. make[1]: Entering directory `/usr/local/install_package/postgresql-9.5.20/config'
  4. /usr/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/config'
  5. /usr/bin/install -c -m 755 ./install-sh '/usr/local/pgsql/lib/pgxs/config/install-sh'
  6. /usr/bin/install -c -m 755 ./missing '/usr/local/pgsql/lib/pgxs/config/missing'
  7. make[1]: Leaving directory `/usr/local/install_package/postgresql-9.5.20/config'
  8. PostgreSQL installation complete.
复制代码
创建用户,不能用root启动
  1. [root@iZul501d9puehvyajdpb92Z pgsql]# useradd postgres
  2. [root@iZul501d9puehvyajdpb92Z pgsql]# passwd postgres
  3. Changing password for user postgres.
  4. New password:
  5. BAD PASSWORD: The password contains the user name in some form
  6. Retype new password:
  7. passwd: all authentication tokens updated successfully.
复制代码
授权
  1. mkdir /usr/local/pgsql/data
  2. mkdir /usr/local/pgsql/log
  3. chown -R postgres:postgres /usr/local/pgsql
复制代码
环境变量,vim /etc/profile, 结尾加上下面的,source /etc/profile,结果生效
  1. export PGDATA=/usr/local/pgsql/data
  2. export PGHOME=/usr/local/pgsql
  3. export LD_LBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH
  4. export PATH=$PGHOME/bin:$PATH
复制代码
初始化数据库
切换postgres用户,到pgsql/bin下,执行initdb
  1. WARNING: enabling "trust" authentication for local connections
  2. You can change this by editing pg_hba.conf or using the option -A, or
  3. --auth-local and --auth-host, the next time you run initdb.
  4. Success. You can now start the database server using:
  5.     bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
复制代码
配置数据库
/usr/local/pgsql/data目录下
vim pg_hba.conf
<img alt="image-20230818145502452" loading="lazy">

vim postgresql.conf
<img alt="image-20230818145552593" loading="lazy">

配置成服务
切回root用户
复制启动文件
  1. cp contrib/start-scripts/linux /etc/init.d/postgresql
  2. vim /etc/init.d/postgresql
复制代码
<img alt="image-20230818150114524" loading="lazy">

授权+开机自启
  1. chmod +x /etc/init.d/postgresql
  2. chkconfig --add postgresql
复制代码
启动,查看
  1. service postgresql start
  2. service postgresql stop
  3. service postgresql status
  4. ps -ef|grep postgres
复制代码
psql连接,\password 设置数据库用户密码
<img alt="image-20230818150659480" loading="lazy">

可以本地使用Navicat测试连接
安装PostGIS
先安装proj,geos,gdal.依赖项,下载地址:http://download.osgeo.org
  1. [root@iZul501d9puehvyajdpb92Z install_package]# tar xf proj-4.8.0.tar.gz
  2. [root@iZul501d9puehvyajdpb92Z proj-4.9.3]# cd proj-4.9.3
  3. [root@iZul501d9puehvyajdpb92Z proj-4.9.3]# ./configure --prefix=/usr/local/pgsql/plugin/proj
  4. [root@iZul501d9puehvyajdpb92Z proj-4.9.3]# make && make install
  5. [root@iZul501d9puehvyajdpb92Z proj-4.9.3]# vim /etc/ld.so.conf.d/proj-4.9.3.conf
  6. #写入一句:
  7. /usr/local/pgsql/plugin/proj/lib
  8. [root@iZul501d9puehvyajdpb92Z proj-4.9.3]# ldconfig
复制代码
安装geos,先安装bzip2解压器,
  1. [root@iZul501d9puehvyajdpb92Z install_package]# tar -zxvf bzip2-1.0.6.tar.gz
  2. [root@iZul501d9puehvyajdpb92Z install_package]# cd bzip2-1.0.6
  3. [root@iZul501d9puehvyajdpb92Z bzip2-1.0.6]# make && make install
  4. [root@iZul501d9puehvyajdpb92Z bzip2-1.0.6]# cd ..
  5. [root@iZul501d9puehvyajdpb92Z install_package]# bzip2 -d geos-3.8.0.tar.bz2
  6. [root@iZul501d9puehvyajdpb92Z install_package]# tar xf geos-3.8.0.tar
  7. [root@iZul501d9puehvyajdpb92Z install_package]# cd geos-3.8.0
  8. [root@iZul501d9puehvyajdpb92Z geos-3.8.0]# ./configure --prefix=/usr/local/pgsql/plugin/geos
  9. [root@iZul501d9puehvyajdpb92Z geos-3.8.0]# make && make install
  10. [root@iZul501d9puehvyajdpb92Z geos-3.8.0]# vim /etc/ld.so.conf.d/geos-3.8.0.conf
  11. #写入一句:
  12. /usr/local/pgsql/plugin/geos/lib
  13. [root@iZul501d9puehvyajdpb92Z geos-3.8.0]# ldconfig
复制代码
gdal
  1. [root@iZul501d9puehvyajdpb92Z install_package]# tar xf gdal-1.11.4.tar.gz
  2. [root@iZul501d9puehvyajdpb92Z install_package]# cd gdal-1.11.4
  3. [root@iZul501d9puehvyajdpb92Z gdal-1.11.4]# ./configure --prefix=/usr/local/pgsql/plugin/gdal
  4. [root@iZul501d9puehvyajdpb92Z gdal-1.11.4]# make && make install
  5. [root@iZul501d9puehvyajdpb92Z gdal-1.11.4]# vim /etc/ld.so.conf.d/gdal-1.11.4.conf
  6. #写入一句:
  7. /usr/local/pgsql/plugin/gdal/lib
  8. [root@iZul501d9puehvyajdpb92Z gdal-1.11.4]# ldconfig
复制代码
PostGis
  1. [root@iZul501d9puehvyajdpb92Z install_package]# tar xf postgis-2.3.7.tar.gz
  2. [root@iZul501d9puehvyajdpb92Z postgis-2.3.7]# cd postgis-2.3.7
  3. [root@iZul501d9puehvyajdpb92Z postgis-2.3.7]# ./configure --prefix=/usr/local/pgsql/plugin/postgis \
  4. --with-pgconfig=/usr/local/pgsql/bin/pg_config \
  5. --with-geosconfig=/usr/local/pgsql/plugin/geos/bin/geos-config \
  6. --with-gdalconfig=/usr/local/pgsql/plugin/gdal/bin/gdal-config \
  7. --with-projdir=/usr/local/pgsql/plugin/proj
复制代码
编译报错还是少组件,下载安装,重新执行编译
  1. configure: error: could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a --with-xml2config parameter.
  2. ## 依赖顺序 xz-libs --> xz-devel --> libxml2-devel
  3. ## 特别注意版本,试错了很多次,因为本机有xz-libs和libxml2,所以要依据本机的版本下载
  4. [root@iZul501d9puehvyajdpb92Z install_package]# rpm -ivh xz-devel-5.2.2-2.el7_9.x86_64.rpm
  5. [root@iZul501d9puehvyajdpb92Z install_package]# rpm -ivh libxml2-devel-2.9.1-6.el7_9.6.x86_64.rpm
复制代码
又一直报错,找不到GDAL
  1. configure: error: could not find GDAL
  2. 解决:把pgsql/lib也配置到ldconfig里
  3. [root@iZul501d9puehvyajdpb92Z postgis-2.3.7]# vim /etc/ld.so.conf.d/pgsql-9.5.20.conf
  4. #写入一句:
  5. /usr/local/pgsql/lib
  6. [root@iZul501d9puehvyajdpb92Z postgis-2.3.7]# ldconfig
复制代码
安装
  1. make && make install
复制代码
检测
  1. [root@iZul501d9puehvyajdpb92Z postgis-2.3.7]# su postgres
  2. [postgres@iZul501d9puehvyajdpb92Z postgis-2.3.7]$ psql
  3. psql (9.5.20)
  4. Type "help" for help.
  5. postgres=# select * from pg_available_extensions;
  6.           name          | default_version | installed_version |                               comment                              
  7. ------------------------+-----------------+-------------------+---------------------------------------------------------------------
  8. plpgsql                | 1.0             | 1.0               | PL/pgSQL procedural language
  9. postgis_topology       | 2.3.7           |                   | PostGIS topology spatial types and functions
  10. postgis_tiger_geocoder | 2.3.7           |                   | PostGIS tiger geocoder and reverse geocoder
  11. postgis                | 2.3.7           |                   | PostGIS geometry, geography, and raster spatial types and functions
  12. (4 rows)
  13. postgres=# create extension postgis;
  14. CREATE EXTENSION
  15. postgres=# create extension postgis_topology;
  16. CREATE EXTENSION
复制代码
JDK
  1. mkdir /usr/local/java/
  2. cd /usr/local/install_package
  3. tar -zxvf jdk-8u381-linux-x64.tar.gz -C /usr/local/java/
  4. vim /etc/profile
  5. #添加环境变量
  6. export JAVA_HOME=/usr/local/java/jdk1.8.0_381/
  7. export JRE_HOME=${JAVA_HOME}/jre
  8. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
  9. export PATH=${JAVA_HOME}/bin:$PATH
  10. source /etc/profile
  11. #建立软连接
  12. ln -s /usr/local/java/jdk1.8.0_381/bin/java /usr/bin/java
  13. #验证
  14. java -version
复制代码
Redis
  1. cd /usr/local/install_package
  2. tar -zxvf redis-6.2.13.tar.gz
  3. cd redis-6.2.13
  4. #编译
  5. make
  6. #安装 默认到/usr/local/bin  ->指定路径 make install PREFIX=/tools/redis
  7. make install
  8. #启动
  9. redis-server /usr/local/install_package/redis-6.2.13/redis.conf
  10. #关闭
  11. redis-cli shutdown
  12. #修改配置
  13. vim /usr/local/install_package/redis-6.2.13/redis.conf
  14. 改动:
  15.         #设置后台启动,如果不是后台启动,每次推出redis就关闭了
  16.     daemonize yes
  17.     #开启密码保护,注释则不需要密码
  18.     requirepass qwer1234
  19.     #允许访问的ip,改为0.0.0.0就是所有ip均可
  20.     #bind 127.0.0.1 -::1
  21.     bind 0.0.0.0
  22. #添加到服务 设置开机自启
  23. vim /usr/lib/systemd/system/reids.service
  24. 写入:
  25.         [Unit]
  26.     Description=redis-server
  27.     After=network.target
  28.     [Service]
  29.     Type=forking
  30.     ExecStart=/usr/local/bin/redis-server/usr/local/install_package/redis-6.2.13/redis.conf
  31.     PrivateTmp=true
  32.     [Install]
  33.     WantedBy=multi-user.target
  34. #重载系统服务
  35. systemctl daemon-reload
  36. #设置开机自启
  37. systemctl enable redis.service
  38. #取消开机自启
  39. systemctl disable redis.service
  40. #启动服务
  41. systemctl start redis.service
  42. #停止服务
  43. systemctl stop redis.service
  44. #查看服务状态
  45. systemctl status redis.service
复制代码
Tomcat
  1. cd /usr/local/install_package
  2. tar -zxvf apache-tomcat-9.0.34.tar.gz -C /usr/local/tomcat
  3. cd /usr/local/tomcat/apache-tomcat-9.0.34
  4. vim /conf/server.xml
  5. 改端口:
  6.         <Connector port="8080" protocol="HTTP/1.1"
  7.                connectionTimeout="20000"
  8.                redirectPort="8443" />
  9. #启动
  10. bin/start.sh
  11. #停止
  12. bin/shutdown.sh
复制代码
Application

找台能连上数据库的Windows,用Navicat执行sql,创建数据库。
war包放到tomcat的webapps目录下,启动tomcat
修改配置文件
webapps/imageserver/WEB-INF/classes/application-dev.yml
修改数据库连接,redis连接,数据目录
  1. server:
  2.   port: 8081
  3. spring:
  4.   datasource:
  5.     url: jdbc:postgresql://127.0.0.1:5432/intoview
  6.     username: intoview
  7.     password: intoview
  8.     # 使用druid数据源
  9.     type: com.alibaba.druid.pool.DruidDataSource
  10.     driver-class-name: org.postgresql.Driver
  11.     filters: stat
  12.     maxActive: 2
  13.     initialSize: 1
  14.     maxWait: 600000
  15.     minIdle: 1
  16.     timeBetweenEvictionRunsMillis: 60000
  17.     minEvictableIdleTimeMillis: 300000
  18.     validationQuery: select now()
  19.     testWhileIdle: true
  20.     testOnBorrow: false
  21.     testOnReturn: false
  22.     poolPreparedStatements: true
  23.     maxOpenPreparedStatements: 20
  24.   redis:
  25.     host: localhost
  26.     port: 6379
  27.     password: qwer1234
  28. imageserver:
  29.   #point-data-path: /opt/module/data/imagedata
  30. #  point-data-path: E:/opt/imagedata
  31. # point-data-path: E:/Desktop/Work/imageServer/testData #E:/Desktop/Work/imageServer/testData
  32.   point-data-path:/data
  33.   closest-distance-tolerance: 5
复制代码
修改tomcat端口和yml的端口最好一致
这里修改application-dev.yml为8080
量测版和非量测版切换:
static/asset/js/index.js
634和639行,realimage是非量测,realimage是量测
  1. if ($(".is-publisher").length > 0) {
  2.             $.each(data, function (index, props) {
  3.                 resources[props.id] = props;
  4.                 html += '<tr>' + '<td>' + (index + 1) + '</td>' + '<td><img src="https://www.cnblogs.com/open/public/getImage/' + props.name + '/' + props.firstPicName + '" >' + '</td>' + '<td>' + props.label + '</td><td>'+props.name+'</td>' + '<td>' + props.createDate + '</td>' + '<td>' + props.collectDate + '</td>' + '<td>' + (props.picCount || 0) + '</td>' + '<td>' + (props.mileage == null ? 0 : props.mileage.toFixed(2)) + '公里</td>' + '<td>' + '<a title="预览" href='https://www.cnblogs.com/ + 'realimage?serviceName=' + props.name + ' target=_blank><i ></i></a>' + '<a title="授权"   data-id=' + props.id + ' data-name=' + props.name + ' data-label=' + props.label + '></a>' + '<a title="删除"  data-serviceName=' + props.name + ' data-id=' + props.id + '></a>' + '<a title="设置"  data-id=' + props.id + '></a>' + '</td>' + '</tr>';
  5.             });
  6.         } else {
  7.             $.each(data, function (index, props) {
  8.                 resources[props.id] = props;
  9.                 html += '<tr>' + '<td>' + (index + 1) + '</td>' + '<td><img src="https://www.cnblogs.com/open/public/getImage/' + props.name + '/' + props.firstPicName + '" >' + '</td>' + '<td>' + props.label + '</td><td>'+props.name+'</td>' + '<td>' + props.createDate + '</td>' + '<td>' + props.collectDate + '</td>' + '<td>' + (props.picCount || 0) + '</td>' + '<td>' + (props.mileage == null ? 0 : props.mileage.toFixed(2)) + '公里</td>' + '<td>' + '<a title="预览" href='https://www.cnblogs.com/ + 'realimage?serviceName=' + props.name + ' target=_blank><i ></i></a>' + '</td>' + '</tr>';
  10.             });
  11.         }
复制代码
来源:https://www.cnblogs.com/wendy12138/p/18346622
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

举报 回复 使用道具