当前位置: 首页 > 工具软件 > LNMT > 使用案例 >

LNMT部署

贲俊才
2023-12-01

nginx安装

//1.创建nginx用户
[root@localhost ~]# useradd -r -M -s /sbin/nologin nginx
[root@localhost ~]# id nginx
uid=991(nginx) gid=986(nginx) groups=986(nginx)
//2.安装nginx依赖包
[root@localhost ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[root@localhost ~]#yum -y groupinstall 'Development Tools'
//3.创建nginx日志文件目录
[root@localhost ~]# mkdir -p /var/log/nginx
[root@localhost ~]# chown -R nginx.nginx /var/log/nginx
[root@localhost ~]# ll -d /var/log/nginx
drwxr-xr-x. 2 nginx nginx 6 Jan  7 20:42 /var/log/nginx
[root@localhost ~]# 
//4.下载nginx压缩包,解压并编译安装
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget http://nginx.org/download/nginx-1.16.1.tar.gz 
[root@localhost src]# tar xf nginx-1.16.1.tar.gz 
[root@localhost src]# cd nginx-1.16.1/
[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
[root@localhost nginx-1.16.1]# echo $?
0
[root@localhost nginx-1.16.1]# make -j4 && make install
[root@localhost nginx-1.16.1]# echo $?
0
//5.
[root@localhost nginx-1.16.1]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost nginx-1.16.1]# . /etc/profile.d/nginx.sh 
[root@localhost nginx-1.16.1]# echo $PATH
/usr/local/nginx/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin
//6.启动nginx并查看端口号
[root@localhost nginx-1.16.1]# nginx
[root@localhost nginx-1.16.1]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 192.168.100.200:6379    0.0.0.0:*               LISTEN      43114/redis-server  
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      60895/nginx: master 
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1128/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      930/sshd            
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      935/cupsd           
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::22                   :::*                    LISTEN      930/sshd            
tcp6       0      0 ::1:631                 :::*                    LISTEN      935/cupsd  
//7.测试
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200108103854749.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDU1NjY4OA==,size_16,color_FFFFFF,t_70)

mysql安装

