lanmp一键安装脚本

一、要求

  • 系统:CentOS 7+
  • 用户:root

二、使用

1. 自定义安装路径

获取脚本

git clone https://github.com/a1711hw/lanmp.git
cd lanmp.sh

# 配置执行权限
chmod +x lanmp.sh

可以自行修改lanmp.conf配置文件,定义安装路径:

# lamp and lnmp directory configuration.

# mysql
mysql=/usr/local/mysql
mysql_data=/data/mysql

# apache
apache=/usr/local/apache24

# php version
php=/usr/local/php

# nginx
nginx=/usr/local/nginx

# php-fpm
php_fpm=/usr/local/php-fpm

# website directory
web_data=/data/www

安装

# lamp
./lanmp.sh lamp

# lnmp
./lanmp.sh lnmp

卸载

# lamp
./lanmp.sh uninstall_lamp

# lnmp
./lanmp.sh uninstall_lnmp

2. 使用默认路径

wget https://github.com/a1711hw/lanmp/raw/master/lanmp.sh && chmod +x lanmp.sh && ./lanmp.sh

交互界面

1. 安装

  • MySQL

版本选择:

Please select stream mysql version:
MySQL-5.5
MySQL-5.6
MySQL-5.7
MySQL-8.0
Which mysql you'd select(Default: MySQL-5.5):

使用序号选择然后回车即可。
安装后会自行启动mysql服务,配置MySQL服务root密码:

Starting MySQL.Logging to '/data/mysql/test02.err'.
... SUCCESS!

Please enter the mysql server root password:
  • Apache或Nginx

自动会安装最新版本,并且在/data/www创建一个测试的PHP网站。

  • PHP部分

版本选择:

Please select stream php version:
php-7.2
php-7.1
php-7.0
php-5.6
Which php you'd select(Default: php-7.2):

PHP安装时间会很长,此时可以四处走动一下,或者泡一碗方便面。

  • 完成
+---------------------------------------------------------------------------+
|                                                                           |
|        Info:      The LAMP and LNMP install script.                       |
|        Author:    v.A1711_HW                                              |
|        Eamil      a1711_hw@xl78693.com                                    |
|        Blog:      https://blog.xl78693.com                                |
|                                                                           |
+---------------------------------------------------------------------------+

+---------------------------------------------------------------------------+

       Your ip address           | 192.168.237.8
       Mysql data dir            | /data/mysql
       Web root                  | /data/www

+---------------------------------------------------------------------------+

[Info!] The lamp install success!
[Info!] Please visit your IP address in your browser.
[Info!] Thanks for your use this script.

所有的服务均已启动,可以打开浏览器访问IP地址,查看PHP是否正常解析。
下图为正常解析页面:

2. 卸载

+---------------------------------------------------------------------------+
|                                                                           |
|        Info:      The LAMP and LNMP install script.                       |
|        Author:    v.A1711_HW                                              |
|        Eamil      a1711_hw@xl78693.com                                    |
|        Blog:      https://blog.xl78693.com                                |
|                                                                           |
+---------------------------------------------------------------------------+






[Info!] The apache and php uninstall success!

[Info!] The mysql uninstall success!

[Info!] The lnmp uninstall success!
[Info!] The site root has been backed up as /data/www_bak
[Info!] Thanks for your use this script.

MySQL数据和网站数据备份在/data//mysql_bak和/data/www_bak目录。

标签: web, 脚本

添加新评论