落根 发表于 2024-8-7 15:20:14

离线Linux服务器环境搭建

文件上传到服务器先
<img alt="image-20230822143232457" loading="lazy">
一般传到服务器目录
mkdir /usr/local/install_package数据库

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

Success. You can now start the database server using:

    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用户
复制启动文件
cp contrib/start-scripts/linux /etc/init.d/postgresql
vim /etc/init.d/postgresql<img alt="image-20230818150114524" loading="lazy">
授权+开机自启
chmod +x /etc/init.d/postgresql
chkconfig --add postgresql启动,查看
service postgresql start
service postgresql stop
service postgresql status
ps -ef|grep postgrespsql连接,\password 设置数据库用户密码
<img alt="image-20230818150659480" loading="lazy">
可以本地使用Navicat测试连接
安装PostGIS
先安装proj,geos,gdal.依赖项,下载地址:http://download.osgeo.org
# tar xf proj-4.8.0.tar.gz
# cd proj-4.9.3
# ./configure --prefix=/usr/local/pgsql/plugin/proj
# make && make install
# vim /etc/ld.so.conf.d/proj-4.9.3.conf
#写入一句:
/usr/local/pgsql/plugin/proj/lib
# ldconfig安装geos,先安装bzip2解压器,
# tar -zxvf bzip2-1.0.6.tar.gz
# cd bzip2-1.0.6
# make && make install
# cd ..
# bzip2 -d geos-3.8.0.tar.bz2
# tar xf geos-3.8.0.tar
# cd geos-3.8.0
# ./configure --prefix=/usr/local/pgsql/plugin/geos
# make && make install
# vim /etc/ld.so.conf.d/geos-3.8.0.conf
#写入一句:
/usr/local/pgsql/plugin/geos/lib
# ldconfiggdal
# tar xf gdal-1.11.4.tar.gz
# cd gdal-1.11.4
# ./configure --prefix=/usr/local/pgsql/plugin/gdal
# make && make install
# vim /etc/ld.so.conf.d/gdal-1.11.4.conf
#写入一句:
/usr/local/pgsql/plugin/gdal/lib
# ldconfigPostGis
# tar xf postgis-2.3.7.tar.gz
# cd postgis-2.3.7
# ./configure --prefix=/usr/local/pgsql/plugin/postgis \
--with-pgconfig=/usr/local/pgsql/bin/pg_config \
--with-geosconfig=/usr/local/pgsql/plugin/geos/bin/geos-config \
--with-gdalconfig=/usr/local/pgsql/plugin/gdal/bin/gdal-config \
--with-projdir=/usr/local/pgsql/plugin/proj编译报错还是少组件,下载安装,重新执行编译
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.

## 依赖顺序 xz-libs --> xz-devel --> libxml2-devel
## 特别注意版本,试错了很多次,因为本机有xz-libs和libxml2,所以要依据本机的版本下载
# rpm -ivh xz-devel-5.2.2-2.el7_9.x86_64.rpm
# rpm -ivh libxml2-devel-2.9.1-6.el7_9.6.x86_64.rpm又一直报错,找不到GDAL
configure: error: could not find GDAL

解决:把pgsql/lib也配置到ldconfig里
# vim /etc/ld.so.conf.d/pgsql-9.5.20.conf
#写入一句:
/usr/local/pgsql/lib
# ldconfig安装
make && make install检测
# su postgres
$ psql
psql (9.5.20)
Type "help" for help.

postgres=# select * from pg_available_extensions;
          name          | default_version | installed_version |                               comment                              
------------------------+-----------------+-------------------+---------------------------------------------------------------------
plpgsql                | 1.0             | 1.0               | PL/pgSQL procedural language
postgis_topology       | 2.3.7         |                   | PostGIS topology spatial types and functions
postgis_tiger_geocoder | 2.3.7         |                   | PostGIS tiger geocoder and reverse geocoder
postgis                | 2.3.7         |                   | PostGIS geometry, geography, and raster spatial types and functions
(4 rows)

