Linux环境下如何搭建LNMP环境
Nginx下载、安装及配置
一.Nginx下载
Nginx下载 Nginx下载
二.Nginx安装
1.准备依赖包
yum -y install zlib-devel pcre-devel openssl-devel
2.准备nginx用户
useradd -M -s /sbin/nologin nginx
3.源码编译与安装
1)检查当前的环境是否满足要安装软件的依赖关系
cd /mnt/nginx-1.19.6
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_sub_module
2)编译并安装
make && make install
4.查看结果
ls /usr/local/nginx
5.查看是否安装好
tree nginx/
6.查看nginx是否启动
pstree | grep nginx
pstree -u | grep nginx
pstree -up | grep nginx
三.设置配置文件:
user nginx;
四.服务管理:
1.检测配置语法
/usr/local/nginx/sbin/nginx -t
2.启动服务
/usr/local/nginx/sbin/nginx
3.重载服务
pkill -HUP nginx
4.关闭服务
pkill nginx
5.开机启动
注:cs8中记得设置x权限,chmod a+x /etc/rc.local
vi /etc/rc.local
/usr/local/nginx/sbin/nginx
6.授权
setfacl -m u:nginx:rwx -R /usr/local/nginx/html/
setfacl -m d:u:nginx:rwx -R /usr/local/nginx/html/
五.进程管理:
pstree -pu|grep nginx
六.端口管理:
netstat -tunpl |grep nginx
七.客户端测试:
服务器ip
MySQL下载、安装与配置
一.MySQL下载
二.编译安装
1.安装依赖包
yum install -y zstd libarchive gcc-toolset-10
yum install -y cmake ncurses-devel libtirpc-devel gcc-c++
2.安装rpcsvc
1)下载地址
rpcsvc
2)安装
tar xf rpcsvc-proto-1.4.2.tar.xz
cd rpcsvc-proto-1.4.2/
./configure
make
make install
3.安装mysql-boost
tar xzf mysql-boost-8.0.23.tar.gz
cd mysql-8.0.23/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DWITH_BOOST=boost -DFORCE_INSOURCE_BUILD=1
make
make install
注:mysql-boost编译安装过程比较久
三.mysql配置文件
-
vi /etc/my.cnf
!includedir /etc/my.cnf.d
-
mkdir /etc/my.cnf.d/
文件1/etc/my.cnf.d/client.cnf
[client] [client-mariadb]
文件2
/etc/my.cnf.d/mysql-default-authentication-plugin.cnf
[mysqld] default_authentication_plugin=mysql_native_passw