Pages

Saturday, 24 February 2018

lnmp的一个一键安装脚本-EasyEngine

EasyEngine (ee) is a Linux shell-script to install and manage wordpress-nginx websites in one go. Using EasyEngine, you can install Nginx, PHP, MySQL, Postfix, phpMyAdmin and their dependencies in one shot easily without the help of a System administrator. It makes very easy to install and manage wordpress-nginx websites, and you don’t have to manually install each packages and memorize all commands. Everything will be done automatically on the background. EasyEngine will work on Ubuntu LTS versions such as Ubuntu 12.04/14.04, and Debian 6/7 version. Unfortunately, there is no support for RPM based systems like CentOS, and there is no future plan to make it work on RPM based systems right now.

Features

The following are the notable features of EasyEngine:
  • Install Nginx, php, mysql, phpmyadmin and all its dependencies in single command.
  • Automatically tweaks server configuration as per available hardware resources.
  • Single and multi-site support, and It can manage any number of wordpress websites.
  • Supports automatic updates.
  • It installs w3-total-cache, wp-super-cache, nginx’s fastcgi-cache, Zend Opcache, and Memcache.

Install EasyEngine on Ubuntu 14.04 LTS server

Run the following command to install EasyEngine from Terminal:
curl -sL rt.cx/ee | sudo bash
Sample output:
 Executing apt-get update, please wait...
 Creating EasyEngine (ee) log directory, please wait...
 Installing required packages, please wait...
 Reading package lists...
 Building dependency tree...
 Reading state information...
 bc is already the newest version.
 coreutils is already the newest version.
 curl is already the newest version.
 ed is already the newest version.
 tar is already the newest version.
 wget is already the newest version.
 The following extra packages will be installed:
 fontconfig fontconfig-config fonts-dejavu-core fonts-liberation git git-man
 libcairo2 libcdt5 libcgraph6 libdatrie1 liberror-perl libfontconfig1 libgd3
 libgraphite2-3 libgvc6 libgvpr2 libharfbuzz0b libice6 libjbig0
 libjpeg-turbo8 libjpeg8 libltdl7 libpango-1.0-0 libpangocairo-1.0-0
 libpangoft2-1.0-0 libpathplan4 libpixman-1-0 libsm6 libthai-data libthai0
 libtiff5 libvpx1 libxaw7 libxcb-render0 libxcb-shm0 libxmu6 libxpm4
 libxrender1 libxt6 python-pycurl x11-common
 Suggested packages:
 git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
 gitweb git-arch git-bzr git-cvs git-mediawiki git-svn gsfonts graphviz-doc
 libgd-tools ttf-baekmuk ttf-arphic-gbsn00lp ttf-arphic-bsmi00lp
 ttf-arphic-gkai00mp ttf-arphic-bkai00mp libcurl4-gnutls-dev
 python-pycurl-dbg
 The following NEW packages will be installed:
 fontconfig fontconfig-config fonts-dejavu-core fonts-liberation git git-core
 git-man graphviz libcairo2 libcdt5 libcgraph6 libdatrie1 liberror-perl
 libfontconfig1 libgd3 libgraphite2-3 libgvc6 libgvpr2 libharfbuzz0b libice6
 libjbig0 libjpeg-turbo8 libjpeg8 libltdl7 libpango-1.0-0 libpangocairo-1.0-0
 libpangoft2-1.0-0 libpathplan4 libpixman-1-0 libsm6 libthai-data libthai0
 libtiff5 libvpx1 libxaw7 libxcb-render0 libxcb-shm0 libxmu6 libxpm4
 libxrender1 libxt6 python-pycurl python-software-properties x11-common
 0 upgraded, 44 newly installed, 0 to remove and 47 not upgraded.
 Need to get 9,716 kB of archives.
 After this operation, 43.4 MB of additional disk space will be used.
 Get:1 http://in.archive.ubuntu.com/ubuntu/ trusty/main fonts-dejavu-core all 2.34-1ubuntu1 [1,024 kB]
 Get:2 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main fontconfig-config all 2.11.0-0ubuntu4.1 [47.4 kB]
 Get:3 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main libfontconfig1 i386 2.11.0-0ubuntu4.1 [124 kB]
 [...]
 .
 .
 .
 .
 [...]
 EasyEngine (ee) required your name & email address
 to track changes you made under the Git version control
 EasyEngine (ee) will be able to send you daily reports & alerts in upcoming version
 EasyEngine (ee) will NEVER send your information across
 
 For EasyEngine (ee) auto completion, run the following command
 source /etc/bash_completion.d/ee
 
 EasyEngine (ee) installed successfully
 EasyEngine (ee) help: https://rtcamp.com/easyengine/docs/