postgres=# create extension postgis;
CREATE EXTENSION
postgres=# create extension postgis_topology;
CREATE EXTENSIONJDK

mkdir /usr/local/java/
cd /usr/local/install_package
tar -zxvf jdk-8u381-linux-x64.tar.gz -C /usr/local/java/
vim /etc/profile
#添加环境变量
export JAVA_HOME=/usr/local/java/jdk1.8.0_381/
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
#建立软连接
ln -s /usr/local/java/jdk1.8.0_381/bin/java /usr/bin/java
#验证
java -versionRedis

cd /usr/local/install_package
tar -zxvf redis-6.2.13.tar.gz
cd redis-6.2.13
#编译
make
#安装 默认到/usr/local/bin->指定路径 make install PREFIX=/tools/redis
make install

#启动
redis-server /usr/local/install_package/redis-6.2.13/redis.conf
#关闭
redis-cli shutdown
#修改配置
vim /usr/local/install_package/redis-6.2.13/redis.conf
改动:
        #设置后台启动,如果不是后台启动,每次推出redis就关闭了
    daemonize yes
    #开启密码保护,注释则不需要密码
    requirepass qwer1234
    #允许访问的ip,改为0.0.0.0就是所有ip均可
    #bind 127.0.0.1 -::1
    bind 0.0.0.0
#添加到服务 设置开机自启
vim /usr/lib/systemd/system/reids.service
写入:
       
    Description=redis-server
    After=network.target

   
    Type=forking

    ExecStart=/usr/local/bin/redis-server/usr/local/install_package/redis-6.2.13/redis.conf
    PrivateTmp=true

   
    WantedBy=multi-user.target
#重载系统服务
systemctl daemon-reload
#设置开机自启
systemctl enable redis.service
#取消开机自启
systemctl disable redis.service
#启动服务
systemctl start redis.service
#停止服务
systemctl stop redis.service
#查看服务状态
systemctl status redis.serviceTomcat

cd /usr/local/install_package
tar -zxvf apache-tomcat-9.0.34.tar.gz -C /usr/local/tomcat
cd /usr/local/tomcat/apache-tomcat-9.0.34
vim /conf/server.xml
改端口:
        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
#启动
bin/start.sh
#停止
bin/shutdown.shApplication

找台能连上数据库的Windows,用Navicat执行sql,创建数据库。
war包放到tomcat的webapps目录下,启动tomcat
修改配置文件
webapps/imageserver/WEB-INF/classes/application-dev.yml
修改数据库连接,redis连接,数据目录
server:
port: 8081

spring:
datasource:
    url: jdbc:postgresql://127.0.0.1:5432/intoview
    username: intoview
    password: intoview
    # 使用druid数据源
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: org.postgresql.Driver
    filters: stat
    maxActive: 2
    initialSize: 1
    maxWait: 600000
    minIdle: 1
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: select now()
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    maxOpenPreparedStatements: 20
redis:
    host: localhost
    port: 6379
    password: qwer1234

imageserver:
#point-data-path: /opt/module/data/imagedata
#point-data-path: E:/opt/imagedata
# point-data-path: E:/Desktop/Work/imageServer/testData #E:/Desktop/Work/imageServer/testData
point-data-path:/data
closest-distance-tolerance: 5修改tomcat端口和yml的端口最好一致
这里修改application-dev.yml为8080
量测版和非量测版切换:
static/asset/js/index.js
634和639行,realimage是非量测,realimage是量测
if ($(".is-publisher").length > 0) {
            $.each(data, function (index, props) {
                resources = props;
                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>';
            });
      } else {
            $.each(data, function (index, props) {
                resources = props;
                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>';
            });
      }
来源:https://www.cnblogs.com/wendy12138/p/18346622
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: 离线Linux服务器环境搭建