服务器部署(保姆级教程)
一、准备工作
1、下载JDK安装包
https://www.oracle.com/java/technologies/downloads/#java8
2、下载Tomcat安装包
https://tomcat.apache.org/download-80.cgi
3、下载MySQL安装包
https://downloads.mysql.com/archives/community/
注意:下载选择Red Hat Enterprise Linux /Oracle Linux
依次下载:(什么版本你自己决定 建议最低5.7)
mysql-community-server-5.7.27-1.el7.x86_64.rpm
mysql-community-client-5.7.27-1.el7.x86_64.rpm
mysql-community-common-5.7.27-1.el7.x86_64.rpm
mysql-community-libs-5.7.27-1.el7.x86_64.rpm
4、下载Redis安装包
https://redis.io/download
5、下载Nginx安装包
http://nginx.org/en/download.html
6、下载Node安装包(.xz结尾的包)
https://nodejs.org/zh-cn/download/
7、下载Maven安装包
https://maven.apache.org/download.cgi
8、下载Git安装包
https://git-scm.com/download/linux
9、准备服务器文件传输工具(自己准备)
10、Oracle账号:oracle-02@qq.com 1211WaN!
二、本地虚拟机网络设置
1、查看有无分配的ip
ifconfig
2、本机控制面板到这个地址下去
控制面板\网络和 Internet\网络和共享中心 更改适配器设置
3、查看以太网 右键—状态—详细信息(这里和等会修改虚拟机网卡的信息相关)
以太网: ——————>>> 虚拟机:
IPv4:IP地址(只有IP不一样) IPADDR=IP地址
IPv4子网掩码:子网掩码 NETMASK=子网掩码
IPv4默认网关:默认网关 GATEWAY=网关
IPv4DNS服务器:服务器 DNS1=服务器
虚拟机的ip根据你本机的ip改 用 ping 命令测试 是否被占用 要在一个网关内哟
4、准备好信息,修改虚拟机网络
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static //这里改成static静态的
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=31ddae9d-57fd-46ee-a464-bd0c0ee6f913
DEVICE=ens33
ONBOOT=yes //这里原来是no 改成yes
IPADDR=静态IP
NETMASK=静态IP对应的子网掩码
GATEWAY=静态IP的网关
DNS1=服务器
5、重启网卡
systemctl restart network.service
6、使用 ping命令 从虚拟机到主机 主机到虚拟机 测试是否畅通
三、安装JDK
1、用文件传输工具吧JDK压缩包上传服务器
2、解压到/usr/local/src/JDK下
①查看是否安装了JDK
rpm -qa|grep java
②先卸载已经安装的JDK
rpm -e --nodeps 安装的JDK
③解压安装JDK
tar -zxvf JDK压缩包
④配置环境变量
vim /etc/profile
如果不能用vim 可以使用vi
或者安装vim:
yum -y install vim*
⑤在末尾添加代码
export JAVA_HOME=JDK安装路径
export PATH=$JAVA_HOME/bin:$PATH
然后按Esc 退出编辑,然后输入 :wq保存退出
⑥使修改的配置立刻生效
source /etc/profile
⑦检查jdk环境变量配置是否成功
java -version
⑧查看JDK安装路径
java -verbose
四、安装Tomcat
注意:(SpringBoot项目根据自己情况安装)
1、上传Tomcat压缩包安装包
2、解压到/usr/local/Tomcat
tar -zxvf ./apache-tomcat-8.5.15.tar.gz 后面不写路径表示解压到当前目录下
3、文件重命名
mv 文件名 修改后的文件名
4、配置环境变量 vim /etc/profile
export TOMCAT_HOME=/usr/local/Tomcat/tomcat
export CLASSPATH=$TOMCAT_HOME/lib/servlet-api.jar
5、启动Tomcat/关闭Tomcat
$TOMCAT_HOME/bin/startup.sh $TOMCAT_HOME/bin/hutdown.sh
6、查看Tomcat日志 Ctrl + C 退出
tail -f ./logs/catalina.out
五、安装MySQL
1、上传MySQL压缩包安装包
2、查看是否已经安装mysql
rpm -qa |grep mysql
rpm -qa |grep mariadb
3、卸载已安装的mysql
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
4、yum安装的删除
rpm -qa |grep mysql
yum remove 删除的文件名
检查是否有残余:rpm -qa |greq -i mysql 如果有再次卸载
终极检查:再来一遍rpm -qa |greq -i mysql看看还有没有残留
清理文件:find / -name mysql
删除文件:rm -rf 删除的目录
5、安装
单个文件安装:
rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm 注意:要安装顺序安装
rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
如果安装出现这个错误(没有出现就不管):
依赖检测失败:
/usr/bin/perl 被 mysql-community-server-5.7.27-1.el7.x86_64 需要
perl(Getopt::Long) 被 mysql-community-server-5.7.27-1.el7.x86_64 需要
perl(strict) 被 mysql-community-server-5.7.27-1.el7.x86_64 需要
安装依赖(需要网络):
yum -y install perl.x86_64
yum install -y libaio.x86_64
yum -y install net-tools.x86_64
就可以正常安装了
6、查看mysql是否安装成功
service mysqld status
7、启动MySQL服务
service mysqld start
8、停止MySQL服务
service mysqld stop
9、查看MySQL的随机密码
查看随机密码:grep 'temporary password' /var/log/mysqld.log //B,eXzjQqd5RE
10、连接数据库
mysql -u root -p
11、修改安全级别
set global validate_password_policy=0; //将密码安全级别设置为0,就表示只验证密码的长度
set global validate_password_length=1; //将密码的默认长度验证设置为1.
12、修改MySQL数据库密码
alter user 'root'@'localhost' identified by '你的密码';
13、查看mysql的字符编码
show variables like 'character%';
quit //退出mysql
14、进入配置文件
vim /etc/my.cnf
15、修改
在[mysqld] 下面添加:character-set-server=utf8
在[mysqld] 下面添加:
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
解决问题:MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause
在文件末尾添加 lower_case_table_names=1 (MySQL不限制大小写)
16、重启MySQL服务
service mysqld stop
service mysqld start
17、再次查看编码
show variables like 'character%';
18、设置允许远程连接数据库
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '自己的密码' WITH GRANT OPTION;
flush privileges;
19、设置防火墙
查看防火墙设置:firewall-cmd --list-all
启动防火墙:service firewalld start
关闭防火墙:service firewalld stop 注意:自己的服务器建议关闭,麻烦
开放3306端口:firewall-cmd --permanent --add-port=3306/tcp
删除端口:firewall-cmd --permanent --remove-port=3306/tcp
20、如果是云端服务器需要配置服务器的安全组
安全组:添加3306端口
六、安装Maven
1、上传到服务器
2、解压
tar -zxvf ./apache-maven-3.6.3-bin.tar.gz
3、配置环境变量
vim /etc/profile
//在文件末尾配置
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3 //自己的Maven路径
export PATH=${MAVEN_HOME}/bin:${PATH}
Esc退出编辑 :wq 退出
source /etc/profile //刷新配置
mvn -v //查看是否安装成功
4、配置镜像和仓库
将此文本全部复制,在文件末尾处修改自己的仓库地址即可
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.conf}/settings.xml.
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->
<!-- pluginGroups
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<!--
| Here is another profile, activated by the system property 'target-env' with a value of 'dev',
| which provides a specific path to the Tomcat instance. To use this, your plugin configuration
| might hypothetically look like:
|
| ...
-->
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<!--
| Here is another profile, activated by the system property 'target-env' with a value of 'dev',
| which provides a specific path to the Tomcat instance. To use this, your plugin configuration
| might hypothetically look like:
|
| ...
| <plugin>
| <groupId>org.myco.myplugins</groupId>
| <artifactId>myplugin</artifactId>
|
| <configuration>
| <tomcatLocation>${tomcatPath}</tomcatLocation>
| </configuration>
| </plugin>
| ...
|
| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
| anything, you could just leave off the <value/> inside the activation-property.
|
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
<localRepository>自己仓库地址</localRepository>
</settings>
七、安装Redis
1、上传到服务器
2、在 /usr/local/ 下创建 redis ⽂件夹并进⼊
cd /usr/local/
mkdir redis
cd redis
3、将 Redis 安装包解压到 /usr/local/redis 中即可
tar zxvf /usr/local/src/redis-6.0.6.tar.gz -C ./
4、解压完之后, /usr/local/redis ⽬录中会出现⼀个 redis-5.0.8 的⽬录
5、编译并安装 如果有了redis要重新装的 必须要把redis彻底删除干净
cd redis-5.0.8/
make && make install
注意安装6.0也上的Redis可能出现gcc依赖版本过低,执行make && make install一直编译报错
1、把reids的解压目录删掉依次执行下面代码
yum -y install gcc-c++ #必须联网
gcc -v
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
2、设置永久升级(注意:scl命令启用只是临时的,推出xshell或者重启虚拟机就会恢复到原来的gcc版本。如果要长期生效的话)
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
重新解压开始操作
6、进⼊ utils ⽬录,并执⾏如下脚本即可
[root@localhost redis-5.0.8]# cd utils/
[root@localhost utils]# ./install_server.sh
如果出现:Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!错误
解决方法:vim /install_server.sh
找到代码: 差不多在76行
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
按 i 进入编辑
然后注释掉这些代码
在按Esc退出编辑模式 按:wq 退出并保存
在执行./install_server.sh 出现Installation successful! 就是成功了
7、查看Redis是否启动
systemctl status redis_6379.service //我不介意使用系统给的服务 建议自己自定义一个服务
自定义启动脚本
跑到/etc/systemd/system/路径下面新建一个服务文件(注意不是文件夹哟)
touch redis.service 新建服务文件
chmod +x redis.service 给文件权限
编辑文件:
[Unit] //基础信息
Description=Redis //描述
After=network.target //是在那个服务后面启动,一般是网络服务启动后启动
[Service] //服务信息
// 启动服务的命令
ExecStart=redis-server服务路径 /配置文件路径 --daemonize no
// 是停止服务的指令
ExecStop=redis-cli服务路径 -h IP地址 -p 6379 shutdown
[Install]
WantedBy=multi-user.target //是以哪种方式启动:multi-user.target表明当系统以多用户方式(默认的运行级别)启动时,这个服务需要被自动运行。
保存退出
刷新配置:systemctl daemon-reload
启动:systemctl start redis
重启:systemctl restart redis
停止:systemctl stop redis
8、启动⾃带的 redis-cli 客户端
redis-cli 进入后
set a haha
get a 输出:haha
9、设置允许远程连接
编辑 redis 配置⽂件 vim /etc/redis/6379.conf
①.将 bind 127.0.0.1 修改为 0.0.0.0
10、然后重启 Redis 服务即可
systemctl restart redis
11、设置访问密码
vim /etc/redis/6379.conf
找到如下内容(大概在788行): #requirepass foobared
去掉注释,将 foobared 修改为⾃⼰想要的密码,保存即可。 比如:requirepass Crazyhao
重启Redis服务
12、验证
redis-cli 这次要输入密码 进入后
set a haha
get a 输出:haha
八、安装Node
1、上传到服务器
2、在 /usr/local/ 下创建 node ⽂件夹并进⼊
cd /usr/local/
mkdir node
cd node
3、将 Node 的安装包解压到 /usr/local/node 中即可
[root@localhost node]# tar -xJvf /root/node-v12.16.3-linux-x64.tar.xz -C ./
4、解压完之后, /usr/local/node ⽬录中会出现⼀个 node-v12.16.3-linux-x64 的⽬录
5、编辑 vim /etc/profile ⽂件,在⽂件末尾追加如下信息
# Nodejs
export PATH=/usr/local/node/node-v12.16.3-linux-x64/bin:$PATH
6、刷新环境变量,使之⽣效即可
source /etc/profile
7、检查安装结果
node -v
npm version 都有版本输出
npx -v
九、安装Nginx
1、上传到服务器
2、在 /usr/local/ 下创建 nginx ⽂件夹并进⼊
cd /usr/local/
mkdir nginx
cd nginx
3、将 Nginx 安装包解压到 /usr/local/nginx 中即可
[root@localhost nginx]# tar zxvf /root/nginx-1.17.10.tar.gz -C ./
4、解压完之后, /usr/local/nginx ⽬录中会出现⼀个 nginx-1.17.10 的⽬录
5、预先安装额外的依赖
yum -y install pcre-devel
yum -y install openssl openssl-devel
6、编译安装NGINX
cd nginx-1.17.10
//设置Nginx支持ssl
./configure --prefix=/usr/local/nginx --with-http_ssl_module
//支持ssl的同时支持fdfs插件,如果没有可以忽略此步骤
./configure --prefix=/usr/local/nginx --with-http_ssl_module --add-module=/usr/local/fastdfs/fastdfs-nginx-module-1.22/src(后面路径是你的插件安装地址)
make && make install
7、安装完成后,Nginx的可执⾏⽂件位置位于
/usr/local/nginx/sbin/nginx
8、相关命令
①.进入/usr/local/nginx/sbin/nginx/sbin目录
./nginx 启动nginx
./nginx -s stop 关闭nginx
./nginx -s reload 修改nginx.conf 配置后需要刷新 刷新不用关闭nginx
nginx.conf路径在 /usr/local/nginx/sbin/nginx/conf
十、安装GIT⼯具
方式一:通过包管理器安装
在 Linux 上安装 Git 向来仅需⼀⾏命令即可搞定,因为各式各样的包管理器帮了我们⼤忙,所以对于
CentOS 系统来讲,直接执⾏如下命令即可安装:
yum install git
当然通过这种⽅式安装的 Git 可能不是较新版的 Git ,不过⼀般来说是够⽤的。
方式二:通过源码编译安装
如果想安装较新版本的 Git ,则需要⾃⾏下载 Git 源码来编译安装。
1、准备Git安装包,上传到服务器 root 下
2、在进⼊root
cd root
3、将 Git 安装包解压到当前目录中即可
tar -zxvf git-2.34.1.tar.gz
4、安装可能所需的依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc-c++ perl-ExtUtils-MakeMaker
5、编译安装Git
进入解压的目录
cd git-2.34.1/
make configure
./configure --prefix=/usr/local/git
make profix=/usr/local/git
make install
6、将 Git 加⼊环境变量
①配置环境变量
vim /etc/profile
//尾部加⼊ Git 的 bin 路径配置即可
############ Git ############
export GIT_HOME=/usr/local/git
export PATH=$PATH:$GIT_HOME/bin
保存退出 :wq
7、刷新配置
source /etc/profile
8、查看安装结果
git --version
十一、上传前端项目并部署
1、将前端项目打包成zip上传到服务器
2、在cd /home 路径下面创建自己的前端文件夹
3、解压
unzip 文件名
4、删除原来的文件
rm -rf 文件名
5、前端项目安装依赖
npm install --unsafe-perm --registry=https://registry.npm.taobao.org
6、前端项目开始打包
npm run build:prod
7、修改Nginx的配置
修改/usr/local/nginx/conf/nginx.conf
43行
location / {
root /home/ruoyi-ui/ruoyi-ui/dist; //自己的前端打包路径
index index.html index.htm;
}
8、浏览器测试
十二、上传后端项目并部署
1、上传后端项目jar包或者war包(服务器上面打包比较慢,所以我就在本地打的包,springboot项目我推荐就jar包)
2、在cd /home 路径下面创建自己的后端文件夹
3、jar包启动测试 进入自己的后端文件夹
java -jar 包名.jar 没有报错就可以 Ctrl+C 关闭
4、jar包启动方式
java -jar 包名.jar 这种启动方式 Ctrl+C 可以关闭(不推荐) 可以写服务脚本启动(推荐)
nohup java -jar 包名.jar & 启动 这种方式 Ctrl+C 关闭不了(推荐) 关闭需要关闭进程
实时查看日志:tail -f 日志文件
查看进程:ps -ef |grep jar
杀死进程:kill -9 进程码
5、war包启动方式(Tomcat)
①.war包放到tomcat的wabapp目录下
②.在Tomcat的server.xml配置文件中配置<Context path="/" docBase="war包路径" reloadable="true"/>
③.重新启动tomcat就行了
6、修改nginx.conf实现前后端联调
server {
listen 80;
server_name localhost;
proxy_set_header Host $host;
location / {
root /前端项目路径/dist/;
try_files $uri /index.html;
index index.html index.htm;
}
location /warehouse/ { //后端的接口路径 不知道的可以看前端浏览器 F12 查看网络
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Agent,X- Requested-Wind,If-Modified-Since,Cache-Control,Content-Type,Authorization';
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_connect_timeout 60;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_pass http://47.108.211.186:10088; //调转后端的路径
}
}
十三、重启服务器后查看各个工具的启动状态
1、Tomcat 是否启动 $TOMCAT_HOME/bin/startup.sh $TOMCAT_HOME/bin/hutdown.sh
2、MySQL 是否启动 service mysqld status
3、Redis 是否启动 systemctl status redis_6379.service
完
e,Cache-Control,Content-Type,Authorization’;
proxy_set_header Host
h
o
s
t
:
host:
host:server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_connect_timeout 60;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_pass http://47.108.211.186:10088; //调转后端的路径
}
}
## 十三、重启服务器后查看各个工具的启动状态
1、Tomcat 是否启动 $TOMCAT_HOME/bin/startup.sh $TOMCAT_HOME/bin/hutdown.sh
2、MySQL 是否启动 service mysqld status
3、Redis 是否启动 systemctl status redis_6379.service
------
**完**
Copyright © 2021 crazyhao.cn All Rights Reserved.