For EasyEngine (ee) auto completion, run the following command:
source /etc/bash_completion.d/ee

Usage

Now, let us install EasyEngine stack. The following command will install nginx, php, mysql, and postfix with all their dependencies in one go.
sudo ee stack install
Sample output:
Adding rtCamp NGINX launchpad repository, please wait...
Adding Ondrej PHP5 launchpad repository, please wait...
Executing apt-get update, please wait...
Installing nginx-custom, please wait...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  libxslt1.1 nginx-common
The following NEW packages will be installed:
  libxslt1.1 nginx-common nginx-custom
0 upgraded, 3 newly installed, 0 to remove and 47 not upgraded.
Need to get 588 kB of archives.
After this operation, 1,654 kB of additional disk space will be used.
[...]
.
.
.
[...]

Setting up NGINX, please wait...
Generating SSL private key
Generating a certificate signing request (CSR)
Removing pass phrase from SSL private key
Generating SSL certificate
Setting up PHP5, please wait...
Setting up MySQL, please wait...
Executing service nginx restart, please wait...
Executing service php5-fpm restart, please wait...
Executing service mysql restart, please wait...
Git commit on /etc/nginx/, please wait...
Git commit on /etc/php5/, please wait...
Git commit on /etc/mysql/, please wait...
Git commit on /etc/postfix, please wait...
Downloading Adminer, please wait...
Downloading phpMyAdmin, please wait...
Installing WP-CLI, please wait...
Installing phpMemcachedAdmin, please wait...
Downloading nginx FastCGI cleanup script, please wait...
Downloading OPcache, please wait...
Cloning Webgrind, please wait...
Cloning Anemometer, please wait...
Successfully installed all packages
Create your first WordPress site powered by NGINX using:
ee site create example.com --w
Nginx, php, phpmyadmin, adminer, phpmyadmin have been installed.
You can access the nginx test page by navigating to the URL: http://ip-address or http://localhost.
Now, you can create a sample wordpress and non-wordpress websites as many as you want. For example, to create a wordpress site called “unixmen.local”, enter the following command.
sudo ee site create unixmen.local --wp
Sample output:
Creating unixmen.local, please wait...
Creating symbolic link for unixmen.local
Creating htdocs & logs directory
Downloading WordPress, please wait...
Setting up WordPress, please wait...
Updating WordPress permalink, please wait...
Installing Nginx Helper plugin, please wait...
Changing ownership of /var/www/unixmen.local, please wait...
Git commit on /etc/nginx/, please wait...
Executing service nginx reload, please wait...

WordPress Admin Username: admin
WordPress Admin Password: zVMW3gfrXtbI9ii

Successfully created new website: http://unixmen.local
That’s it. My wordpress site has been created in less than 5 minutes. Very simple, isn’t?
To find the mysql server root user password, use the following command:
sudo cat ~/.my.cnf
Sample output:
[client]
user=root
password=lTMtPXyvbmdNr2w
For wordpress site specific username and password, check the wordpress site’s wp-config.php file. In our case, my unixmen.local wordpress site wp-config.php file is located in /var/www/unixmen.local.
ls /var/www/unixmen.local/
htdocs  logs  wp-config.php

List of EasyEngine commands to create WordPress and Non-wordpress websites

