0% found this document useful (0 votes)
19 views7 pages

centos7 7安装

This document provides a step-by-step guide for installing LNMT (Nginx, Tomcat, MariaDB, and Redis) on CentOS 7.7. It includes instructions for changing the system language, setting up Aliyun repositories, and installing each component along with configuration details. Additionally, it covers enabling services to start automatically and creating symbolic links for easier access.

Uploaded by

yjzyjz185672
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views7 pages

centos7 7安装

This document provides a step-by-step guide for installing LNMT (Nginx, Tomcat, MariaDB, and Redis) on CentOS 7.7. It includes instructions for changing the system language, setting up Aliyun repositories, and installing each component along with configuration details. Additionally, it covers enabling services to start automatically and creating symbolic links for easier access.

Uploaded by

yjzyjz185672
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

centos7.

7 LNMT+REDIS 安装

1.更改系统语言

[root@centos7 ~]# cat /etc/locale.conf


#LANG="zh_CN.UTF-8"
LANG="en_US.UTF-8"

2.安装阿里云源

① 安装阿里云基础源
mv /etc/yum.repos.d/CentOS-Base.repo{,.blk } 备份基础源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 安装阿里
云基础源

② 安装阿里云 epel 源
yum install -y epel-release
yum clean all && yum makecache
yum repolist
安装环境

安装 nginx tomcat redis mariadb

Nginx 安装
yum install -y nginx

配置反向 nginx 代理
vi /etc/nginx/nginx.conf
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;


pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '


'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;
access_log /var/log/nginx/web.access.log main;

server {
listen 80;
server_name www.test.com;
location / {
proxy_pass http://192.168.137.129:8080/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
}
}

}
Tomcat 安装
yum install tomcat -y

systemctl start tomcat


ss -ntlp

mkdir /usr/share/tomcat/webapps/ROOT 暂时不用


cd /
ln -s /usr/share/tomcat/webapps/ROOT/ /web 暂时不用

或者直接修改 tomcat 默认站点路径


vi /usr/share/tomcat/conf/server.xml 并在<host>和</host>之间插入如下语句。
<Context path="" docBase="/web/" debug="0" reloadable="true" crosscontext="true" />

Cd /web
echo 'hello world!' > index.html
mariadb 安装 mysql 的安装参照 centos7.7 按照 mysql5.7 文章
yum install mariadb-server mariadb -y

systemctl start mariadb


ss -ntlp
ln -s /var/lib/mysql/ /data 创建数据库软连接

或直接修改 my.cnf 默认数据库路径


vi /etc/my.cnf
datadir=/data/mysql

Redis 安装
yum install redis

配置自启动

nginx tomcat redis mysqld mariadb

systemctl enable nginx


systemctl enable tomcat
systemctl enable redis
systemctl enable mysqld

systemctl enable mariadb


systemctl list-unit-files|grep mariadb

systemctl list-unit-files|grep nginx


systemctl list-unit-files|grep tomcat
systemctl list-unit-files|grep redis
systemctl list-unit-files |grep mysqld.service

软连接创建
mkdir /program
cd /program/
ln -s /usr/share/tomcat/ /program/tomcat
ln -s /etc/nginx/ /program/nginx
ln -s /var/lib/mysql /program/mysqldata
ln -s /etc/redis.conf /program/redis.conf
ls

You might also like