设为首页 加入收藏

TOP

lnmp部署(一)
2023-07-23 13:35:49 】 浏览:71
Tags:lnmp 部署

lnmp部署

环境说明

系统平台 IP 需要安装的服务
centos8 192.168.118.130 nginx-1.20.2
centos8 192.168.118.131 mysql-5.7.34
centos8 192.168.118.132 php-8.1.11

1.nginx安装

安装准备

#修改主机名
[root@localhost ~]# hostnamectl set-hostname nginx
[root@localhost ~]# bash

#关闭防火墙和selinux
[root@nginx ~]# setenforce 0
[root@nginx ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@nginx ~]# systemctl disable --now firewalld.service

#创建nginx用户
[root@nginx ~]# useradd -rMs /sbin/nologin nginx

#安装所需要的依赖包
[root@nginx ~]# dnf -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make wget vim

#下载nginx源码包,并解压
[root@nginx ~]# wget http://nginx.org/download/nginx-1.20.2.tar.gz
[root@nginx ~]# tar -xf nginx-1.20.2.tar.gz
[root@nginx ~]# cd nginx-1.20.2/
[root@nginx nginx-1.20.2]#

开始安装

#配置
[root@nginx nginx-1.20.2]# ./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

#编译安装
[root@nginx nginx-1.20.2]# make -j $(grep 'processor' /proc/cpuinfo | wc -l)
[root@nginx nginx-1.20.2]# make install

#安装成功
[root@nginx nginx-1.20.2]# cd /usr/local/nginx/
[root@nginx nginx]# ls
conf  html  logs  sbin

配置文件

#配置环境变量
[root@nginx ~]# echo "export PATH=$PATH:/usr/local/nginx/sbin" > /etc/profile.d/nginx.sh
[root@nginx ~]# source /etc/profile.d/nginx.sh

#编写service文件
[root@nginx ~]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx server daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecReload=/bin/kill -HUP \$MAINPID

[Install]
WantedBy=multi-user.target
[root@nginx ~]# systemctl daemon-reload

启动服务,开机自启

[root@nginx ~]# systemctl enable --now nginx.service
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@nginx ~]# systemctl status nginx.service 
● nginx.service - nginx server daemon
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disable>
   Active: active (running) since Tue 2022-10-11 15:42:27 CST; 36s ago

2.mysql安装

#修改主机名
[root@localhost ~]# hostnamectl set-hostname mysql
[root@localhost ~]# bash

#关闭防火墙和selinux
[root@mysql ~]# setenforce 0
[root@mysql ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@mysql ~]# systemctl disable --now firewalld.service

#创建mysql用户
[root@mysql ~]# useradd -rMs /sbin/nologin mysql

#安装所需要的依赖包
[root@mysql ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs

#下载mysql源码包,并解压
[root@mysql ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.34-linux-glibc2.12-x86_64.tar
[root@mysql ~]# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

#更改属主属组
[root@mysql ~]# cd /usr/local/
[root@mysql local]# mv mysql-5.7.34-linux-glibc2.12-x86_64/ mysql
[root@mysql local]# chown -R mysql.mysql mys

#头文件
[root@mysql local]# cd mysql/
[root@mysql mysql]# ls
LICEN
首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Linux 安装Httpd服务 下一篇VMware vSphere 8.0 正式版下载

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目