Standard WordPress Sites:
ee site create example.com --wp                  # install wordpress without any page caching
ee site create example.com --w3tc                # install wordpress with w3-total-cache plugin 
ee site create example.com --wpsc                # install wordpress with wp-super-cache plugin 
ee site create example.com --wpfc                # install wordpress + nginx fastcgi_cache
WordPress Multsite with subdirectory:
ee site create example.com --wpsubdir            # install wpmu-subdirectory without any page caching
ee site create example.com --wpsubdir --w3tc     # install wpmu-subdirectory with w3-total-cache plugin 
ee site create example.com --wpsubdir --wpsc     # install wpmu-subdirectory with wp-super-cache plugin 
ee site create example.com --wpsubdir --wpfc     # install wpmu-subdirectory + nginx fastcgi_cache
WordPress Multsite with subdomain:
ee site create example.com --wpsubdom            # install wpmu-subdomain without any page caching
ee site create example.com --wpsubdom --w3tc     # install wpmu-subdomain with w3-total-cache plugin 
ee site create example.com --wpsubdom --wpsc     # install wpmu-subdomain with wp-super-cache plugin 
ee site create example.com --wpsubdom --wpfc     # install wpmu-subdomain + nginx fastcgi_cache
Non-WordPress Sites:
ee site create example.com --html                # create example.com for static/html sites
ee site create example.com --php                 # create example.com with php support
ee site create example.com --mysql               # create example.com with php & mysql support
EasyEngine supports debugging feature from version 1.3. For example, to enable debugging for your wordpress site, enter the following command.
sudo ee debug unixmen.local
Replace unixmen.local with your own wordpress site name.
The above command will put WordPress into debug mode, enable xdebug profiling for PHP, PHP-FPM Slow-log, MySQL’s slow query log and nginx’s debug log. After complete debugging, run the following command to stop it.
sudo ee debug unixmen.local --stop
To debug entire system, use the following command:
sudo ee debug
The above command will turn on php, mysql, nginx debugging. Please note that it will not enable any WordPress debugging.
After you finish debugging, run following command to turn off debugging mode.
ee debug --stop
To view the system (OS) status and also running status of php, mysql, nginx and postfix services, run the following command.
sudo ee system status
Sample output:
 System information as of Fri Jul 18 15:18:47 IST 2014

 System load:    0.00         Processes:        84
 Usage of /:    8%         Users logged in:    2
 Memory usage:    14%         Swap usage:        .05%

 Service status information

 Nginx:        Running
 PHP5-FPM:    Running
 MySQL:        Running
 Postfix:    Running
Similarly, you can start, stop, restart ee using the following commands.
sudo ee system start
sudo ee system stop
sudo ee system restart
Be mindful that “ee system restart” will not restart your Ubuntu server, instead it just restarts nginx, php, mysql and postfix services.

Managing Access Control For PhpMyAdmin and Other administration tools

EasyEngine stores all admin tools like phpMyAdmin, MemCache viewer, Zend Opcache Viewer and other web-accessible tools in a protected location /ee. You can add /ee to any domain (Ex: unixmen.local/ee to access admin tools).
This location is mapped to /var/www/shared/. Any other script you put inside this directory can be access from /ee subpaths.
Followings are the method to access protected area:
  1. Whitelisting allowed IP-addresses.
  2. HTTP Authentication.
Edit /etc/nginx/common/acl.conf file,
sudo nano /etc/nginx/common/acl.conf
Add the ip address to whiltelist.
allow   192.168.1.0/24;
allow   127.0.0.1;
allow   192.168.1.100;
deny all;
Replace 192.168.1.100 with your own ip address.
After above process, try to reload nginx by using following command,
sudo ee system restart
Or, just use the following command to restart nginx service alone. Make sure you are running the following user with root user privileges.
nginx -t && service nginx restart
If you do not have dynamic IP, or working remotely, you can still access the protected area, by providing HTTP Authentication username and password.
During easyengine installation or upgrade, it asks for your HTTP Authentication username and password.
If you forget/skip this step, you can still find your Username and Password by using following command:
cat /etc/easyengine/ee.conf | grep htpasswd
Output:
htpasswduser = easyengine
htpasswdpass = easyengine
By default, username and password, both are easyengine.
If you want to change the default username and password for http authentication, run the following command:
ee secure --auth
Sample output:
Provide HTTP authentication user name [easyengine]: 
Provide HTTP authentication password [easyengine]: 
Executing service nginx reload, please wait...
That’s it. After that, restart nginx service as shown below.
nginx -t && service nginx restart

Updating EasyEngine

To update to the most recent version of EasyEngine, run the following command:
sudo ee update

No comments:

Post a Comment