Shell脚本之一键安装LNMP环境

曾经终败给现在 2022-04-15 06:08 892阅读 0赞

本脚本和Nginx源码包、php-fpm的rpm包在一个目录才能使用

本脚本的LNMP为Linux、Nginx、Mariadb、PHP

脚本内容:

  1. #!/bin/bash
  2. yum repolist &>/dev/null
  3. [ $? -eq 0 ]&&yum -y install gcc pcre-devel openssl-devel || echo "yum not available..." exit
  4. tar -xf nginx-1.12.2.tar.gz
  5. cd nginx-1.12.2
  6. ./configure --with-http_ssl_module
  7. make &&make install
  8. yum -y install mariadb mariadb-server mariadb-devel
  9. yum -y install php php-mysql
  10. rpm -ivh php-fpm-5.4.16-42.el7.x86_64.rpm
  11. sed -i 70s/fastcgi_params/fastcgi.conf/ /usr/local/nginx/conf/nginx.conf
  12. sed -i 69d /usr/local/nginx/conf/nginx.conf
  13. sed -i 65,70s/#// /usr/local/nginx/conf/nginx.conf
  14. echo "<?php
  15. $i=33;
  16. echo $i;
  17. ?>" > /usr/local/nginx/html/test.php
  18. systemctl stop httpd ##防止端口占用
  19. /usr/local/nginx/sbin/nginx
  20. ln -s /usr/local/nginx/sbin/nginx /sbin/ ##软链接,方便使用
  21. systemctl start mariadb
  22. systemctl start php-fpm

发表评论

表情:
评论列表 (有 0 条评论,892人围观)

还没有评论,来说两句吧...

相关阅读