乌班图(Ubuntu)初始开发环境配置

一、apt-get数据源修改

1、复制原文件备份

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2、编辑源列表文件

sudo vim /etc/apt/sources.list

3、将原来的列表删除,添加如下内容

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

4、运行

sudo apt-get update

sudo apt-get upgrade


二、依赖安装

1.     安装gcc

sudo apt-get  install  build-essential

2.     安装openssl

sudo apt-get install openssl

sudo apt-get install libssl-dev

3.     make安装

sudo apt-get install make

4.     expat安装

下载expat:

https://sourceforge.net/projects/expat/files/expat

./configure

sudo make

sudo make install

5.     安装dpkg

sudo apt-get install dpkg-dev

6.     安装autoconf

sudo apt-get install autoconf

7.     安装 libtool

sudo apt-get install libtool

sudo apt-get install libtool-bin


三、JAVA环境

1.     解压路径


2.     修改配置文件



export JAVA_HOME=/home/cpcnet/soft/java/jdk1.8.0_202

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

3.     使配置文件生效



四、Nginx

1.     解压路径


2.     安装编译

1)安装依赖库

apt-get install gcc

apt-get install libpcre3 libpcre3-dev

apt-get install zlib1g zlib1g-dev

sudo apt-get install libssl-dev

2)执行配置命令

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module

3)执行make命令

make

4)执行make install命令

make install

下面两步(5,6)可以跳过

5)启动nginx服务

​​​​​​​/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

6)重新加载nginx配置

/usr/local/nginx/sbin/nginx -s reload

3.     添加到服务并设置自启动

1) 进入/usr/local/nginx/sbin创建nginx.sh,内容如下:

#!/bin/sh -e

cd /usr/local/nginx/sbin

./nginx

2) 修改权限

chmod 677 ./nginx.sh

3) 进入/lib/systemd/system并创建nginx.service文件,修改权限

cd /lib/systemd/system

touch ./nginx.service

chmod 777 nginx.service

4) nginx.sh内容如下:

#  This file is part of systemd.

#  systemd is free software; you can redistribute it and/or modify it

#  under the terms of the GNU Lesser General Public License as published by

#  the Free Software Foundation; either version 2.1 of the License, or

#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by

[Unit]

Description=/usr/local/nginx/sbin/nginx.sh Compatibility

ConditionFileIsExecutable=/usr/local/nginx/sbin/nginx.sh

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx.sh

TimeoutSec=0

RemainAfterExit=yes

#### 添加 ####

[Install]

WantedBy=multi-user.target

Alias=nginx.service

5) 创建软链接

sudo ln -s /lib/systemd/system/nginx.service /etc/systemd/system

6) 设置开机自启

systemctl enable nginx.service

7) 常用服务命令

systemctl start nginx.service

systemctl status nginx.service

systemctl stop nginx.service


五、JKS证书生成

1.     通过*.crt和*.key证书创建jks证书


先生成p12文件

openssl pkcs12 -export -in mss.china-entercom.com.crt -inkey mss.china-entercom.com.key -out mss.china-entercom.com.p12

再生成keystore文件(jks格式是keysotre标准格式,java key store的缩写)

keytool -importkeystore -v -srckeystore mss.china-entercom.com.p12 -srcstoretype pkcs12 -destkeystore mss.china-entercom.com.jks -deststoretype jks

2.     存放目录



六、APR安装

APR下载地址

http://apr.apache.org/download.cgi

1.     安装apr,解压apr-1.7.0.tar.gz并进入目录执行下面命令

./configure --prefix=/usr/local/apr

sudo make

sudo make install

2.     安装 apr-iconv

./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr

sudo make

sudo make install

3.     安装apr-util

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv

sudo make

sudo make install

 

七、Tomat配置

1.     解压Tomcat


2.     修改bin目录下的setclasspath.sh文件,配置上apr,java环境



export JAVA_HOME=/home/cpcnet/soft/java/jdk1.8.0_202

export JRE_HOME=${JAVA_HOME}/jre

export LD_LIBRARY_PATH=/usr/local/apr/lib

3.     安装tomcat-native

解压tomcat-native.tar.gz


进入目录


执行配置

./configure --with-apr=/usr/local/apr --with-java-home=/home/cpcnet/soft/java/jdk1.8.0_202
sudo make
sudo make install

4.     配置SSL

进入conf目录修改server.xml文件


    <Connector port="80" 
               protocol="org.apache.coyote.http11.Http11AprProtocol"
               connectionTimeout="20000"
               redirectPort="443"
               maxPostSize="-1" 
               maxHttpHeaderSize="8192" 
               maxThreads="150" 
               maxSpareThreads="75"
            />


    <Connector port="443" 
               protocol="org.apache.coyote.http11.Http11AprProtocol"
               SSLEnabled="true" 
               scheme="https" 
               secure="true"
               maxPostSize="-1" 
               maxHttpHeaderSize="8192" 
               maxThreads="150" 
               maxSpareThreads="75"
            >
        <SSLHostConfig>
                <Certificate 
                         certificateKeystoreFile="/home/cpcnet/msselk/cert/mss.china-entercom.com.jks"
                         certificateKeystorePassword="123456"
                         certificateKeystoreType="jks" />
        </SSLHostConfig>
    </Connector>


BIO,NIO,ARP配置方式,推荐使用ARP

 

5.配置用户


<user username="xxxx" password="xxxx" roles="admin-gui,manager-gui" />

6.设置可访问IP

打开webapps下的host-manager和manager,都有一个共同的文件夹META-INF,里面都有context.xml,修改:


allow="^.*$"

7.设置war包上传大小,默认是50M我们修改为50G



    <multipart-config>
      <!-- 50MB max -->
      <max-file-size>53687091200</max-file-size>
      <max-request-size>53687091200</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>


(1)