//1.下载MySQL二进制安装包
[root@localhost src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
//2.创建mysql用户
[root@localhost src]# groupadd -r mysql
[root@localhost src]# useradd -r -M -s /sbin/nologin -g mysql mysql
//3.解压mysql包到/usr/local/下
[root@localhost src]# tar xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# ls /usr/local/
bin  games    lib    libexec                              nginx  share
etc  include  lib64  mysql-5.7.22-linux-glibc2.12-x86_64  sbin   src
[root@localhost src]# cd /usr/local/
[root@localhost local]# ls
bin  games    lib    libexec                              nginx  share
etc  include  lib64  mysql-5.7.22-linux-glibc2.12-x86_64  sbin   src
//4.创建软连接并给mysql修改属主属组
[root@localhost local]# ln -sv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql
‘mysql’ -> ‘mysql-5.7.22-linux-glibc2.12-x86_64/’
[root@localhost local]# chown -R mysql.mysql mysql*
[root@localhost local]# ll
total 0
drwxr-xr-x.  2 root  root  134 Jan  7 06:04 bin
drwxr-xr-x.  2 root  root    6 Nov  5  2016 etc
drwxr-xr-x.  2 root  root    6 Nov  5  2016 games
drwxr-xr-x.  2 root  root    6 Nov  5  2016 include
drwxr-xr-x.  2 root  root    6 Nov  5  2016 lib
drwxr-xr-x.  2 root  root    6 Nov  5  2016 lib64
drwxr-xr-x.  2 root  root    6 Nov  5  2016 libexec
lrwxrwxrwx.  1 mysql mysql  36 Jan  7 21:44 mysql -> mysql-5.7.22-linux-glibc2.12-x86_64/
drwxr-xr-x.  9 mysql mysql 129 Jan  7 21:42 mysql-5.7.22-linux-glibc2.12-x86_64
drwxr-xr-x. 11 root  root  151 Jan  7 20:55 nginx
drwxr-xr-x.  2 root  root    6 Nov  5  2016 sbin
drwxr-xr-x.  5 root  root   49 Nov 14 06:56 share
drwxr-xr-x.  2 root  root    6 Nov  5  2016 src
//5.添加环境变量
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# . /etc/profile.d/mysql.sh 
[root@localhost local]# echo $PATH
/usr/local/mysql/bin:/usr/local/nginx/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin
[root@localhost local]# 
//6.创建数据存放目录
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll -d /opt/data/
drwxr-xr-x. 2 mysql mysql 6 Jan  7 21:49 /opt/data/
//7.初始化数据库
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2020-01-08T02:51:04.798710Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-01-08T02:51:05.118109Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-01-08T02:51:05.174159Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-01-08T02:51:05.245183Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: b6bc1b88-31c1-11ea-aa4c-000c29f2403e.
2020-01-08T02:51:05.245829Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-01-08T02:51:05.246686Z 1 [Note] A temporary password is generated for root@localhost: PKo&d%iAB1wT
[root@localhost ~]# 
//7.编写配置文件
[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
[root@localhost ~]# 
//8.配置服务启动脚本
[root@localhost ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@localhost ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
//9.启动mysql
[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
 SUCCESS! 
[root@localhost ~]# netstat -ntpl |grep mysqld
tcp6       0      0 :::3306                 :::*                    LISTEN      62159/mysqld        
//10.修改数据库登录密码
[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p'PKo&d%iAB1wT'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password = password('peiyf');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

tomcat安装

//1.安装JDK
[root@localhost src]# yum -y install java-11-openjdk java-11-openjdk-devel
[root@localhost src]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
[root@localhost src]# 
//2.下载安装包
[root@localhost src]# wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
[root@localhost src]# tar cf apache-tomcat-9.0.27.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# ll | grep apache-tomcat-9.0.27
drwxr-xr-x.  9 root  root  220 Jan  7 22:26 apache-tomcat-9.0.27
[root@localhost local]# ln -s apache-tomcat-9.0.27 tomcat
[root@localhost local]# ll | grep apache-tomcat-9.0.27
drwxr-xr-x.  9 root  root  220 Jan  7 22:26 apache-tomcat-9.0.27
lrwxrwxrwx.  1 root  root   20 Jan  7 22:27 tomcat -> apache-tomcat-9.0.27
[root@localhost local]# cd tomcat/webapps/
[root@localhost webapps]# pwd
/usr/local/tomcat/webapps
[root@localhost webapps]# mkdir test
[root@localhost webapps]# cd test/
[root@localhost test]# vim index.jsp
[root@localhost test]# cat index.jsp 
<html>
<head>
        <title>test page</title>
</head>
<body>
        <%
            out.println("Hellow World");
        %>
        </body>
        </html>
[root@localhost test]# 
[root@localhost test]# /usr/local/tomcat/bin/catalina.sh start
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@localhost test]# ss -natl
State       Recv-Q Send-Q    Local Address:Port                   Peer Address:Port              
LISTEN      0      128     192.168.100.200:6379                              *:*                  
LISTEN      0      128                   *:111                               *:*                  
LISTEN      0      128                   *:80                                *:*                  
LISTEN      0      5         192.168.122.1:53                                *:*                  
LISTEN      0      128                   *:22                                *:*                  
LISTEN      0      128           127.0.0.1:631                               *:*                  
LISTEN      0      128                  :::111                              :::*                  
LISTEN      0      100                  :::8080                             :::*                  
LISTEN      0      128                  :::22                               :::*                  
LISTEN      0      128                 ::1:631                              :::*                  
LISTEN      0      1      ::ffff:127.0.0.1:8005                             :::*                  
LISTEN      0      100                  :::8009                             :::*                  
LISTEN      0      80                   :::3306                             :::*                  
测试:


//1.启动第2个tomcat
[root@localhost ~]# vim /usr/local/tomcat2/conf/server.xml 
    <Server port="8040" shutdown="SHUTDOWN">
    <Connector port="8050" protocol="HTTP/1.1"
    <Connector port="8060" protocol="AJP/1.3" redirectPort="8443" />
    
[root@localhost test]# /usr/local/tomcat/bin/catalina.sh start
[root@localhost conf]# ss -natl
State       Recv-Q Send-Q    Local Address:Port                   Peer Address:Port              
LISTEN      0      128     192.168.100.200:6379                              *:*                  
LISTEN      0      128                   *:111                               *:*                  
LISTEN      0      128                   *:80                                *:*                  
LISTEN      0      5         192.168.122.1:53                                *:*                  
LISTEN      0      128                   *:22                                *:*                  
LISTEN      0      128           127.0.0.1:631                               *:*                              
LISTEN      0      128                  :::111                              :::*                  
LISTEN      0      100                  :::8080                             :::*                  
LISTEN      0      100                  :::8050                             :::*                           
LISTEN      0      128                  :::22                               :::*                  
LISTEN      0      128                 ::1:631                              :::*                  
LISTEN      0      100                  :::8060                             :::*                  
LISTEN      0      1                    :::8005                             :::*                  
LISTEN      0      1                    :::8040                             :::*                  
LISTEN      0      100                  :::8009                             :::*                  
LISTEN      0      80                   :::3306                             :::*  
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
        upstream tomcat {
        server 192.168.100.200:8080;
        server 192.168.100.200:8050;
        }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location ~* \.(jsp|do)$ {
        proxy_pass http://tomcat;
        }
        location / {
        root html;
        proxy_pass http://tomcat;
        index index.html index.htm;
        }
        
[root@localhost ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# nginx -s reload
测试:

安装Jenkins

//1.下载jenkins包到/usr/local/tomcat2/webapps下
[root@localhost webapps]# pwd
/usr/local/tomcat2/webapps
[root@localhost webapps]# ls
docs  examples  host-manager  jenkins  jenkins.war  manager  ROOT  test
//2.访问Jenkins页面
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200109182812257.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDU1NjY4OA==,size_16,color_FFFFFF,t_70)

[root@localhost webapps]# cat /root/.jenkins/secrets/initialAdminPassword
20851f277b8641cf8fd451978d1878e3
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200109182831494.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDU1NjY4OA==,size_16,color_FFFFFF,t_70)
/输入密码/继续访问
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200109182909547.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDU1NjY4OA==,size_16,color_FFFFFF,t_70)

 类似资料: