Interactive installation

How to use

yum -y install wget screen  #For CentOS/Redhat
#apt-get -y install wget screen  #For Debian/Ubuntu
wget http://mirrors.linuxeye.com/lnmp-full.tar.gz  #Contains the source code
tar xzf lnmp-full.tar.gz
cd lnmp  #If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file
screen -S lnmp  #If network interruption, you can execute the command `screen -r lnmp` reconnect install window
sudo ./install.sh
# sudo ~/lnmp/install.sh

#######################################################################
#         LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+          #
#                              Install                                #
#######################################################################

Do you want to check md5sum? [y/n]: y

Please input SSH port(Default: 22): 22

Do you want to enable firewall? [y/n]: n

Do you want to install Web server? [y/n]: y

Please select Nginx server:
        1. Install Nginx
        2. Install Tengine
        3. Install OpenResty
        4. Do not install
Please input a number:(Default 1 press Enter) 1

Do you want to install Apache? [y/n]: n

Please select tomcat server:
        1. Install Tomcat-10
        2. Install Tomcat-9
        3. Install Tomcat-8
        4. Install Tomcat-7
        5. Do not install
Please input a number:(Default 5 press Enter) 

Do you want to install Database? [y/n]: y

Please select a version of the Database:
         1. Install MySQL-8.0
         2. Install MySQL-5.7
         3. Install MySQL-5.6
         4. Install MySQL-5.5
         5. Install MariaDB-10.11
         6. Install MariaDB-10.5
         7. Install MariaDB-10.4
         8. Install MariaDB-5.5
         9. Install Percona-8.0
        10. Install Percona-5.7
        11. Install Percona-5.6
        12. Install Percona-5.5
        13. Install PostgreSQL
        14. Install MongoDB
Please input a number:(Default 2 press Enter) 5
Please input the root password of MySQL(default: f8j1T9Z2): f8j1T9Z2

Please choose installation of the database:
        1. Install database from binary package.
        2. Install database from source package.
Please input a number:(Default 1 press Enter) 1

Do you want to install PHP? [y/n]: y

Please select a version of the PHP:
         1. Install php-5.3
         2. Install php-5.4
         3. Install php-5.5
         4. Install php-5.6
         5. Install php-7.0
         6. Install php-7.1
         7. Install php-7.2
         8. Install php-7.3
         9. Install php-7.4
        10. Install php-8.0
        11. Install php-8.1
        12. Install php-8.2
        13. Install php-8.3
        14. Install php-8.4
Please input a number:(Default 12 press Enter) 14

Do you want to install opcode cache of the PHP? [y/n]: y
Please select a opcode cache of the PHP:
        1. Install Zend OPcache
        2. Install APCU
Please input a number:(Default 1 press Enter) 1

Please select PHP extensions:
         0. Do not install
         1. Install zendguardloader(PHP<=5.6)
         2. Install ioncube
         3. Install sourceguardian(PHP<=7.2) 4. Install imagick 5. Install gmagick 6. Install fileinfo 7. Install imap 8. Install ldap 9. Install phalcon(PHP>=5.5)
        10. Install yaf(PHP>=7.0)
        11. Install redis
        12. Install memcached
        13. Install memcache
        14. Install mongodb
        15. Install swoole
        16. Install xdebug(PHP>=5.5)
Please input numbers:(Default '4 11 12' press Enter) 4 11

Do you want to install Nodejs? [y/n]: n

Do you want to install Pure-FTPd? [y/n]: n

Do you want to install phpMyAdmin? [y/n]: n

Do you want to install redis-server? [y/n]: y

Do you want to install memcached-server? [y/n]: y

How to add Extensions

# sudo ~/lnmp/addons.sh

#######################################################################
#          LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+         #
#                    Install/Uninstall Extensions                     #
#######################################################################

What Are You Doing?
        1. Install/Uninstall PHP Composer
        2. Install/Uninstall fail2ban
        3. Install/Uninstall ngx_lua_waf
        q. Exit
Please input the correct option: 3

Please select an action:
        1. install
        2. uninstall
Please input a number:(Default 1 press Enter) 1

How to add a virtual host

# sudo ~/lnmp/vhost.sh

#######################################################################
#          LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+         #
#######################################################################

What Are You Doing?
        1. Use HTTP Only
        2. Use your own SSL Certificate and Key
        3. Use Let's Encrypt to Create SSL Certificate and Key
        q. Exit
Please input the correct option: 3

Please input domain(example: www.example.com): demo.linuxeye.com
domain=demo.linuxeye.com

Please input the directory for the domain:demo.linuxeye.com :
(Default directory: /data/wwwroot/demo.linuxeye.com):
Virtual Host Directory=/data/wwwroot/demo.linuxeye.com

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: y

Type domainname or IP(example: example.com other.example.com): demo2.linuxeye.com
domain list=demo2.linuxeye.com

Do you want to redirect from demo2.linuxeye.com to demo.linuxeye.com? [y/n]: y  

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y

Please select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048): 2048

Please enter your email: lj2007331@mail.com

[Sun Oct 30 04:27:06 PM CST 2022] Create account key ok.
[Sun Oct 30 04:27:06 PM CST 2022] No EAB credentials found for ZeroSSL, let's get one
[Sun Oct 30 04:27:13 PM CST 2022] Registering account: https://acme.zerossl.com/v2/DV90
[Sun Oct 30 04:27:15 PM CST 2022] Could not get nonce, let's try again.
[Sun Oct 30 04:27:39 PM CST 2022] Registered
[Sun Oct 30 04:27:39 PM CST 2022] ACCOUNT_THUMBPRINT='LMG4Elq-AFm-IH17QAk3yjmp-8TNoxi__gWTIIT1tzY'
....
[Sun Oct 30 04:28:20 PM CST 2022] Cert success.

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Do you want to add hotlink protection? [y/n]: n

