10 一键部署LNMP网站平台
#!/bin/bash export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin NGINX_V=1.19.1 PHP_V=7.2.19 TMP_DIR=/tmp INSTALL_DIR=/usr/local PWD_C=$PWD echo echo -e "\tMenu\n" echo -e "1. Install Nginx" echo -e "2. Install PHP" echo -e "3. Install MySQL" echo -e "4. Deploy LNMP" echo -e "9. Quit" if ! id nginx &> /dev/null; then groupadd -g 1200 nginx useradd -M -s /sbin/nologin -u 1200 -g nginx nginx &> /dev/null fi function command_status_check() { if [ $? -ne 0 ]; then echo $1 exit fi } function install_nginx() { cd $TMP_DIR yum install -y gcc gcc-c++ make openssl-devel pcre-devel wget wget http://nginx.org/download/nginx-${NGINX_V}.tar.gz tar zxf nginx-${NGINX_V}.tar.gz cd nginx-${NGINX_V} ./configure --prefix=$INSTALL_DIR/nginx \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-stream command_status_check "Nginx - 平台环境检查失败!" make -j 4 command_status_check "Nginx - 编译失败!" make install command_status_check "Nginx - 安装失败!" mkdir -p $INSTALL_DIR/nginx/conf/conf.d cp -a $PWD_C/nginx.conf $INSTALL_DIR/nginx/conf rm -rf $INSTALL_DIR/nginx/html/* echo "ok" > $INSTALL_DIR/nginx/html/status.html echo '<?php phpinfo(); ?>' > $INSTALL_DIR/nginx/html/status.php # $INSTALL_DIR/nginx/sbin/nginx cp -a $PWD_C/nginx.service /usr/lib/systemd/system systemctl daemon-reload systemctl enable nginx.service systemctl start nginx.service command_status_check "Nginx - 启动失败!" } function install_php() { cd $TMP_DIR yum install -y gcc gcc-c++ make gd-devel libxml2-devel \ libcurl-devel libjpeg-devel libpng-devel openssl-devel \ libmcrypt-devel libxslt-devel libtidy-devel wget http://docs.php.net/distributions/php-${PHP_V}.tar.gz tar zxf php-${PHP_V}.tar.gz cd php-${PHP_V} ./configure --prefix=$INSTALL_DIR/php \ --with-config-file-path=$INSTALL_DIR/php/etc \ --enable-fpm --enable-opcache \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --with-mysql --with-mysqli --with-pdo-mysql \ --with-openssl --with-zlib --with-curl --with-gd \ --with-jpeg-dir --with-png-dir --with-freetype-dir \ --enable-mbstring --enable-hash command_status_check "PHP - 平台环境检查失败!" make -j 4 command_status_check "PHP - 编译失败!" make install command_status_check "PHP - 安装失败!" cp -a php.ini-production $INSTALL_DIR/php/etc/php.ini cp -a $INSTALL_DIR/php/etc/php-fpm.conf.default $INSTALL_DIR/php/etc/php-fpm.conf cp -a $INSTALL_DIR/php/etc/php-fpm.d/www.conf.default $INSTALL_DIR/php/etc/php-fpm.d/www.conf cp -a sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm # /etc/init.d/php-fpm start cp -a $PWD_C/php.service /usr/lib/systemd/system systemctl daemon-reload systemctl enable php.service systemctl start php.service command_status_check "PHP - 启动失败!" } function install_mysql() { yum install mariadb-server -y command_status_check "mysql - 安装失败!" systemctl enable mariadb.service systemctl start mariadb.service command_status_check "mysql - 启动失败!" } read -p "请输入编号:" number case $number in 1) install_nginx;; 2) install_php;; 3) install_mysql;; 4) install_mysql install_nginx install_php ;; 9) exit;; esac
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
2020-04-24 29、Tomcat只允许指定域名访问,禁用IP地址访问,防止恶意解析