webgis

服务器安装配置

操作系统

下载centos 8镜像,制作u盘启动盘,引导U盘启动。提示 dracut-initqueue timeout 无法找到安装媒体,分别执行dracut:/# cd /dev dracut:/# ls;找到安装媒体的sdb编号sdbx,重启(dracut:/# reboot)后,安装界面修改安装配置文件;将vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64.check quiet修改为vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdbx(你u盘的编号 比如sdb1)quiet,按Ctrl+x即可。

mysql

安装

mysql官网找到对应的rpm文件(8.0)地址,下载rpm文件wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm,使用yum -y install *.rpm安装;使用yum -y install mysql-server安装服务器;

使用

  • 坑1首先关闭selinux /etc/selinux/config文件中设置SELINUX=disabled 然后reboot

  • 坑2安装完后默认没有/var/lib/mysql文件夹,需自行'mkdir mysql'创建并赋予权限chown -R mysql:mysql /var/lib/mysql

  • 启动服务systemctl start mysqld.service;

  • 查看初始密码:grep "password" /var/log/mysqld.log

  • 登录mysql服务器mysql -uroot

  • 查看密码规则SHOW VARIABLES LIKE 'validate_password%';,修改密码规则set global validate.number_length=5;set global validate_password.special_char_count=0;

  • 设置密码ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

  • 授予权限grant all privileges on *.* to 'root'@'192.168.0.1',查看权限·use mysql;select user,authentication_string,host from user;`查看用户权限;

  • 开启防火墙 firewall-cmd --zone=public --add-port=3306/tcp --permanent,firewall-cmd --reload

  • 配置默认编码;修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
  • 重启mysql;systemctl restart mysqld
  • 创建用户 CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';,赋予权限GRANT ALL PRIVILEGES ON *.* TO 'finley'@'localhost' WITH GRANT OPTION;

mysql on ubuntu

create user 'root'@'%' identified by 'Scgd_1234';
grant all privileges on *.* to 'root'@'%';
flush privileges;

PostgreSql

安装

按照官网链接进行安装配置,https://www.postgresql.org/download/linux/redhat/

user&db

create user spuser with password '123456'
create database spdb owner spuser;
grant all privileges on database spdb to spuser;

开启远程

修改/var/lib/pgsql/10/data/postgresql.conf(ubuntu中为/etc/postgresql/12/main)文件,取消 listen_addresses 的注释,将参数值改为“*”。修改pg_hba.conf文件,允许远程访问,修改ipv4配置

图片.png

重启systemctl restart postgresql-11

  • !!!切记!!!开启防火墙 firewall-cmd --zone=public --add-port=5432/tcp --permanent,firewall-cmd --reload
  • 安装pgAdmin4客户端

postgis

wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install  pgdg-redhat-repo-latest.noarch.rpm

postgresql ubuntu

postgresql

sudo apt-get install postgresql
修改/var/lib/pgsql/10/data/postgresql.conf(ubuntu中为/etc/postgresql/12/main)文件,取消 listen_addresses 的注释,将参数值改为“*”。修改pg_hba.conf文件,允许远程访问;

安装postgis

sudo apt-get install postgis
创建空间数据库及其用户

create user spuser with password '123456'
create database spdb owner spuser;
grant all privileges on database spdb to spuser;

执行postsql脚本

psql -d ltpostgis -f /usr/share/postgresql/12/contrib/postgis-3.0/postgis.sql  
psql -d ltpostgis -f /usr/share/postgresql/12/contrib/postgis-3.0/spatial_ref_sys.sql   

或者添加扩展使数据库扩展为空间数据库

psql -d yourdatabase -c "CREATE EXTENSION postgis;"
-- if you built with raster support and want to install it --
psql -d yourdatabase -c "CREATE EXTENSION postgis_raster;"
-- if you want to install topology support --
psql -d yourdatabase -c "CREATE EXTENSION postgis_topology;"
-- if you built with sfcgal support and want to install it --
psql -d yourdatabase -c "CREATE EXTENSION postgis_sfcgal;"
-- if you want to install tiger geocoder --
psql -d yourdatabase -c "CREATE EXTENSION fuzzystrmatch"
psql -d yourdatabase -c "CREATE EXTENSION postgis_tiger_geocoder;"
-- if you installed with pcre
-- you should have address standardizer extension as well
psql -d yourdatabase -c "CREATE EXTENSION address_standardizer;"

java

安装指定版本的开源jdksudo apt-get install openjdk-7-jdk
查看当前版本java -version
多版本注册update-alternatives --config java
卸载官方版本(最新版java14运行tomcat要报错)sudo apt-get remove oracle-java14-installer
添加环境变量vim /etc/profile

#set java environment
export JAVA_HOME=/usr/lib/jvm/jdk-8-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JRE_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

tomcat

下载tomcat文件,配置srartup.sh和shutdown.sh中java环境变量,添加tomcat home环境变量;

#tomcat
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:%{JAVA_HOME}/lib:%{JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-8.5.55

test localhost:8080

你可能感兴趣的:(webgis)