Allow Rewrite rule? [y/n]: y

Please input the rewrite of programme :
wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel
thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist.
(Default rewrite: other): wordpress
You choose rewrite=wordpress

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/demo.linuxeye.com_nginx.log

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#           LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+        #
#######################################################################
Your domain:                  demo.linuxeye.com
Virtualhost conf:             /usr/local/nginx/conf/vhost/demo.linuxeye.com.conf
Directory of:                 /data/wwwroot/demo.linuxeye.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/wordpress.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/demo.linuxeye.com.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/demo.linuxeye.com.key

How to delete a virtual host

# sudo ~/lnmp/vhost.sh --del

#######################################################################
#           LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+        #
#######################################################################

Virtualhost list:
demo1.linuxeye.com demo.linuxeye.com www.linuxeye.com

Please input a domain you want to delete: demo.linuxeye.com

Do you want to delete Virtul Host directory? [y/n]: y
Press Ctrl+c to cancel or Press any key to continue...

Domain: demo.linuxeye.com has been deleted.

How to add FTP virtual user

# sudo ~/lnmp/pureftpd_vhost.sh

#######################################################################
#           LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+        #
#                 FTP virtual user account management                 #
#######################################################################

What Are You Doing?
        1. UserAdd      #Tip: Add Ftp account
        2. UserMod      #Tip: Change the webroot directory permissions of an Ftp account
        3. UserPasswd   #Tip: Change a ftp password
        4. UserDel      #Tip: Delete a ftp account
        5. ListAllUser  #Tip: List all Ftp accounts
        6. ShowUser     #Tip: Display a Ftp account details
        q. Exit         #Tip: Quit
Please input the correct option: 1

Please input a username: ftpuser

Please input the password: UArUDjLZ12HD

Please input the directory(Default directory: /data/wwwroot):    #Tip: ftpuser webroot directory, it is recommended to default, you can directly press Enter.
Password: 
Enter it again: 
#####################################

[ftpuser] create successful! 

You user name is : ftpuser
You Password is : UArUDjLZ12HD
You directory is : /data/wwwroot

How to backup

Backup parameters

# sudo ~/lnmp/backup_setup.sh

#######################################################################
#           LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+        #
#                     Setup the backup parameters                     #
#######################################################################

Please select your backup destination:
        1. Localhost
        2. Remote host
        3. Aliyun OSS
        4. Qcloud COS
        5. UPYUN
        6. QINIU
        7. Amazon S3
        8. Dropbox
Please input numbers:(Default 1 press Enter) 1

Please select your backup content:
        1. Only Database
        2. Only Website
        3. Database and Website
Please input a number:(Default 1 press Enter) 1

Please enter the directory for save the backup file: 
(Default directory: /data/backup):

Please enter a valid backup number of days: 
(Default days: 5): 10

Please enter one or more name for database, separate multiple database names with commas: 
(Default database: linuxeye,wordpress) linuxeye,wordpress

You have to backup the content:
Database: linuxeye,wordpress

Perform the backup immediately

sudo ~/lnmp/backup.sh

Setup scheduled tasks to automatically schedule backup

sudo echo '0 1 * * * sudo /root/lnmp/backup.sh > /dev/null 2>&1' >> /var/spool/cron/root

How to manage service

Nginx/Tengine/OpenResty

systemctl {start|stop|status|restart|reload} nginx

MySQL/MariaDB/Percona

systemctl {start|stop|restart|status} mysqld

PHP

systemctl {start|stop|restart|reload|status} php-fpm

Apache

systemctl {start|stop|status|restart|reload} httpd

Pure-Ftpd

systemctl {start|stop|restart|status} pureftpd

Redis

systemctl {start|stop|status|restart|reload} redis-server

Memcached

systemctl {start|stop|status|restart|reload} memcached

How to upgrade

# sudo ~/lnmp/upgrade.sh

#######################################################################
#          LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+         #
#                Upgrade Software versions for LNMP                   #
#######################################################################

What Are You Doing?
         1. Upgrade Nginx/Tengine/OpenResty
         2. Upgrade Apache
         3. Upgrade Tomcat
         4. Upgrade MySQL/MariaDB/Percona
         5. Upgrade PHP
         6. Upgrade Redis
         7. Upgrade Memcached
         8. Upgrade phpMyAdmin
         9. Upgrade OneinStack latest
        10. Upgrade acme.sh latest
         q. Exit

Please input the correct option: q

How to uninstall

# sudo ~/lnmp/uninstall.sh

#######################################################################
#           LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+        #
#                               Uninstall                             #
#######################################################################

What Are You Doing?
         0. Uninstall All
         1. Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat
         2. Uninstall MySQL/MariaDB/Percona
         3. Uninstall PostgreSQL
         4. Uninstall MongoDB
         5. Uninstall all PHP
         6. Uninstall PHP opcode cache
         7. Uninstall PHP extensions
         8. Uninstall PureFtpd
         9. Uninstall Redis
        10. Uninstall Memcached
        11. Uninstall phpMyAdmin
        12. Uninstall Nodejs (PATH: /usr/local/node)
         q. Exit

Please input the correct option: q