提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
LNMP框架的架构与环境配置
一、安装 Nginx 服务
1.关闭防火墙及安装依赖包
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
#安装依赖包
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
2、创建运行用户
useradd -M -s /sbin/nologin nginx
3、编译安装
cd /opt
tar zxvf nginx-1.24.0.tar.gz -C /opt/
cd nginx-1.24.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
make && make install
4、优化路径
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
5、添加 Nginx 系统服务
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
chmod 754 /lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl enable nginx.service
二、安装 MySQL 服务
1、安装Mysql环境依赖包
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake
2、创建运行用户
useradd -M -s /sbin/nologin mysql
3、编译安装
cd /opt
tar zxvf mysql-boost-5.7.20.tar.gz
cd /opt/mysql-5.7.20/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci