概述
lnmt
- 1.安装
- 1.1安装nginx
- 1.2安装mysql
- 1.3安装tomcat
- 2.实现功能
1.安装
1.1安装nginx
//创建系统用户nginx
[root@zzg ~]# groupadd -r nginx
[root@zzg ~]# useradd -r -M -s /sbin/nologin -g nginx nginx
//安装依赖环境
[root@zzg ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[root@zzg ~]# yum -y groups mark install 'Development Tools'
//创建日志存放目录
[root@zzg ~]# mkdir -p /var/log/nginx
[root@zzg ~]# chown nginx.nginx /var/log/nginx/
//下载nginx,解压
[root@zzg ~]# cd /usr/src/
[root@zzg src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@zzg src]# ls |grep nginx
nginx-1.12.0.tar.gz
[root@zzg src]# tar -xf nginx-1.12.0.tar.gz
//编译安装
[root@zzg nginx-1.12.0]# ./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@zzg nginx-1.12.0]# make && make install
[root@localhost ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost ~]# . /etc/profile.d/nginx.sh
//添加环境变量
1.2安装mysql
//安装依赖包
[root@zzg ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
//创建用户和组
[root@zzg ~]# groupadd -r -g 306 mysql
[root@zzg ~]# useradd -r -M -s /sbin/nologin -g mysql mysql
//下载二进制格式的mysql软件包
[root@zzg ~]# cd /usr/src/
[root@zzg src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
//解压软件至/usr/local/
[root@zzg src]# tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@zzg src]# ls /usr/local/
bin games lib libexec sbin src
etc include lib64 mysql-5.7.23-linux-glibc2.12-x86_64 share
[root@zzg src]# cd /usr/local/
[root@zzg local]# ln -s mysql-5.7.23-linux-glibc2.12-x86_64/ mysql
//修改目录/usr/local/mysql的属主属组,添加环境变量
[root@zzg local]# chown -R mysql.mysql /usr/local/mysql
[root@zzg local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@zzg local]# . /etc/profile.d/mysql.sh
//建立数据存放目录
[root@zzg local]# mkdir /opt/data
[root@zzg local]# chown -R mysql.mysql /opt/data/
//初始化数据库
[root@zzg local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
//配置mysql
[root@zzg local]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
‘/usr/local/include/mysql’ -> ‘/usr/local/mysql/include/’
[root@zzg local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@zzg local]# ldconfig -v
//生成配置文件
[root@zzg local]# cat > /etc/my.cnf <<EOF
> [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
> EOF
//配置服务启动脚本
[root@zzg local]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@zzg local]# sed -ri 's#^(basedir=).*#1/usr/local/mysql#g' /etc/init.d/mysqld
[root@zzg local]# sed -ri 's#^(datadir=).*#1/opt/data#g' /etc/init.d/mysqld
//启动
[root@zzg local]# service mysqld start
//修改密码
mysql> set password = password(123456');
1.3安装tomcat
//安装jdk环境
[root@zzg ~]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@zzg ~]# java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
//下载tomcat
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.tar.gz
//解压部署
[root@zzg src]# tar xf apache-tomcat-9.0.16.tar.gz -C /usr/local/tomcat/
[root@zzg src]# cd /usr/local/tomcat/
[root@zzg tomcat]# ls
apache-tomcat-9.0.16
[root@zzg tomcat]# mv apache-tomcat-9.0.16/ test
[root@zzg tomcat]# cp -a test/ test123
[root@zzg tomcat]# ls
test test123
//启动tomcat
[root@zzg zzg]# /usr/local/tomcat/test/bin/catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat/test
Using CATALINA_HOME: /usr/local/tomcat/test
Using CATALINA_TMPDIR: /usr/local/tomcat/test/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/test/bin/bootstrap.jar:/usr/local/tomcat/test/bin/tomcat-juli.jar
Tomcat started.
[root@zzg zzg]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
//关闭防火墙,selinux
[root@zzg zzg]# systemctl stop firewalld
[root@zzg zzg]# setenforce 0
2.实现功能
//反向代理
upstream zhangzhengguang{ //添加
server 192.168.220.40:8080; //添加
} //添加
server {
listen 80;
server_name localhosta;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://zhangzhengguang; //添加
//不懂反向代理可以查看博客nginx这一篇
//重启nginx服务
[root@zzg ~]# nginx -s stop
[root@zzg ~]# nginx
[root@zzg ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 80 :::3306 :::*
验证:
最后
以上就是彩色黑夜为你收集整理的搭建lnmt服务的全部内容,希望文章能够帮你解决搭建lnmt服务所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复