一键部署LNMP平台脚本

时间:2022-10-28 18:01:42

分享一个一键部署LNMP平台脚本,设置通过systemd管理Nginx服务,好用!

#!/bin/bash

yum -y install gcc openssl-devel pcre-devel

tar xf lnmp_soft.tar.gz

cd lnmp_soft/

tar xf nginx-1.12.2.tar.gz

cd nginx-1.12.2/

./configure --with-http_ssl_module --with-http_stub_status_module

make && make install

yum install -y mariadb-server mariadb-devel php php-fpm php-mysql

systemctl enable mariadb.service --now

ss -tlnp | grep :3306

systemctl enable php-fpm.service --now

ss -tlnp | grep :9000

echo "

[Unit]

Description=The Nginx HTTP Server

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx

ExecReload=/usr/local/nginx/sbin/nginx -s reload

ExecStop=/bin/kill -s QUIT ${MAINPID}

[Install]

WantedBy=multi-user.target

"   > /usr/lib/systemd/system/nginx.service

systemctl start nginx

ss -tlnp | grep :80