From 617bf60731e67280a1fecada3da5d683ce4643f7 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 21 Feb 2014 16:43:10 +0530 Subject: [PATCH 01/50] EasyEngine Admin Tools Moved On Port No: 22222 #124 --- etc/nginx/common/locations.conf | 41 +++++++++++++------------ etc/nginx/conf.d/eeadmin.conf | 25 +++++++++++++++ usr/local/sbin/easyengine | 54 ++++++++++++++++----------------- 3 files changed, 74 insertions(+), 46 deletions(-) create mode 100644 etc/nginx/conf.d/eeadmin.conf diff --git a/etc/nginx/common/locations.conf b/etc/nginx/common/locations.conf index 81e6fc96..499646f6 100644 --- a/etc/nginx/common/locations.conf +++ b/etc/nginx/common/locations.conf @@ -22,34 +22,37 @@ location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gi # EasyEngine Shared Settings -location /ee/ { - autoindex on; - alias /var/www/shared/; - include common/acl.conf; - index index.php index.html index.htm; - - location ~ ^/ee(.+\.php)$ { - alias /var/www/shared$1; - fastcgi_pass php; - include /etc/nginx/fastcgi_params; - } - - location ~* ^/ee(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { - alias /var/www/shared$1; - } -} +#location /ee/ { +# autoindex on; +# alias /var/www/shared/; +# include common/acl.conf; +# index index.php index.html index.htm; + +# location ~ ^/ee(.+\.php)$ { +# alias /var/www/shared$1; +# fastcgi_pass php; +# include /etc/nginx/fastcgi_params; +# } + +# location ~* ^/ee(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { +# alias /var/www/shared$1; +# } +#} # PMA Settings location /pma { - rewrite ^/* /ee/pma last; + #rewrite ^/* /ee/pma last; + return 301 $scheme://$host:22222/pma; } location /phpMyAdmin { - rewrite ^/* /ee/pma last; + #rewrite ^/* /ee/pma last; + return 301 $scheme://$host:22222/pma; } location /phpmyadmin { - rewrite ^/* /ee/pma last; + #rewrite ^/* /ee/pma last; + return 301 $scheme://$host:22222/pma; } diff --git a/etc/nginx/conf.d/eeadmin.conf b/etc/nginx/conf.d/eeadmin.conf new file mode 100644 index 00000000..ca219e53 --- /dev/null +++ b/etc/nginx/conf.d/eeadmin.conf @@ -0,0 +1,25 @@ +# WPSINGLE BASIC NGINX CONFIGURATION +server { + + listen 22222; + server_name _; + + access_log /var/log/nginx/eeadmin.access.log rt_cache; + error_log /var/log/nginx/eeadmin.error.log; + + root /var/www/eeadmin/htdocs; + index index.php index.htm index.html; + + location / { + autoindex on; + include common/acl.conf; + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; + } + +} diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index ebedf694..302cc124 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -329,25 +329,25 @@ WP-CLI() INSTALLPMA() { # Install PMA/phpMyAdmin - if [ ! -d /var/www/shared/pma ] + if [ ! -d /var/www/eeadmin/htdocs/pma ] then echo -e "\033[34mInstalling phpMyAdmin, Please Wait...\e[0m" # Setup PMA/phpMyAdmin - mkdir -p /var/www/shared/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/shared/pma/" + mkdir -p /var/www/eeadmin/htdocs/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/eeadmin/htdocs/pma/" # Download PMA/phpMyAdmin - wget -cqO /var/www/shared/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ + wget -cqO /var/www/eeadmin/htdocs/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ || OwnError "Unable To Download phpMyAdmin" # Extract PMA/phpMyAdmin - tar --strip-components=1 -zxf /var/www/shared/pma/pma.tar.gz -C /var/www/shared/pma/ \ + tar --strip-components=1 -zxf /var/www/eeadmin/htdocs/pma/pma.tar.gz -C /var/www/eeadmin/htdocs/pma/ \ || OwnError "Unable To Extract phpMyAdmin" # Remove Unwanted Files - rm -f /var/www/shared/pma/pma.tar.gz + rm -f /var/www/eeadmin/htdocs/pma/pma.tar.gz else - echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/shared/pma)...\e[0m" + echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/eeadmin/htdocs/pma)...\e[0m" fi } @@ -440,7 +440,7 @@ REMOVEPMA() { # Remove PMA/phpMyAdmin echo -e "\033[34mRemoving phpMyAdmin, Please Wait...\e[0m" - rm -rf /var/www/shared/pma || OwnError "Unable To Remove phpMyAdmin" + rm -rf /var/www/eeadmin/htdocs/pma || OwnError "Unable To Remove phpMyAdmin" } REMOVEMYSQL() @@ -1063,29 +1063,29 @@ PERMISSIONANDGIT() EEOPMEMCACHE() { # Opcache Settings - if [ ! -d /var/www/shared/opcache ] + if [ ! -d /var/www/eeadmin/htdocs/opcache ] then - mkdir -p /var/www/shared/opcache || OwnError "Unable To Create Opcache Directory" + mkdir -p /var/www/eeadmin/htdocs/opcache || OwnError "Unable To Create Opcache Directory" # Download Opcache Status Files - wget -cqO /var/www/shared/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php - wget -cqO /var/www/shared/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php - wget -cqO /var/www/shared/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php + wget -cqO /var/www/eeadmin/htdocs/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php + wget -cqO /var/www/eeadmin/htdocs/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php + wget -cqO /var/www/eeadmin/htdocs/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php fi # Memcache Settings - if [ ! -d /var/www/shared/memcache ] + if [ ! -d /var/www/eeadmin/htdocs/memcache ] then - mkdir -p /var/www/shared/memcache || OwnError "Unable To Create Memcache Directory" + mkdir -p /var/www/eeadmin/htdocs/memcache || OwnError "Unable To Create Memcache Directory" # Download phpMemcachedAdmin - wget -cqO /var/www/shared/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz + wget -cqO /var/www/eeadmin/htdocs/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz # Extract phpMemcachedAdmin - tar -zxf /var/www/shared/memcache/memcache.tar.gz -C /var/www/shared/memcache + tar -zxf /var/www/eeadmin/htdocs/memcache/memcache.tar.gz -C /var/www/eeadmin/htdocs/memcache # Remove Unwanted Files - rm -f /var/www/shared/memcache/memcache.tar.gz + rm -f /var/www/eeadmin/htdocs/memcache/memcache.tar.gz fi } @@ -1334,7 +1334,7 @@ then INSTALLPMA # Initialise Git - EEGITDIR=/var/www/shared/pma/ + EEGITDIR=/var/www/eeadmin/htdocs/pma/ EEGITINIT # Display Success Message @@ -1424,7 +1424,7 @@ then EEGITINIT # Initialize Git - EEGITDIR=/var/www/shared/pma/ + EEGITDIR=/var/www/eeadmin/htdocs/pma/ EEGITINIT # Initialize Git @@ -1872,7 +1872,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display Success Message echo @@ -1896,7 +1896,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -1927,7 +1927,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -1958,7 +1958,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -1994,7 +1994,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display Success Message echo @@ -2018,7 +2018,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2049,7 +2049,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2080,7 +2080,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee + #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo From 4b0de050fe4f53458c511fc6b3dccf935e42e7d2 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 24 Feb 2014 11:17:45 +0530 Subject: [PATCH 02/50] Fix Issue #33 --- usr/local/sbin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 302cc124..147aa419 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -588,7 +588,7 @@ MYSQLPASSCHECK() MYSQLROOT() { MYSQLUSER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2) - MYSQLPASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2) + MYSQLPASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//') } # GET Information Function MYSQLINFO() From 918d5d3fbe277803dd9d86b9e0a73d598616e745 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 28 Feb 2014 18:30:34 +0530 Subject: [PATCH 03/50] Fix WP-CLI Version --- usr/local/sbin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 17434f49..c266ef3a 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -313,7 +313,7 @@ WP-CLI() then echo -e "\033[31mWP-CLI Command Not Found\e[0m" echo -e "\033[34mInstalling WP-CLI, Please Wait...\e[0m" - curl -sL https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | INSTALL_DIR='/usr/share/easyengine/wp-cli' bash &>> $INSTALLLOG \ + curl -sL https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | INSTALL_DIR='/usr/share/easyengine/wp-cli' VERSION='0.14.0' bash &>> $INSTALLLOG \ || OwnError "Unable To Install WP-CLI" # Add WP-CLI Command In PATH Variable From 507166bdc34722c074ba68605ced6a6984126116 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 4 Mar 2014 17:06:05 +0530 Subject: [PATCH 04/50] Specify Branch Name Using EE_BRANCH Variable --- install.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index dd08b79e..140bdd22 100644 --- a/install.sh +++ b/install.sh @@ -120,13 +120,27 @@ fi # Pre Checks End # Clone EasyEngine (ee) -echo -e "\033[34mCloning EasyEngine (ee), Please Wait...\e[0m" | tee -ai $INSTALLLOG +if [ -z "$EE_BRANCH" ] +then + EE_BRANCH=stable +else + # Cross Check The Branch Name + git ls-remote --heads https://github.com/rtCamp/easyengine | grep $EE_BRANCH &>> $INSTALLLOG + + if [ $? -ne 0 ] + then + echo -e "\033[31mThe $EE_BRANCH Branch Does Not Exist, Please Provide The Correct Branch Name\e[0m" | tee -ai $INSTALLLOG + exit 103; + fi +fi + +echo -e "\033[34mCloning EasyEngine (ee) $EE_BRANCH Branch, Please Wait...\e[0m" | tee -ai $INSTALLLOG # Remove Older EasyEngine (ee) If Found rm -rf /tmp/easyengine &>> /dev/null -# Clone EasyEngine (ee) Stable Repository -git clone -b stable git://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $INSTALLLOG || OwnError "Unable To Clone Easy Engine" +# Clone EasyEngine (ee) Repository +git clone -b $EE_BRANCH git://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $INSTALLLOG || OwnError "Unable To Clone Easy Engine" # Create Directory /etc/easyengine From 4c73716f8d058d7c8e14287197bbadd383bd830b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 5 Mar 2014 14:08:14 +0530 Subject: [PATCH 05/50] Fixed Nginx Settings #100 --- usr/local/sbin/easyengine | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index ea2078bc..93849351 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -215,16 +215,25 @@ COMMONNGINX() if [ $? -ne 0 ] then - # Change Nginx Worker Processes Connections And Gzip - sed -i "s/# gzip/gzip/" /etc/nginx/nginx.conf + # Change Nginx Main Section Settings + sed -i "s/worker_processes.*/worker_processes auto;/" /etc/nginx/nginx.conf + sed -i "/worker_processes/a \worker_rlimit_nofile 100000;" /etc/nginx/nginx.conf + + # Change Nginx Events Section Settings sed -i "s/worker_connections.*/worker_connections 1024;/" /etc/nginx/nginx.conf - sed -i "s/worker_processes.*/worker_processes `cat /proc/cpuinfo | grep processor | wc -l`;/" /etc/nginx/nginx.conf + sed -i "s/# multi_accept/multi_accept/" /etc/nginx/nginx.conf + + # Disable Nginx Version Set Custom Headers Proxy And SSL Settings + sed -i "s/http {/http {\n\t##\n\t# Easy Engine Settings\n\t##\n\n\tserver_tokens off;\n\treset_timedout_connection on;\n\tadd_header X-Powered-By "EasyEngine";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n/" /etc/nginx/nginx.conf - # Disable Nginx Version Set Custom Headers Variables And Proxy Settings - sed -i "s/http {/http {\n\t##\n\t# Easy Engine Settings\n\t##\n\n\tserver_tokens off;\n\tadd_header X-Powered-By "EasyEngine";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n/" /etc/nginx/nginx.conf + # Change Keepalive Timeout Settings + sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf # Set Custom Logs sed -i "s/error_log.*/error_log \/var\/log\/nginx\/error.log;\n\n\tlog_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '\n\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '\n\t\t'\"\$http_referer\" \"\$http_user_agent\"';/" /etc/nginx/nginx.conf + + # Enable Gzip + sed -i "s/# gzip/gzip/" /etc/nginx/nginx.conf fi # Check Directory Exist From d75f05a9e822e5f9ddc54ae8ae02873d9a9ffdc0 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 5 Mar 2014 16:13:17 +0530 Subject: [PATCH 06/50] EasyEngine Admin Tools Locations Changed & Setup adminer DB Management Tool --- etc/nginx/common/locations.conf | 31 +++--------- usr/local/sbin/easyengine | 89 ++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 59 deletions(-) diff --git a/etc/nginx/common/locations.conf b/etc/nginx/common/locations.conf index 499646f6..aab12715 100644 --- a/etc/nginx/common/locations.conf +++ b/etc/nginx/common/locations.conf @@ -21,40 +21,25 @@ location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gi } -# EasyEngine Shared Settings -#location /ee/ { -# autoindex on; -# alias /var/www/shared/; -# include common/acl.conf; -# index index.php index.html index.htm; - -# location ~ ^/ee(.+\.php)$ { -# alias /var/www/shared$1; -# fastcgi_pass php; -# include /etc/nginx/fastcgi_params; -# } - -# location ~* ^/ee(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { -# alias /var/www/shared$1; -# } -#} +# EasyEngine Admin Tools # PMA Settings location /pma { - #rewrite ^/* /ee/pma last; - return 301 $scheme://$host:22222/pma; + return 301 $scheme://$host:22222/db/pma; } location /phpMyAdmin { - #rewrite ^/* /ee/pma last; - return 301 $scheme://$host:22222/pma; + return 301 $scheme://$host:22222/db/pma; } location /phpmyadmin { - #rewrite ^/* /ee/pma last; - return 301 $scheme://$host:22222/pma; + return 301 $scheme://$host:22222/db/pma; } +# Adminer Settings +location /adminer { + return 301 $scheme://$host:22222/db/adminer/; +} # Status Pages location /nginx_status { diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 93849351..de2c9f5b 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -339,25 +339,42 @@ WP-CLI() INSTALLPMA() { # Install PMA/phpMyAdmin - if [ ! -d /var/www/eeadmin/htdocs/pma ] + if [ ! -d /var/www/eeadmin/htdocs/db ] then - echo -e "\033[34mInstalling phpMyAdmin, Please Wait...\e[0m" + if [ ! -d /var/www/eeadmin/htdocs/db/pma ] + then + echo -e "\033[34mDownloading phpMyAdmin, Please Wait...\e[0m" - # Setup PMA/phpMyAdmin - mkdir -p /var/www/eeadmin/htdocs/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/eeadmin/htdocs/pma/" + # Setup PMA/phpMyAdmin + mkdir -p /var/www/eeadmin/htdocs/db/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/eeadmin/htdocs/db/pma/" - # Download PMA/phpMyAdmin - wget -cqO /var/www/eeadmin/htdocs/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ - || OwnError "Unable To Download phpMyAdmin" + # Download PMA/phpMyAdmin + wget -cqO /var/www/eeadmin/htdocs/db/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ + || OwnError "Unable To Download phpMyAdmin" - # Extract PMA/phpMyAdmin - tar --strip-components=1 -zxf /var/www/eeadmin/htdocs/pma/pma.tar.gz -C /var/www/eeadmin/htdocs/pma/ \ - || OwnError "Unable To Extract phpMyAdmin" + # Extract PMA/phpMyAdmin + tar --strip-components=1 -zxf /var/www/eeadmin/htdocs/db/pma/pma.tar.gz -C /var/www/eeadmin/htdocs/db/pma/ \ + || OwnError "Unable To Extract phpMyAdmin" + + # Remove Unwanted Files + rm -f /var/www/eeadmin/htdocs/db/pma/pma.tar.gz + + fi + + if [ ! -d /var/www/eeadmin/htdocs/db/adminer ] + then + echo -e "\033[34mDownloading Adminer, Please Wait...\e[0m" + # Setup Adminer + mkdir -p /var/www/eeadmin/htdocs/db/adminer/ || OwnError "Unable To Create Adminer Directory: /var/www/eeadmin/htdocs/db/adminer/" + + # Download Adminer + wget -cqO /var/www/eeadmin/htdocs/db/adminer/index.php http://downloads.sourceforge.net/adminer/adminer-4.0.3.php \ + || OwnError "Unable To Download Adminer" + + fi - # Remove Unwanted Files - rm -f /var/www/eeadmin/htdocs/pma/pma.tar.gz else - echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/eeadmin/htdocs/pma)...\e[0m" + echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/eeadmin/htdocs/db/pma)...\e[0m" fi } @@ -450,7 +467,7 @@ REMOVEPMA() { # Remove PMA/phpMyAdmin echo -e "\033[34mRemoving phpMyAdmin, Please Wait...\e[0m" - rm -rf /var/www/eeadmin/htdocs/pma || OwnError "Unable To Remove phpMyAdmin" + rm -rf /var/www/eeadmin/htdocs/db/pma || OwnError "Unable To Remove phpMyAdmin" } REMOVEMYSQL() @@ -1078,29 +1095,29 @@ PERMISSIONANDGIT() EEOPMEMCACHE() { # Opcache Settings - if [ ! -d /var/www/eeadmin/htdocs/opcache ] + if [ ! -d /var/www/eeadmin/htdocs/php/opcache ] then - mkdir -p /var/www/eeadmin/htdocs/opcache || OwnError "Unable To Create Opcache Directory" + mkdir -p /var/www/eeadmin/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" # Download Opcache Status Files - wget -cqO /var/www/eeadmin/htdocs/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php - wget -cqO /var/www/eeadmin/htdocs/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php - wget -cqO /var/www/eeadmin/htdocs/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php + wget -cqO /var/www/eeadmin/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php + wget -cqO /var/www/eeadmin/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php + wget -cqO /var/www/eeadmin/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php fi # Memcache Settings - if [ ! -d /var/www/eeadmin/htdocs/memcache ] + if [ ! -d /var/www/eeadmin/htdocs/php/memcache ] then - mkdir -p /var/www/eeadmin/htdocs/memcache || OwnError "Unable To Create Memcache Directory" + mkdir -p /var/www/eeadmin/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" # Download phpMemcachedAdmin - wget -cqO /var/www/eeadmin/htdocs/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz + wget -cqO /var/www/eeadmin/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz # Extract phpMemcachedAdmin - tar -zxf /var/www/eeadmin/htdocs/memcache/memcache.tar.gz -C /var/www/eeadmin/htdocs/memcache + tar -zxf /var/www/eeadmin/htdocs/php/memcache/memcache.tar.gz -C /var/www/eeadmin/htdocs/php/memcache # Remove Unwanted Files - rm -f /var/www/eeadmin/htdocs/memcache/memcache.tar.gz + rm -f /var/www/eeadmin/htdocs/php/memcache/memcache.tar.gz fi } @@ -1349,8 +1366,8 @@ then INSTALLPMA # Initialise Git - EEGITDIR=/var/www/eeadmin/htdocs/pma/ - EEGITINIT + #EEGITDIR=/var/www/eeadmin/htdocs/db/pma/ + #EEGITINIT # Display Success Message echo -e "\033[34mphpMyAdmin Successfully Installed\e[0m" @@ -1439,8 +1456,8 @@ then EEGITINIT # Initialize Git - EEGITDIR=/var/www/eeadmin/htdocs/pma/ - EEGITINIT + #EEGITDIR=/var/www/eeadmin/htdocs/db/pma/ + #EEGITINIT # Initialize Git EEGITDIR=/etc/postfix/ @@ -1887,7 +1904,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display Success Message echo @@ -1911,7 +1928,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -1942,7 +1959,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -1973,7 +1990,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2009,7 +2026,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display Success Message echo @@ -2033,7 +2050,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2064,7 +2081,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2095,7 +2112,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo From 25d9ce16e59b513dda20cd5ffa202890597c1151 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 5 Mar 2014 17:54:47 +0530 Subject: [PATCH 07/50] Add redirection for the adminer memcache and opcache --- etc/nginx/common/locations.conf | 63 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/etc/nginx/common/locations.conf b/etc/nginx/common/locations.conf index aab12715..e91dc9da 100644 --- a/etc/nginx/common/locations.conf +++ b/etc/nginx/common/locations.conf @@ -21,25 +21,27 @@ location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gi } -# EasyEngine Admin Tools +# Security Settings For Better Privacy -# PMA Settings -location /pma { - return 301 $scheme://$host:22222/db/pma; +# Deny Hidden Files +location ~ /\. { + deny all; + access_log off; + log_not_found off; } -location /phpMyAdmin { - return 301 $scheme://$host:22222/db/pma; +# Deny Backup Extensions & Log Files +location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp)$ { + deny all; + access_log off; + log_not_found off; } -location /phpmyadmin { - return 301 $scheme://$host:22222/db/pma; +# Return 403 Forbidden For readme.(txt|html) or license.(txt|html) +if ($request_uri ~* "^.+(readme|license)\.(txt|html)$") { + return 403; } -# Adminer Settings -location /adminer { - return 301 $scheme://$host:22222/db/adminer/; -} # Status Pages location /nginx_status { @@ -55,23 +57,32 @@ location ~ ^/(status|ping) { } -# Security Settings For Better Privacy +# EasyEngine Admin Tools -# Deny Hidden Files -location ~ /\. { - deny all; - access_log off; - log_not_found off; +# PMA Settings +location /pma { + return 301 $scheme://$host:22222/db/pma; } -# Deny Backup Extensions & Log Files -location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp)$ { - deny all; - access_log off; - log_not_found off; +location /phpMyAdmin { + return 301 $scheme://$host:22222/db/pma; } -# Return 403 Forbidden For readme.(txt|html) or license.(txt|html) -if ($request_uri ~* "^.+(readme|license)\.(txt|html)$") { - return 403; +location /phpmyadmin { + return 301 $scheme://$host:22222/db/pma; +} + +# Adminer Settings +location /adminer { + return 301 $scheme://$host:22222/db/adminer/; +} + +# Memcache Settings +location /memcache { + return 301 $scheme://$host:22222/php/memcache/; +} + +# Opcache Settings +location /opcache { + return 301 $scheme://$host:22222/php/opcache/; } From 6fbb3e94c33234d1bab6d0db1655c7856133585d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 6 Mar 2014 18:07:35 +0530 Subject: [PATCH 08/50] ee system status|start|stop|reload|restart commands added, Fixed Issue: 131 --- etc/bash_completion.d/ee | 2 +- usr/local/sbin/easyengine | 164 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 159 insertions(+), 7 deletions(-) diff --git a/etc/bash_completion.d/ee b/etc/bash_completion.d/ee index 36120b28..811da6a9 100644 --- a/etc/bash_completion.d/ee +++ b/etc/bash_completion.d/ee @@ -23,7 +23,7 @@ EEAUTO() ;; system) - COMPREPLY=( $( compgen -W "install remove purge" -- $CURRENT ) ) + COMPREPLY=( $( compgen -W "install remove purge status start stop reload restart" -- $CURRENT ) ) return 0 ;; diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index de2c9f5b..45f6d137 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -545,6 +545,46 @@ PURGEALL() || OwnError "Unable To Purge Nginx PHP5 MySQL Postfix" } +# EasyEngine Status Function +EE_SYSTEM_STATUS() +{ + OPERATING_SYSTEM=$(lsb_release -d | awk '{print $2,$3,$4}') + SYSTEM_LOAD=$(cat /proc/loadavg | awk '{print $1}') + PROCESSES=$(ps ax | wc -l) + MEMORY_TOTAL=$(free | grep Mem: | awk '{print $2}') + MEMORY_USED=$(free | grep Mem: | awk '{print $3}') + MEMORY_BUFFERS=$(free | grep Mem: | awk '{print $6}') + MEMORY_CACHE=$(free | grep Mem: | awk '{print $7}') + SWAP_TOTAL=$(free | grep Swap: | awk '{print $2}') + SWAP_USED=$(free | grep Swap: | awk '{print $3}') + MEMORY_USAGE=$(echo "($MEMORY_USED-$MEMORY_BUFFERS-$MEMORY_CACHE)*100/$MEMORY_TOTAL" | bc -l | cut -d'.' -f1) + SWAP_USAGE=$(echo "$SWAP_USED*100/$SWAP_TOTAL" | bc -l | cut -d'.' -f1) + LOGGED_IN_USERS=$(w -h | wc -l) + ROOT_PARTITION_USAGE=$(df -h | grep /$ | awk '{print $5}') + + NGINX_STATUS=$(service nginx status | grep 'nginx is running' &>> $INSTALLLOG && echo -e "\033[34mRunning\e[0m" || echo -e "\033[31mStopped\e[0m") + PHP_STATUS=$(service php5-fpm status | grep running &>> $INSTALLLOG && echo -e "\033[34mRunning\e[0m" || echo -e "\033[31mStopped\e[0m") + MYSQL_STATUS=$(service mysql status | grep running &>> $INSTALLLOG && echo -e "\033[34mRunning\e[0m" || echo -e "\033[31mStopped\e[0m") + POSTFIX_STATUS=$(service postfix status | grep 'postfix is running' &>> $INSTALLLOG && echo -e "\033[34mRunning\e[0m" || echo -e "\033[31mStopped\e[0m") + + echo + echo + echo -e "\033[37m System information as of $(/bin/date)\e[0m" + echo + echo -e " System load:\t$SYSTEM_LOAD\t\t Processes:\t\t$PROCESSES" + echo -e " Usage of /:\t$ROOT_PARTITION_USAGE\t\t Users logged in:\t$LOGGED_IN_USERS" + echo -e " Memory usage:\t$MEMORY_USAGE%\t\t Swap usage:\t\t$SWAP_USAGE%" + echo + echo -e "\033[37m Service status information\e[0m" + echo + echo -e " Nginx:\t$NGINX_STATUS" + echo -e " PHP5-FPM:\t$PHP_STATUS" + echo -e " MySQL:\t$MYSQL_STATUS" + echo -e " Postfix:\t$POSTFIX_STATUS" + echo + echo +} + # EE GIT Function EEGITINIT() @@ -881,13 +921,23 @@ NGINXBUCKETSIZE() fi } +NGINXSTART () +{ + # Check Nginx server_names_hash_bucket_size Value + NGINXBUCKETSIZE + + # Start Nginx Service + echo -e "\033[34mStarting Nginx Service, Please Wait...\e[0m" + (nginx -t && service nginx start) &>> $INSTALLLOG || OwnError "Unable To Start Nginx" +} + NGINXRELOAD() { # Check Nginx server_names_hash_bucket_size Value NGINXBUCKETSIZE - # Reload Nginx Configuration - echo -e "\033[34mReloading Nginx Configuration, Please Wait...\e[0m" + # Reload Nginx Service + echo -e "\033[34mReloading Nginx Service, Please Wait...\e[0m" (nginx -t && service nginx reload) &>> $INSTALLLOG || OwnError "Unable To Reload Nginx" } @@ -896,18 +946,74 @@ NGINXRESTART() # Check Nginx server_names_hash_bucket_size Value NGINXBUCKETSIZE - # Test & Reload Nginx - echo -e "\033[34mRestarting Nginx Configuration, Please Wait...\e[0m" + # Test & Restart Nginx Service + echo -e "\033[34mRestarting Nginx Service, Please Wait...\e[0m" (nginx -t && service nginx restart) &>> $INSTALLLOG || OwnError "Unable To Restart Nginx" } +PHPSTART() +{ + # Start PHP5-FPM Service + echo -e "\033[34mStarting PHP5-FPM Service, Please Wait...\e[0m" + service php5-fpm start &>> $INSTALLLOG || OwnError "Unable To Start PHP5-FPM" +} + +PHPRELOAD() +{ + # Reload PHP5-FPM Service + echo -e "\033[34mReloading PHP5-FPM Service, Please Wait...\e[0m" + service php5-fpm reload &>> $INSTALLLOG || OwnError "Unable To Reloading PHP5-FPM" +} + PHPRESTART() { - # Reload PHP - echo -e "\033[34mRestarting PHP5-FPM Configuration, Please Wait...\e[0m" + # Restart PHP5-FPM Service + echo -e "\033[34mRestarting PHP5-FPM Service, Please Wait...\e[0m" service php5-fpm restart &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM" } +MYSQLSTART() +{ + # Start MySQL Service + echo -e "\033[34mStarting MySQL Service, Please Wait...\e[0m" + service mysql start &>> $INSTALLLOG || OwnError "Unable To Start MySQL" +} + +MYSQLRELOAD() +{ + # Reload MySQL Service + echo -e "\033[34mReloading MySQL Service, Please Wait...\e[0m" + service mysql reload &>> $INSTALLLOG || OwnError "Unable To Reloading MySQL" +} + +MYSQLRESTART() +{ + # Restart MySQL Service + echo -e "\033[34mRestarting MySQL Service, Please Wait...\e[0m" + service mysql restart &>> $INSTALLLOG || OwnError "Unable To Restart MySQL" +} + +POSTFIXSTART() +{ + # Start Postfix Service + echo -e "\033[34mStarting Postfix Service, Please Wait...\e[0m" + service postfix start &>> $INSTALLLOG || OwnError "Unable To Start Postfix" +} + +POSTFIXRELOAD() +{ + # Reload Postfix Service + echo -e "\033[34mReloading Postfix Service, Please Wait...\e[0m" + service postfix reload &>> $INSTALLLOG || OwnError "Unable To Reloading Postfix" +} + +POSTFIXRESTART() +{ + # Restart Postfix Service + echo -e "\033[34mRestarting Postfix Service, Please Wait...\e[0m" + service postfix restart &>> $INSTALLLOG || OwnError "Unable To Restart Postfix" +} + # EE Domian Functions @@ -1626,8 +1732,54 @@ then fi + elif [ "$2" = "status" ] + then + # Call The System Status Function + EE_SYSTEM_STATUS + + elif [ "$2" = "stop" ] + then + # Stop Nginx PHP5-FPM MySQL & Postfix + echo -e "\033[34mStopping Nginx Service, Please Wait...\e[0m" + service nginx stop &>> $INSTALLLOG || OwnError "Unable To Stop Nginx" + echo -e "\033[34mStopping PHP5-FPM Service, Please Wait...\e[0m" + service php5-fpm stop &>> $INSTALLLOG || OwnError "Unable To Stop PHP5-FPM" + echo -e "\033[34mStopping MySQL Service, Please Wait...\e[0m" + service mysql stop &>> $INSTALLLOG || OwnError "Unable To Stop MySQL" + echo -e "\033[34mStopping Postfix Service, Please Wait...\e[0m" + service postfix stop &>> $INSTALLLOG || OwnError "Unable To Stop Postfix" + + elif [ "$2" = "start" ] + then + # Start Nginx PHP5-FPM MySQL & Postfix + NGINXSTART + PHPSTART + MYSQLSTART + POSTFIXSTART + + elif [ "$2" = "reload" ] + then + # Restart Nginx PHP5-FPM MySQL & Postfix + NGINXRELOAD + PHPRELOAD + MYSQLRELOAD + POSTFIXRELOAD + + elif [ "$2" = "restart" ] + then + # Restart Nginx PHP5-FPM MySQL & Postfix + NGINXRESTART + PHPRESTART + MYSQLRESTART + POSTFIXRESTART + else echo -e "\033[34mList Of Available Commands:\e[0m" + echo -e "\tstatus:\t Display The System Status Information" + echo -e "\tstop:\t Stop Nginx PHP5-FPM MySQL And Postfix Services" + echo -e "\tstart:\t Start Nginx PHP5-FPM MySQL And Postfix Services" + echo -e "\treload:\t Reload Nginx PHP5-FPM MySQL And Postfix Services" + echo -e "\trestart:\t Restart Nginx PHP5-FPM MySQL And Postfix Services" echo -e "\tpurge:\t Purge Nginx PHP5-FPM phpMyAdmin MySQL And Postfix" echo -e "\tremove:\t Remove Nginx PHP5-FPM phpMyAdmin MySQL And Postfix" echo -e "\tinstall: Install Nginx PHP5-FPM phpMyAdmin MySQL And Postfix" From 4d35287981eb30dc1c468678eb97cf623956258e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 6 Mar 2014 19:39:27 +0530 Subject: [PATCH 09/50] Minor Update on ee system command --- usr/local/sbin/easyengine | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 45f6d137..e539fc65 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1779,10 +1779,10 @@ then echo -e "\tstop:\t Stop Nginx PHP5-FPM MySQL And Postfix Services" echo -e "\tstart:\t Start Nginx PHP5-FPM MySQL And Postfix Services" echo -e "\treload:\t Reload Nginx PHP5-FPM MySQL And Postfix Services" - echo -e "\trestart:\t Restart Nginx PHP5-FPM MySQL And Postfix Services" - echo -e "\tpurge:\t Purge Nginx PHP5-FPM phpMyAdmin MySQL And Postfix" - echo -e "\tremove:\t Remove Nginx PHP5-FPM phpMyAdmin MySQL And Postfix" - echo -e "\tinstall: Install Nginx PHP5-FPM phpMyAdmin MySQL And Postfix" + echo -e "\trestart: Restart Nginx PHP5-FPM MySQL And Postfix Services" + echo -e "\tpurge:\t Purge Nginx PHP5-FPM phpMyAdmin MySQL And Postfix Packages" + echo -e "\tremove:\t Remove Nginx PHP5-FPM phpMyAdmin MySQL And Postfix Packages" + echo -e "\tinstall: Install Nginx PHP5-FPM phpMyAdmin MySQL And Postfix Packages" fi From dda9560714f2da445e593baf65b42c13aca74918 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Sat, 8 Mar 2014 12:18:47 +0530 Subject: [PATCH 10/50] Auto Switch the site create options --- usr/local/sbin/easyengine | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index e539fc65..0b32019f 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1870,10 +1870,17 @@ then EESITECREATE=--html fi + # Auto Switch The Options if [ "$EESITECREATE" = "--basic" ] || [ "$EESITECREATE" = "--w3tc" ] || [ "$EESITECREATE" = "--wpsc" ] || [ "$EESITECREATE" = "--wpfc" ] then - EESITECREATE=--wp - WPCACHEOPTION=$4 + if [ "$WPCACHEOPTION" = "--wpsubdir" ] || [ "$WPCACHEOPTION" = "--wpsubdirectory" ] || [ "$WPCACHEOPTION" = "--wpsubdom" ] || [ "$WPCACHEOPTION" = "--wpsubdomain" ] + then + EESITECREATE=$5 + WPCACHEOPTION=$4 + else + EESITECREATE=--wp + WPCACHEOPTION=$4 + fi fi # If No Cache Specified Use --basic As Default From 7d61900ac8b35f41dfdf5d53de3874c62b116d77 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Sat, 8 Mar 2014 13:02:45 +0530 Subject: [PATCH 11/50] Fix Issue #113 Automatically Change MYSQL User If More Than 16 Character Provided --- usr/local/sbin/easyengine | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 0b32019f..63cf56f7 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -732,17 +732,19 @@ FIXMYSQLUSER16() if [[ $MYSQLUSER16 -gt 16 ]] then echo MySQL Database Username $WPDBUSER = $MYSQLUSER16 &>> $INSTALLLOG - REPLACEDOT16=$(echo $REPLACEDOT | cut -c1-16) + echo -e "\033[34mAuto Fix MySQL Username To The 16 Characters\e[0m" + RANDOM_CHARACTER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n1) + WPDBUSER=$(echo $REPLACEDOT | cut -c1-16 | sed "s/.\{10\}$/$RANDOM_CHARACTER/") - echo -e "\033[31mERROR 1470 (HY000): $WPDBUSER Is Too Long For MySQL Username\e[0m" + #echo -e "\033[31mERROR 1470 (HY000): $WPDBUSER Is Too Long For MySQL Username\e[0m" # Turn Off Echo For Passwords - stty echo - read -p "Enter The MySQL Database Username [$REPLACEDOT16]: " WPDBUSER + #stty echo + #read -p "Enter The MySQL Database Username [$REPLACEDOT16]: " WPDBUSER - if [[ $WPDBUSER = "" ]] - then - WPDBUSER=$REPLACEDOT16 - fi + #if [[ $WPDBUSER = "" ]] + #then + # WPDBUSER=$REPLACEDOT16 + #fi fi From d0b9941ff298086be6f2254ef8e906119b46cf8c Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Sat, 8 Mar 2014 14:57:40 +0530 Subject: [PATCH 12/50] After auto switch the easyengine NETWORKACTIVATE and WPSUBDOMAINS are not set properly fixed this by handling auto switch opton at the top --- usr/local/sbin/easyengine | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 63cf56f7..7a351328 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1852,6 +1852,19 @@ then EESITECREATE=$4 WPCACHEOPTION=$5 + # Auto Switch The Options + if [ "$EESITECREATE" = "--basic" ] || [ "$EESITECREATE" = "--w3tc" ] || [ "$EESITECREATE" = "--wpsc" ] || [ "$EESITECREATE" = "--wpfc" ] + then + if [ "$WPCACHEOPTION" = "--wpsubdir" ] || [ "$WPCACHEOPTION" = "--wpsubdirectory" ] || [ "$WPCACHEOPTION" = "--wpsubdom" ] || [ "$WPCACHEOPTION" = "--wpsubdomain" ] + then + EESITECREATE=$5 + WPCACHEOPTION=$4 + else + EESITECREATE=--wp + WPCACHEOPTION=$4 + fi + fi + # WordPress SubDirectory Variables if [ "$EESITECREATE" = "--wpsubdir" ] || [ "$EESITECREATE" = "--wpsubdirectory" ] then @@ -1872,18 +1885,6 @@ then EESITECREATE=--html fi - # Auto Switch The Options - if [ "$EESITECREATE" = "--basic" ] || [ "$EESITECREATE" = "--w3tc" ] || [ "$EESITECREATE" = "--wpsc" ] || [ "$EESITECREATE" = "--wpfc" ] - then - if [ "$WPCACHEOPTION" = "--wpsubdir" ] || [ "$WPCACHEOPTION" = "--wpsubdirectory" ] || [ "$WPCACHEOPTION" = "--wpsubdom" ] || [ "$WPCACHEOPTION" = "--wpsubdomain" ] - then - EESITECREATE=$5 - WPCACHEOPTION=$4 - else - EESITECREATE=--wp - WPCACHEOPTION=$4 - fi - fi # If No Cache Specified Use --basic As Default if [ "$WPCACHEOPTION" = "" ] && [ "$EESITECREATE" != "--html" ] && [ "$EESITECREATE" != "--php" ] From fa1e86c8665715e3c404800820691a469f958c03 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Sat, 8 Mar 2014 15:39:57 +0530 Subject: [PATCH 13/50] Optimise system comamnd dont check/run installation stuff on ee system status/start/stop/restart command --- usr/local/sbin/easyengine | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 7a351328..973e5047 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -138,7 +138,16 @@ UPDATEAPT() INSTALLNGINX() { - # Install Nginx + # Define Nginx Package & Install IT + if [ "$LINUX_DISTRO" == "Ubuntu" ] + then + NGINXPACKAGE=nginx-custom + + elif [ "$LINUX_DISTRO" == "Debian" ] + then + NGINXPACKAGE=nginx-full + fi + echo -e "\033[34mInstalling Nginx, Please Wait...\e[0m" $EEAPTGET install $NGINXPACKAGE || OwnError "Unable To Install Nginx" } @@ -1384,24 +1393,13 @@ then elif [ "$1" = "system" ] then - # Check Auto Assume Yes Or No To Apt-Get - APTASSUMEYES - - # Define Nginx Package - if [ "$LINUX_DISTRO" == "Ubuntu" ] - then - NGINXPACKAGE=nginx-custom - - elif [ "$LINUX_DISTRO" == "Debian" ] - then - NGINXPACKAGE=nginx-full - fi - - # Easy Engine Install if [ "$2" = "install" ] then + # Check Auto Assume Yes Or No To Apt-Get + APTASSUMEYES + if [ "$3" = "nginx" ] then @@ -1581,6 +1579,9 @@ then # Easy Engine Remove elif [ "$2" = "remove" ] then + + # Check Auto Assume Yes Or No To Apt-Get + APTASSUMEYES if [ "$3" = "nginx" ] then @@ -1659,6 +1660,9 @@ then # Easy Engine Purge elif [ "$2" = "purge" ] then + + # Check Auto Assume Yes Or No To Apt-Get + APTASSUMEYES if [ "$3" = "nginx" ] then From 6c5941534c33ff0a3aabf8f3bc58eed6ef625952 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Sat, 8 Mar 2014 16:05:17 +0530 Subject: [PATCH 14/50] Fix Previous commit nginx installation issue --- usr/local/sbin/easyengine | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 973e5047..c45cf971 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -136,9 +136,9 @@ UPDATEAPT() apt-get update &>> $INSTALLLOG || OwnError "Unable To Update APT Cache" } -INSTALLNGINX() +NGINXINSTALLTWEAKS () { - # Define Nginx Package & Install IT + # Define Nginx Package if [ "$LINUX_DISTRO" == "Ubuntu" ] then NGINXPACKAGE=nginx-custom @@ -147,7 +147,14 @@ INSTALLNGINX() then NGINXPACKAGE=nginx-full fi +} + +INSTALLNGINX() +{ + # Select Nginx Package + NGINXINSTALLTWEAKS + # Install Nginx Package echo -e "\033[34mInstalling Nginx, Please Wait...\e[0m" $EEAPTGET install $NGINXPACKAGE || OwnError "Unable To Install Nginx" } @@ -435,7 +442,8 @@ INSTALLPOSTFIX() INSTALLALL() { - # Setting Up MySQL & Postfix + # Setting Up Nginx MySQL & Postfix + NGINXINSTALLTWEAKS MYSQLINSTALLTWEAKS POSTFIXINSTALLTWEAKS From 496cd64bd496d1392b75f658f1373ae346a6013b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Sat, 8 Mar 2014 16:08:53 +0530 Subject: [PATCH 15/50] Fix Previous commit nginx remove/purge issue --- usr/local/sbin/easyengine | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index c45cf971..921b98cc 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -459,6 +459,9 @@ INSTALLALL() # Remove Package Functions REMOVENGINX() { + # Select Nginx Package + NGINXINSTALLTWEAKS + # Remove Nginx echo -e "\033[34mRemoving Nginx, Please Wait...\e[0m" $EEAPTGET remove $NGINXPACKAGE nginx-common || OwnError "Unable To Remove Nginx" @@ -504,6 +507,9 @@ REMOVEPOSTFIX() REMOVEALL() { + # Select Nginx Package + NGINXINSTALLTWEAKS + # Remove Nginx PHP5 MySQL Postfix echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET remove $NGINXPACKAGE nginx-common php5-common php5-mysqlnd php5-xmlrpc \ @@ -523,6 +529,9 @@ AUTOREMOVE() # Purge Package Functions PURGENGINX() { + # Select Nginx Package + NGINXINSTALLTWEAKS + # Purge Nginx echo -e "\033[34mPurge Nginx, Please Wait...\e[0m" $EEAPTGET purge $NGINXPACKAGE nginx-common || OwnError "Unable To Purge Nginx" From aa2aab5991355267f37e6c7a75c853eda89aee72 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 10 Mar 2014 15:11:07 +0530 Subject: [PATCH 16/50] Self Signed SSL Certificate For The Issue #124 --- etc/nginx/common/locations.conf | 12 ++++++------ etc/nginx/conf.d/eeadmin.conf | 7 +++++-- usr/local/sbin/easyengine | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/etc/nginx/common/locations.conf b/etc/nginx/common/locations.conf index e91dc9da..f03551b6 100644 --- a/etc/nginx/common/locations.conf +++ b/etc/nginx/common/locations.conf @@ -61,28 +61,28 @@ location ~ ^/(status|ping) { # PMA Settings location /pma { - return 301 $scheme://$host:22222/db/pma; + return 301 https://$host:22222/db/pma; } location /phpMyAdmin { - return 301 $scheme://$host:22222/db/pma; + return 301 https://$host:22222/db/pma; } location /phpmyadmin { - return 301 $scheme://$host:22222/db/pma; + return 301 https://$host:22222/db/pma; } # Adminer Settings location /adminer { - return 301 $scheme://$host:22222/db/adminer/; + return 301 https://$host:22222/db/adminer/; } # Memcache Settings location /memcache { - return 301 $scheme://$host:22222/php/memcache/; + return 301 https://$host:22222/php/memcache/; } # Opcache Settings location /opcache { - return 301 $scheme://$host:22222/php/opcache/; + return 301 https://$host:22222/php/opcache/; } diff --git a/etc/nginx/conf.d/eeadmin.conf b/etc/nginx/conf.d/eeadmin.conf index ca219e53..2e1a4399 100644 --- a/etc/nginx/conf.d/eeadmin.conf +++ b/etc/nginx/conf.d/eeadmin.conf @@ -1,12 +1,15 @@ -# WPSINGLE BASIC NGINX CONFIGURATION +# EasyEngine Admin Configuration server { - listen 22222; + listen 22222 ssl; server_name _; access_log /var/log/nginx/eeadmin.access.log rt_cache; error_log /var/log/nginx/eeadmin.error.log; + ssl_certificate /etc/nginx/ssl/eeadmin.crt; + ssl_certificate_key /etc/nginx/ssl/eeadmin.key; + root /var/www/eeadmin/htdocs; index index.php index.htm index.html; diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 921b98cc..02773a73 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -273,6 +273,30 @@ COMMONNGINX() EEDEST="/etc/nginx/common" EEMD5SUM + # EEAdmin SSL Setup + if [ ! -d /etc/nginx/ssl ] + then + mkdir /etc/nginx/ssl || OwnError "Unable To Create /etc/nginx/ssl" + fi + + # Generate SSL Key + echo -e "\033[34mGenerating SSL Private Key, Please Wait...\e[0m" + openssl genrsa -out /etc/nginx/ssl/eeadmin.key 2048 &>> $INSTALLLOG \ + || OwnError "Unable To Generate SSL Private Key" + + echo -e "\033[34mGenerating a Certificate Signing Request (CSR), Please Wait...\e[0m" + openssl req -new -batch -subj /C=IN/ST=Maharashtra/O="rtCamp Solutions Pvt. Ltd."/localityName=Pune/commonName=127.0.0.1/organizationalUnitName=EasyEngine/emailAddress=$(git config user.email)/ -key /etc/nginx/ssl/eeadmin.key -out /etc/nginx/ssl/eeadmin.csr &>> $INSTALLLOG \ + || OwnError "Unable To Generate Certificate Signing Request (CSR)" + + echo -e "\033[34mRemoving Passphrase From SSL Private Key, Please Wait...\e[0m" + mv /etc/nginx/ssl/eeadmin.key /etc/nginx/ssl/eeadmin.key.org + openssl rsa -in /etc/nginx/ssl/eeadmin.key.org -out /etc/nginx/ssl/eeadmin.key &>> $INSTALLLOG \ + || OwnError "Unable To Remove Passphrase From SSL Private Key" + + echo -e "\033[34mGenerating SSL Certificate, Please Wait...\e[0m" + openssl x509 -req -days 3652 -in /etc/nginx/ssl/eeadmin.csr -signkey /etc/nginx/ssl/eeadmin.key -out /etc/nginx/ssl/eeadmin.crt &>> $INSTALLLOG \ + || OwnError "Unable To Generate SSL Certificate" + # White List IP Address echo -e "\033[34mEasyEngine (ee) Allow To Access Protected Files By Using Whitelisted IP Address Or HTTP Authentication\e[0m" stty echo From 9749d9aa47971553c0e81db992478cfafa86a6ba Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 10 Mar 2014 15:44:46 +0530 Subject: [PATCH 17/50] Remove Optional Things From CSR #124 --- usr/local/sbin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 02773a73..d79e525d 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -285,7 +285,7 @@ COMMONNGINX() || OwnError "Unable To Generate SSL Private Key" echo -e "\033[34mGenerating a Certificate Signing Request (CSR), Please Wait...\e[0m" - openssl req -new -batch -subj /C=IN/ST=Maharashtra/O="rtCamp Solutions Pvt. Ltd."/localityName=Pune/commonName=127.0.0.1/organizationalUnitName=EasyEngine/emailAddress=$(git config user.email)/ -key /etc/nginx/ssl/eeadmin.key -out /etc/nginx/ssl/eeadmin.csr &>> $INSTALLLOG \ + openssl req -new -batch -subj /commonName=127.0.0.1/ -key /etc/nginx/ssl/eeadmin.key -out /etc/nginx/ssl/eeadmin.csr &>> $INSTALLLOG \ || OwnError "Unable To Generate Certificate Signing Request (CSR)" echo -e "\033[34mRemoving Passphrase From SSL Private Key, Please Wait...\e[0m" From a2633806ed437c91e172eeb8b79f1c6c371954bb Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 10 Mar 2014 16:40:07 +0530 Subject: [PATCH 18/50] Minor Update on ee info commnad --- usr/local/sbin/easyengine | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index d79e525d..977c5126 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -934,11 +934,12 @@ EEINFO() echo -e "\033[34mMySQL socket:\t\t\t \033[37m$MYSQLSOCKET\e[0m" # Common Locations: - echo -e "\033[34m\n\nEasyEngine (ee) Common Locations:\n\e[0m" + echo -e "\033[34m\n\nEasyEngine ($(ee version| awk '{print $3}')) Common Locations:\n\e[0m" echo -e "\033[34mphpMyAdmin:\t\t\t \033[37mhttp://example.com/pma\e[0m" echo -e "\033[34mPHP Status:\t\t\t \033[37mhttp://example.com/status\e[0m" echo -e "\033[34mNginx Status:\t\t\t \033[37mhttp://example.com/nginx_status\e[0m" - echo -e "\033[34mOpcache & Memcache Status:\t \033[37mhttp://example.com/ee/\e[0m" + echo -e "\033[34mMemcache Status:\t\t \033[37mhttp://example.com/memcache\e[0m" + echo -e "\033[34mMemcache Status:\t\t \033[37mhttp://example.com/opcache\e[0m" echo -e "\033[34mEasyEngine Log File:\t\t \033[37m/var/log/easyengine/install.log\e[0m" echo -e "\033[34mEasyEngine Configuration File:\t \033[37m/etc/easyengine/ee.conf\e[0m" From a34137e43df275f7ea7c1c9523321abe967d816d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 25 Mar 2014 12:46:07 +0530 Subject: [PATCH 19/50] Better way to moinitor git status and fixed issue #157 --- usr/local/sbin/easyengine | 23 ++++++++++++----------- usr/local/sbin/eeupdate | 3 +-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 9499a06f..9ded4f1c 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -651,8 +651,7 @@ EEGITINIT() fi # Check For Untracked Files - git status | grep clean &>> $INSTALLLOG - if [ $? -ne 0 ] + if [ $(git status -s | wc -l) -ne 0 ] then # Add Files In Git Version Control git add --all && git commit -am "Initialize Git On $EEGITDIR" &>> $INSTALLLOG \ @@ -663,9 +662,8 @@ EEGITINIT() EEGITCOMMIT() { cd $EEGITDIR || OwnError "Unable To Change Directory $EEGITDIR" - git status | grep clean &>> $INSTALLLOG - if [ $? -ne 0 ] + if [ $(git status -s | wc -l) -ne 0 ] then # Git Commit Functionality echo -e "\033[34mTake $EEGITDIR Configuration In Git Version Control...\e[0m" @@ -2438,13 +2436,16 @@ then # Edit The Nginx Configuration For $DOMAIN EESITEEDIT - # Reload Nginx Configuration - NGINXRELOAD - - # Take Nginx Configuration In Git Version Control - EEGITDIR=/etc/nginx - EEGITMESSAGE="Edited Website: $DOMAIN" - EEGITCOMMIT + if [ $(git status -s /etc/nginx/sites-available/$DOMAIN | wc -l) -ne 0 ] + then + # Take Nginx Configuration In Git Version Control + EEGITDIR=/etc/nginx + EEGITMESSAGE="Edited Website: $DOMAIN" + EEGITCOMMIT + + # Reload Nginx Configuration + NGINXRELOAD + fi else diff --git a/usr/local/sbin/eeupdate b/usr/local/sbin/eeupdate index 3efba9a3..6e171a3d 100644 --- a/usr/local/sbin/eeupdate +++ b/usr/local/sbin/eeupdate @@ -25,8 +25,7 @@ GITCOMMIT () fi # Check For Untracked Files - git status | grep clean &>> $INSTALLLOG - if [ $? -ne 0 ] + if [ $(git status -s | wc -l) -ne 0 ] then # Add Files In Git Version Control git add --all && git commit -am "$EEGITMESSAGE" &>> $INSTALLLOG \ From b98e4e6d36c9370a5aa0af7b9211d1e4f9c693f4 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 26 Mar 2014 16:43:20 +0530 Subject: [PATCH 20/50] Debug Function Ready --- etc/easyengine/ee.conf | 3 + usr/local/sbin/easyengine | 124 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 121 insertions(+), 6 deletions(-) diff --git a/etc/easyengine/ee.conf b/etc/easyengine/ee.conf index 97dda24e..a207e7b4 100644 --- a/etc/easyengine/ee.conf +++ b/etc/easyengine/ee.conf @@ -9,6 +9,9 @@ gpg-keys-fix = false htpasswduser = htpasswdpass = +# Comma Separated Whitelist/Debugging IP Address +ip_address = + # WordPress Defaults # MySQL Default Host: localhost mysqlhost = diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 9ded4f1c..64e7c25f 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -315,7 +315,7 @@ INSTALLPHP() # Install PHP5 echo -e "\033[34mInstalling PHP5, Please Wait...\e[0m" $EEAPTGET install php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached || OwnError "Unable To Install PHP5" } @@ -324,6 +324,12 @@ COMMONPHP() # Personal Settings For PHP echo -e "\033[34mUpdating PHP Configuration Files, Please Wait...\e[0m" + # Needed For Custome PHP5 Logs + if [ ! -d /var/log/php5/ ] + then + mkdir -p /var/log/php5/ || OwnError "Unable To Create PHP5 Log Directory: /var/log/php5/" + fi + grep "Easy Engine" /etc/php5/fpm/php.ini &> /dev/null if [ $? -ne 0 ] then @@ -338,6 +344,9 @@ COMMONPHP() sed -i "s/upload_max_filesize.*/upload_max_filesize = 100M/" /etc/php5/fpm/php.ini sed -i "s/max_execution_time.*/max_execution_time = 300/" /etc/php5/fpm/php.ini + # Change PHP5-FPM Error Logs Location + sed -i "s'error_log.*'error_log = /var/log/php5/fpm.log'" /etc/php5/fpm/php-fpm.conf + # Enable PHP Status & Ping sed -i "s/;ping.path/ping.path/" /etc/php5/fpm/pool.d/www.conf sed -i "s/;pm.status_path/pm.status_path/" /etc/php5/fpm/pool.d/www.conf @@ -474,7 +483,7 @@ INSTALLALL() # Install Nginx PHP5 MySQL Postfix echo -e "\033[34mInstalling Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET install $NGINXPACKAGE php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached mysql-server mysqltuner postfix \ || OwnError "Unable To Install Nginx PHP5 MySQL Postfix" } @@ -496,7 +505,7 @@ REMOVEPHP() # Remove PHP5 echo -e "\033[34mRemoving PHP5, Please Wait...\e[0m" $EEAPTGET remove php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached || OwnError "Unable To Remove PHP5" } @@ -537,7 +546,7 @@ REMOVEALL() # Remove Nginx PHP5 MySQL Postfix echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET remove $NGINXPACKAGE nginx-common php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached mysql-server mysqltuner postfix \ || OwnError "Unable To Remove Nginx PHP5 MySQL Postfix" } @@ -566,7 +575,7 @@ PURGEPHP() # Purge PHP5 echo -e "\033[34mPurge PHP5, Please Wait...\e[0m" $EEAPTGET purge php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached || OwnError "Unable To Purge PHP5" } @@ -590,7 +599,7 @@ PURGEALL() # Purge Nginx PHP5 MySQL Postfix echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET purge $NGINXPACKAGE nginx-common php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached mysql-server mysqltuner postfix \ || OwnError "Unable To Purge Nginx PHP5 MySQL Postfix" } @@ -1412,6 +1421,67 @@ REMOVENGINXCONF() fi } +DEBUG_NGINX() +{ + # Enable Debug Connection + for DEBUG_IP_ADDRESS in $( grep ip_address /etc/easyengine/ee.conf | cut -d'=' -f2 |sed 's/ //g' | tr ',' '\n' ) + do + sed -i "/multi_accept/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf + done +} + +DEBUG_NGINX_REWRITE() +{ + # Enable Nginx Rewrite Logs + sed -i '/http {/a \\trewrite_log on;\n\n' /etc/nginx/nginx.conf +} + +DEBUG_PHP() +{ + # Slowlog Settings + sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/www.conf + sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/www.conf + + # Xdebug Settings + echo -e "xdebug.profiler_output_dir=/tmp \nxdebug.profiler_output_name=cachegrind.out.%p-%H-%R \nxdebug.profiler_enable_trigger=1 \nxdebug.profiler_enable=0" >> /etc/php5/fpm/conf.d/20-xdebug.ini + + if [ ! -d /var/www/eeadmin/htdocs/php/webgrind/ ] + then + # Webgrind Install + mkdir -p mkdir -p /var/www/eeadmin/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory: /var/www/eeadmin/htdocs/php/webgrind/" + echo -e "\033[34mCloning webgrind, Please Wait...\e[0m" + git clone https://github.com/jokkedk/webgrind.git /var/www/eeadmin/htdocs/php/webgrind/ + sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/eeadmin/htdocs/php/webgrind/config.php + + # Install Graphviz + dpkg -l | grep graphviz &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "\033[34mInstalling Graphviz, Please Wait...\e[0m" + $EEAPTGET install graphviz || OwnError "Unable To Install Graphviz" + fi + fi +} + +DEBUG_PHP_FPM() +{ + # Enable PHP5-FPM Error Logs In Debug Mode + sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf +} + +DEBUG_MYSQL() +{ + # Enable MySQL Slow Logs + sed -i "/long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf + sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf + sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf +} + +DEBUG_WORDPRESS() +{ + # Debug WordPress + sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php +} # Easy Engine Version if [ "$1" = "version" ] || [ "$1" = "--version" ] || [ "$1" = "-v" ] @@ -2460,6 +2530,48 @@ then fi +elif [ "$1" = "debug" ] +then + + if [ "$2" = "--nginx" ] + then + + # Debug Nginx + DEBUG_NGINX + + elif [ "$2" = "--rewrite" ] + then + + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE + + elif [ "$2" = "--php" ] + then + + # Debug PHP + DEBUG_PHP + + elif [ "$2" = "--fpm" ] + then + + # Debug PHP FPM + DEBUG_PHP_FPM + + elif [ "$2" = "--mysql" ] + then + + # Debug MySQL Slow Query + DEBUG_MYSQL + + elif [ "$2" = "--wp" ] + then + + # Debug WordPress Debug Log + DEBUG_WORDPRESS + + fi + + elif [ "$1" = "update" ] then From 8a46fcfcc916a2147196d9076e77d689bc8efd61 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 26 Mar 2014 18:02:55 +0530 Subject: [PATCH 21/50] Auto Adjust Debug Options --- usr/local/sbin/easyengine | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 64e7c25f..b074ce5b 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1458,6 +1458,7 @@ DEBUG_PHP() if [ $? -ne 0 ] then echo -e "\033[34mInstalling Graphviz, Please Wait...\e[0m" + APTASSUMEYES $EEAPTGET install graphviz || OwnError "Unable To Install Graphviz" fi fi @@ -2533,37 +2534,60 @@ then elif [ "$1" = "debug" ] then - if [ "$2" = "--nginx" ] + # Auto Arrenge Options + for ARGS in $@ + do + [ "$ARGS" = "--nginx" ] && EE_DEBUG_NGINX=$ARGS && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG + [ "$ARGS" = "--rewrite" ] && EE_DEBUG_REWRITE=$ARGS && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG + [ "$ARGS" = "--php" ] && EE_DEBUG_PHP=$ARGS && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG + [ "$ARGS" = "--fpm" ] && EE_DEBUG_FPM=$ARGS && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG + [ "$ARGS" = "--mysql" ] && EE_DEBUG_MYSQL=$ARGS && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG + [ "$ARGS" = "--wp" ] && EE_DEBUG_WP=$ARGS && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG + [ "$ARGS" != "debug" ]&& [ "$ARGS" != "--nginx" ] && [ "$ARGS" != "--rewrite" ] && [ "$ARGS" != "--php" ] && [ "$ARGS" != "--fpm" ] && [ "$ARGS" != "--mysql" ] && [ "$ARGS" != "--wp" ] && EE_DEBUG_SITENAME=$ARGS && echo EE_DEBUG_SITENAME = $EE_DEBUG_SITENAME &>> $INSTALLLOG + + done + + if [ "$EE_DEBUG_NGINX" = "--nginx" ] then # Debug Nginx DEBUG_NGINX - elif [ "$2" = "--rewrite" ] + fi + + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs DEBUG_NGINX_REWRITE - elif [ "$2" = "--php" ] + fi + + if [ "$EE_DEBUG_PHP" = "--php" ] then # Debug PHP DEBUG_PHP - elif [ "$2" = "--fpm" ] + fi + + if [ "$EE_DEBUG_FPM" = "--fpm" ] then # Debug PHP FPM DEBUG_PHP_FPM - elif [ "$2" = "--mysql" ] + fi + + if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then # Debug MySQL Slow Query DEBUG_MYSQL - elif [ "$2" = "--wp" ] + fi + + if [ "$EE_DEBUG_WP" = "--wp" ] then # Debug WordPress Debug Log From 49977f40b757bd0705ff88d7cb60da7c15227a7e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 28 Mar 2014 16:39:30 +0530 Subject: [PATCH 22/50] EasyEngine Debug Start Logic Finished --- usr/local/sbin/easyengine | 106 +++++++++++++++++++++++++++++--------- 1 file changed, 83 insertions(+), 23 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index b074ce5b..8cb5268d 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -5,6 +5,7 @@ LOGDIR=/var/log/easyengine ERRORLOG=/var/log/easyengine/error.log INSTALLLOG=/var/log/easyengine/install.log LINUX_DISTRO=$(lsb_release -i | cut -d':' -f2 | awk '{print $1}') +EE_IP_ADDRESS=$(grep ip_address /etc/easyengine/ee.conf | cut -d'=' -f2 |sed 's/ //g' | tr ',' '\n') # Main EasyEngine Function To Log All The Outputs EasyEngine() @@ -299,11 +300,14 @@ COMMONNGINX() # White List IP Address echo -e "\033[34mEasyEngine (ee) Allow To Access Protected Files By Using Whitelisted IP Address Or HTTP Authentication\e[0m" - stty echo - read -p "Enter The IP Address To Whitelist: " WHITELISTIP - if [[ $WHITELISTIP != "" ]] + if [ -n "$EE_IP_ADDRESS" ] then - sed -i "s/deny.*/$(echo "allow $WHITELISTIP;")\ndeny all;/" /etc/nginx/common/acl.conf + for WHITELIST_IP_ADDRESS in $(echo $EE_IP_ADDRESS) + do + sed -i "/deny/i $(echo allow $WHITELIST_IP_ADDRESS\;)" /etc/nginx/common/acl.conf + done + else + echo -e "\033[34mEasyEngine Don't Find IP Address in /etc/easyengine/ee.conf file\e[0m" fi # Protect EE Locations @@ -1423,19 +1427,44 @@ REMOVENGINXCONF() DEBUG_NGINX() { + if [ -z "$EE_IP_ADDRESS" ] + then + read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS + fi + # Enable Debug Connection - for DEBUG_IP_ADDRESS in $( grep ip_address /etc/easyengine/ee.conf | cut -d'=' -f2 |sed 's/ //g' | tr ',' '\n' ) + for DEBUG_IP_ADDRESS in $(echo $EE_IP_ADDRESS) do - sed -i "/multi_accept/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf + sed -i "/multi_accept/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf done } +DEBUG_NGINX_SITE() +{ + grep "error.log debug" /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable Nginx Debug Log + echo -e "\033[34mStarting $DOMAIN Error Logs In Debugging Mode\e[0m" + sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$DOMAIN + else + echo -e "\033[34mAlready Started $DOMAIN Error Logs In Debugging Mode\e[0m" + fi +} + DEBUG_NGINX_REWRITE() { # Enable Nginx Rewrite Logs sed -i '/http {/a \\trewrite_log on;\n\n' /etc/nginx/nginx.conf } +DEBUG_NGINX_REWRITE_SITE() +{ + # Enable Nginx Rewrite Logs + echo -e "\033[34mStart Rewrite Logs For $DOMAIN\e[0m" + sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$DOMAIN +} + DEBUG_PHP() { # Slowlog Settings @@ -1481,6 +1510,7 @@ DEBUG_MYSQL() DEBUG_WORDPRESS() { # Debug WordPress + echo -e "\033[34mStart WordPress Debug Logs For $DOMAIN\e[0m" sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php } @@ -2547,55 +2577,85 @@ then done - if [ "$EE_DEBUG_NGINX" = "--nginx" ] + if [ -z "$EE_DEBUG_SITENAME" ] then - # Debug Nginx - DEBUG_NGINX + if [ "$EE_DEBUG_NGINX" = "--nginx" ] + then + # Debug Nginx + DEBUG_NGINX + fi - fi + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + then + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE + fi - if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] - then + else + + # Get The Domain Name + SITENAMECHECK=$EE_DEBUG_SITENAME + EESITENAME + + if [ "$EE_DEBUG_NGINX" = "--nginx" ] + then + # Debug Nginx + DEBUG_NGINX_SITE + fi - # Debug Nginx Rewrite Logs - DEBUG_NGINX_REWRITE + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + then + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE_SITE + fi + + if [ "$EE_DEBUG_WP" = "--wp" ] + then + + # Debug WordPress Debug Log + DEBUG_WORDPRESS + fi fi if [ "$EE_DEBUG_PHP" = "--php" ] then - # Debug PHP DEBUG_PHP - fi if [ "$EE_DEBUG_FPM" = "--fpm" ] then - # Debug PHP FPM DEBUG_PHP_FPM - fi if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then - # Debug MySQL Slow Query DEBUG_MYSQL - fi - if [ "$EE_DEBUG_WP" = "--wp" ] + # Lets Restart Services + if [ "$EE_DEBUG_NGINX" = "--nginx" ] || [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then + # Restart Nginx + NGINXRESTART - # Debug WordPress Debug Log - DEBUG_WORDPRESS + elif [ "$EE_DEBUG_PHP" = "--php" ] || [ "$EE_DEBUG_FPM" = "--fpm" ] + then + # Restart PHP5-FPM + PHPRESTART + elif [ "$EE_DEBUG_MYSQL" = "--mysql" ] + then + # Restart MySQL + MYSQLRESTART fi + elif [ "$1" = "update" ] then From ba8895ede079fb775807fac5eda30cdeaf4f435a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 28 Mar 2014 17:28:01 +0530 Subject: [PATCH 23/50] Fix nginx duplicate check issue --- usr/local/sbin/easyengine | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 8cb5268d..bbed7d72 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1448,21 +1448,36 @@ DEBUG_NGINX_SITE() echo -e "\033[34mStarting $DOMAIN Error Logs In Debugging Mode\e[0m" sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$DOMAIN else + EE_DEBUG_NGINX="" echo -e "\033[34mAlready Started $DOMAIN Error Logs In Debugging Mode\e[0m" fi } DEBUG_NGINX_REWRITE() { - # Enable Nginx Rewrite Logs - sed -i '/http {/a \\trewrite_log on;\n\n' /etc/nginx/nginx.conf + grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable Nginx Rewrite Logs + sed -i '/http {/a \\trewrite_log on;\n\n' /etc/nginx/nginx.conf + else + EE_DEBUG_REWRITE="" + echo -e "\033[34mRewrites Logs Already ON\e[0m" + fi } DEBUG_NGINX_REWRITE_SITE() { - # Enable Nginx Rewrite Logs - echo -e "\033[34mStart Rewrite Logs For $DOMAIN\e[0m" - sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$DOMAIN + grep "rewrite_log on;" /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable Nginx Rewrite Logs + echo -e "\033[34mStart Rewrite Logs For $DOMAIN\e[0m" + sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$DOMAIN + else + EE_DEBUG_REWRITE="" + echo -e "\033[34mRewrites Logs Already ON For $DOMAIN\e[0m" + fi } DEBUG_PHP() From 7ca48faea541b3d6794c20582af600c104aa6558 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 31 Mar 2014 14:18:34 +0530 Subject: [PATCH 24/50] Add Checks Before Restart Services --- usr/local/sbin/easyengine | 102 ++++++++++++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 16 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index bbed7d72..af2dd2cb 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1432,11 +1432,27 @@ DEBUG_NGINX() read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS fi - # Enable Debug Connection + # Lets Disable EE_DEBUG_NGINX + EE_DEBUG_NGINX="" + for DEBUG_IP_ADDRESS in $(echo $EE_IP_ADDRESS) do - sed -i "/multi_accept/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf + grep "debug_connection $DEBUG_IP_ADDRESS" /etc/nginx/nginx.conf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable Debug Connection + sed -i "/events {/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf + + # EasyEngine Found New IP Address Which Is Not Present In nginx.conf + # Lets Trigger The Nginx Restart + EE_DEBUG_NGINX="--nginx" + fi done + + if [ -z "$EE_DEBUG_NGINX" ] + then + echo -e "\033[34mNginx Already Started Debug Connection For Listed IP Address\e[0m" + fi } DEBUG_NGINX_SITE() @@ -1482,12 +1498,33 @@ DEBUG_NGINX_REWRITE_SITE() DEBUG_PHP() { + EE_DEBUG_PHP="" # Slowlog Settings - sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/www.conf - sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/www.conf + grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/www.conf + sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/www.conf + + # Lets Trigger The PHP5-FPM Restart + EE_DEBUG_PHP="--php" + + else + echo -e "\033[34mSlowlog Already Enabled\e[0m" + fi # Xdebug Settings - echo -e "xdebug.profiler_output_dir=/tmp \nxdebug.profiler_output_name=cachegrind.out.%p-%H-%R \nxdebug.profiler_enable_trigger=1 \nxdebug.profiler_enable=0" >> /etc/php5/fpm/conf.d/20-xdebug.ini + grep xdebug.profiler_ /etc/php5/fpm/conf.d/20-xdebug.ini &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "xdebug.profiler_output_dir=/tmp \nxdebug.profiler_output_name=cachegrind.out.%p-%H-%R \nxdebug.profiler_enable_trigger=1 \nxdebug.profiler_enable=0" >> /etc/php5/fpm/conf.d/20-xdebug.ini + + # Lets Trigger The PHP5-FPM Restart + EE_DEBUG_PHP="--php" + + else + echo -e "\033[34mXdebug Already Enabled\e[0m" + fi if [ ! -d /var/www/eeadmin/htdocs/php/webgrind/ ] then @@ -1510,23 +1547,43 @@ DEBUG_PHP() DEBUG_PHP_FPM() { - # Enable PHP5-FPM Error Logs In Debug Mode - sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf + grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable PHP5-FPM Error Logs In Debug Mode + sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf + else + EE_DEBUG_FPM="" + echo -e "\033[34mPHP5-FPM Log Level Is Already In Debug Mode\e[0m" + fi } DEBUG_MYSQL() { - # Enable MySQL Slow Logs - sed -i "/long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf - sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf - sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf + grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable MySQL Slow Logs + sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf + sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf + sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf + else + EE_DEBUG_MYSQL="" + echo -e "\033[34mMySQL Slow Log Already Enabled\e[0m" + fi } DEBUG_WORDPRESS() { - # Debug WordPress - echo -e "\033[34mStart WordPress Debug Logs For $DOMAIN\e[0m" - sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php + grep "'WP_DEBUG'" /var/www/$DOMAIN/wp-config.php | grep true &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Debug WordPress + echo -e "\033[34mStart WordPress Debug Logs For $DOMAIN\e[0m" + sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php + else + echo -e "\033[34mWordPress Debug Log Already Started For $DOMAIN\e[0m" + fi } # Easy Engine Version @@ -2592,6 +2649,17 @@ then done + if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] + then + echo -e "\033[34mLets Start Debugging Server\e[0m" + EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG + EE_DEBUG_REWRITE="--rewrite" && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG + EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG + EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG + EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG + EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG + fi + if [ -z "$EE_DEBUG_SITENAME" ] then @@ -2657,13 +2725,15 @@ then then # Restart Nginx NGINXRESTART + fi - elif [ "$EE_DEBUG_PHP" = "--php" ] || [ "$EE_DEBUG_FPM" = "--fpm" ] + if [ "$EE_DEBUG_PHP" = "--php" ] || [ "$EE_DEBUG_FPM" = "--fpm" ] then # Restart PHP5-FPM PHPRESTART + fi - elif [ "$EE_DEBUG_MYSQL" = "--mysql" ] + if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then # Restart MySQL MYSQLRESTART From 0756703a5eecb75087a54e1b047cb9a42010cf67 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 31 Mar 2014 17:32:39 +0530 Subject: [PATCH 25/50] ee debug [--start|--stop] --- usr/local/sbin/easyengine | 360 +++++++++++++++++++++++++++++++------- 1 file changed, 298 insertions(+), 62 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index af2dd2cb..470b1e2c 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1432,7 +1432,7 @@ DEBUG_NGINX() read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS fi - # Lets Disable EE_DEBUG_NGINX + # Lets Disable Nginx Restart Trigger EE_DEBUG_NGINX="" for DEBUG_IP_ADDRESS in $(echo $EE_IP_ADDRESS) @@ -1441,6 +1441,7 @@ DEBUG_NGINX() if [ $? -ne 0 ] then # Enable Debug Connection + echo -e "\033[34mSetting Up Nginx Debug Connection, Please Wait...\e[0m" sed -i "/events {/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf # EasyEngine Found New IP Address Which Is Not Present In nginx.conf @@ -1451,7 +1452,50 @@ DEBUG_NGINX() if [ -z "$EE_DEBUG_NGINX" ] then - echo -e "\033[34mNginx Already Started Debug Connection For Listed IP Address\e[0m" + echo -e "\033[34mNginx Debug Connection Already Enabled\e[0m" + fi +} + +DEBUG_NGINX_STOP() +{ + grep "debug_connection" /etc/nginx/nginx.conf &>> $INSTALLLOG + if [ $? -eq 0 ] + then + echo -e "\033[34mStopping Nginx Debug Connection, Please Wait...\e[0m" + sed -i "/debug_connection.*/d" /etc/nginx/nginx.conf + else + # Lets Disable Nginx Restart Trigger + EE_DEBUG_NGINX="" + echo -e "\033[34mNginx Debug Connection Already Stopped\e[0m" + fi +} + +DEBUG_NGINX_REWRITE() +{ + grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Enable Nginx Rewrite Logs + echo -e "\033[34mSetting Up Nginx Rewrite Logs, Please Wait...\e[0m" + sed -i '/http {/a \\trewrite_log on;' /etc/nginx/nginx.conf + else + EE_DEBUG_REWRITE="" + echo -e "\033[34mNginx Rewrites Logs Already ON\e[0m" + fi +} + +DEBUG_NGINX_REWRITE_STOP() +{ + grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $INSTALLLOG + if [ $? -eq 0 ] + then + # Disable Nginx Rewrite Logs + echo -e "\033[34mStopping Nginx Rewrite Logs, Please Wait...\e[0m" + sed -i "/rewrite_log.*/d" /etc/nginx/nginx.conf + else + # Lets Disable Nginx Restart Trigger + EE_DEBUG_REWRITE="" + echo -e "\033[34mNginx Rewrites Logs Already STOP\e[0m" fi } @@ -1461,24 +1505,27 @@ DEBUG_NGINX_SITE() if [ $? -ne 0 ] then # Enable Nginx Debug Log - echo -e "\033[34mStarting $DOMAIN Error Logs In Debugging Mode\e[0m" + echo -e "\033[34mSetting Up $DOMAIN Error Logs In Debugging Mode,Please Wait...\e[0m" sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$DOMAIN else + # Lets Disable Nginx Restart Trigger EE_DEBUG_NGINX="" echo -e "\033[34mAlready Started $DOMAIN Error Logs In Debugging Mode\e[0m" fi } -DEBUG_NGINX_REWRITE() +DEBUG_NGINX_SITE_STOP() { - grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $INSTALLLOG - if [ $? -ne 0 ] + grep "error.log debug" /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + if [ $? -eq 0 ] then - # Enable Nginx Rewrite Logs - sed -i '/http {/a \\trewrite_log on;\n\n' /etc/nginx/nginx.conf + # Disable Nginx Debug Log + echo -e "\033[34mDisable $DOMAIN Error Logs In Debugging Mode,Please Wait...\e[0m" + sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$DOMAIN else - EE_DEBUG_REWRITE="" - echo -e "\033[34mRewrites Logs Already ON\e[0m" + # Lets Disable Nginx Restart Trigger + EE_DEBUG_NGINX="" + echo -e "\033[34mAlready Stopped $DOMAIN Error Logs In Debugging Mode\e[0m" fi } @@ -1488,21 +1535,40 @@ DEBUG_NGINX_REWRITE_SITE() if [ $? -ne 0 ] then # Enable Nginx Rewrite Logs - echo -e "\033[34mStart Rewrite Logs For $DOMAIN\e[0m" + echo -e "\033[34mSetting Up Nginx Rewrite Logs For $DOMAIN\e[0m" sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$DOMAIN else + # Lets Disable Nginx Restart Trigger EE_DEBUG_REWRITE="" echo -e "\033[34mRewrites Logs Already ON For $DOMAIN\e[0m" fi } +DEBUG_NGINX_REWRITE_SITE_STOP() +{ + grep "rewrite_log on;" /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + if [ $? -eq 0 ] + then + # Disable Nginx Rewrite Logs + echo -e "\033[34mStopping Up Nginx Rewrite Logs For $DOMAIN\e[0m" + sed -i "/rewrite_log.*/d" /etc/nginx/sites-available/$DOMAIN + else + # Lets Disable Nginx Restart Trigger + EE_DEBUG_REWRITE="" + echo -e "\033[34mRewrites Logs Already Stop For $DOMAIN\e[0m" + fi +} + DEBUG_PHP() { + # Lets Disable PHP Restart Trigger EE_DEBUG_PHP="" + # Slowlog Settings grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG if [ $? -ne 0 ] then + echo -e "\033[34mSetting Up PHP5-FPM Slow Log, Please Wait...\e[0m" sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/www.conf sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/www.conf @@ -1510,13 +1576,14 @@ DEBUG_PHP() EE_DEBUG_PHP="--php" else - echo -e "\033[34mSlowlog Already Enabled\e[0m" + echo -e "\033[34mPHP5-FPM Slow Log Already Enabled\e[0m" fi # Xdebug Settings grep xdebug.profiler_ /etc/php5/fpm/conf.d/20-xdebug.ini &>> $INSTALLLOG if [ $? -ne 0 ] then + echo -e "\033[34mSetting Up Xdebug, Please Wait...\e[0m" echo -e "xdebug.profiler_output_dir=/tmp \nxdebug.profiler_output_name=cachegrind.out.%p-%H-%R \nxdebug.profiler_enable_trigger=1 \nxdebug.profiler_enable=0" >> /etc/php5/fpm/conf.d/20-xdebug.ini # Lets Trigger The PHP5-FPM Restart @@ -1545,12 +1612,48 @@ DEBUG_PHP() fi } +DEBUG_PHP_STOP() +{ + # Lets Disable PHP Restart Trigger + EE_DEBUG_PHP="" + + # Slowlog Settings + grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG + if [ $? -eq 0 ] + then + echo -e "\033[34mStopping Up PHP5-FPM Slow Log, Please Wait...\e[0m" + sed -i "s'slowlog =';slowlog ='" /etc/php5/fpm/pool.d/www.conf + sed -i "s'request_slowlog_timeout';request_slowlog_timeout'" /etc/php5/fpm/pool.d/www.conf + + # Lets Trigger The PHP5-FPM Restart + EE_DEBUG_PHP="--php" + + else + echo -e "\033[34mPHP5-FPM Slow Log Already Disable\e[0m" + fi + + # Xdebug Settings + grep xdebug.profiler_ /etc/php5/fpm/conf.d/20-xdebug.ini &>> $INSTALLLOG + if [ $? -eq 0 ] + then + echo -e "\033[34mDisable Xdebug, Please Wait...\e[0m" + sed "/xdebug.profiler_/d" /etc/php5/fpm/conf.d/20-xdebug.ini + + # Lets Trigger The PHP5-FPM Restart + EE_DEBUG_PHP="--php" + + else + echo -e "\033[34mXdebug Already Disable\e[0m" + fi +} + DEBUG_PHP_FPM() { grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $INSTALLLOG if [ $? -ne 0 ] then # Enable PHP5-FPM Error Logs In Debug Mode + echo -e "\033[34mSetting Up PHP5-FPM Log Level In Debug Mode, Please Wait...\e[0m" sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf else EE_DEBUG_FPM="" @@ -1558,12 +1661,27 @@ DEBUG_PHP_FPM() fi } +DEBUG_PHP_FPM_STOP() +{ + grep "log_level = notice" /etc/php5/fpm/php-fpm.conf &>> $INSTALLLOG + if [ $? -nq 0 ] + then + # Disable PHP5-FPM Error Logs In Debug Mode + echo -e "\033[34mStopping PHP5-FPM Log Level In Debug Mode, Please Wait...\e[0m" + sed -i "s/log_level = debug/log_level = notice/" /etc/php5/fpm/php-fpm.conf + else + EE_DEBUG_FPM="" + echo -e "\033[34mDiPHP5-FPM Log Level Already In Notice (Default) Mode\e[0m" + fi +} + DEBUG_MYSQL() { grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG if [ $? -ne 0 ] then # Enable MySQL Slow Logs + echo -e "\033[34mSetting Up MySQL Slow Log, Please Wait...\e[0m" sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf @@ -1573,6 +1691,22 @@ DEBUG_MYSQL() fi } +DEBUG_MYSQL_STOP() +{ + grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG + if [ $? -eq 0 ] + then + # Disable MySQL Slow Logs + echo -e "\033[34mStopping MySQL Slow Log, Please Wait...\e[0m" + sed -i "/slow-query-log/d" /etc/mysql/my.cnf + sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf + sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf + else + EE_DEBUG_MYSQL="" + echo -e "\033[34mMySQL Slow Log Already Disable\e[0m" + fi +} + DEBUG_WORDPRESS() { grep "'WP_DEBUG'" /var/www/$DOMAIN/wp-config.php | grep true &>> $INSTALLLOG @@ -1586,6 +1720,22 @@ DEBUG_WORDPRESS() fi } +DEBUG_WORDPRESS_STOP() +{ + grep "'WP_DEBUG'" /var/www/$DOMAIN/wp-config.php | grep true &>> $INSTALLLOG + if [ $? -eq 0 ] + then + # Stop Debug WordPress + echo -e "\033[34mStopping WordPress Debug Logs For $DOMAIN\e[0m" + sed -i "s/define('WP_DEBUG', true);/define('WP_DEBUG', false);/" /var/www/$DOMAIN/wp-config.php + sed -i "/define('WP_DEBUG_DISPLAY', false);/d" /var/www/$DOMAIN/wp-config.php + sed -i "/define('WP_DEBUG_LOG', true);/d" /var/www/$DOMAIN/wp-config.php + sed -i "/define('SAVEQUERIES', true);/d" /var/www/$DOMAIN/wp-config.php + else + echo -e "\033[34mWordPress Debug Log Already Stopped For $DOMAIN\e[0m" + fi +} + # Easy Engine Version if [ "$1" = "version" ] || [ "$1" = "--version" ] || [ "$1" = "-v" ] then @@ -2636,90 +2786,176 @@ then elif [ "$1" = "debug" ] then + # Default Action = Start Debugging + EE_DEBUG="--start" + # Auto Arrenge Options for ARGS in $@ do + [ "$ARGS" = "--stop" ] && EE_DEBUG=$ARGS && echo EE_DEBUG = $EE_DEBUG &>> $INSTALLLOG [ "$ARGS" = "--nginx" ] && EE_DEBUG_NGINX=$ARGS && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG [ "$ARGS" = "--rewrite" ] && EE_DEBUG_REWRITE=$ARGS && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG [ "$ARGS" = "--php" ] && EE_DEBUG_PHP=$ARGS && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG [ "$ARGS" = "--fpm" ] && EE_DEBUG_FPM=$ARGS && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG [ "$ARGS" = "--mysql" ] && EE_DEBUG_MYSQL=$ARGS && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG [ "$ARGS" = "--wp" ] && EE_DEBUG_WP=$ARGS && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG - [ "$ARGS" != "debug" ]&& [ "$ARGS" != "--nginx" ] && [ "$ARGS" != "--rewrite" ] && [ "$ARGS" != "--php" ] && [ "$ARGS" != "--fpm" ] && [ "$ARGS" != "--mysql" ] && [ "$ARGS" != "--wp" ] && EE_DEBUG_SITENAME=$ARGS && echo EE_DEBUG_SITENAME = $EE_DEBUG_SITENAME &>> $INSTALLLOG - + if [ "$ARGS" != "debug" ] && [ "$ARGS" != "--start" ] && [ "$ARGS" != "--stop" ] && [ "$ARGS" != "--nginx" ] && [ "$ARGS" != "--rewrite" ] && [ "$ARGS" != "--php" ] && [ "$ARGS" != "--fpm" ] && [ "$ARGS" != "--mysql" ] && [ "$ARGS" != "--wp" ] + then + ls /etc/nginx/sites-available/ | grep $ARGS &>> $INSTALLLOG + if [ $? -eq 0 ] + then + EE_DEBUG_SITENAME=$ARGS && echo EE_DEBUG_SITENAME = $EE_DEBUG_SITENAME &>> $INSTALLLOG + fi + fi done - if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] + if [ "$EE_DEBUG" = "--start" ] then echo -e "\033[34mLets Start Debugging Server\e[0m" - EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG - EE_DEBUG_REWRITE="--rewrite" && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG - EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG - EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG - EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG - EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG - fi + if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] + then + EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG + EE_DEBUG_REWRITE="--rewrite" && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG + EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG + EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG + EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG + EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG + fi + + if [ -z "$EE_DEBUG_SITENAME" ] + then - if [ -z "$EE_DEBUG_SITENAME" ] - then + if [ "$EE_DEBUG_NGINX" = "--nginx" ] + then + # Debug Nginx + DEBUG_NGINX + fi + + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + then + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE + fi + + else + + # Get The Domain Name + SITENAMECHECK=$EE_DEBUG_SITENAME + EESITENAME + + if [ "$EE_DEBUG_NGINX" = "--nginx" ] + then + # Debug Nginx + DEBUG_NGINX_SITE + fi + + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + then + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE_SITE + fi + + if [ "$EE_DEBUG_WP" = "--wp" ] + then + # Debug WordPress Debug Log + DEBUG_WORDPRESS + fi - if [ "$EE_DEBUG_NGINX" = "--nginx" ] - then - # Debug Nginx - DEBUG_NGINX fi - if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + if [ "$EE_DEBUG_PHP" = "--php" ] then - # Debug Nginx Rewrite Logs - DEBUG_NGINX_REWRITE + # Debug PHP + DEBUG_PHP fi - else - - # Get The Domain Name - SITENAMECHECK=$EE_DEBUG_SITENAME - EESITENAME - - if [ "$EE_DEBUG_NGINX" = "--nginx" ] + if [ "$EE_DEBUG_FPM" = "--fpm" ] then - # Debug Nginx - DEBUG_NGINX_SITE + # Debug PHP FPM + DEBUG_PHP_FPM fi - if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then - # Debug Nginx Rewrite Logs - DEBUG_NGINX_REWRITE_SITE + # Debug MySQL Slow Query + DEBUG_MYSQL fi - if [ "$EE_DEBUG_WP" = "--wp" ] + elif [ "$EE_DEBUG" = "--stop" ] + then + echo -e "\033[34mLets Stop Debugging Server\e[0m" + + if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] + then + EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG + EE_DEBUG_REWRITE="--rewrite" && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG + EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG + EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG + EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG + EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG + fi + + if [ -z "$EE_DEBUG_SITENAME" ] then - # Debug WordPress Debug Log - DEBUG_WORDPRESS + if [ "$EE_DEBUG_NGINX" = "--nginx" ] + then + # Debug Nginx + DEBUG_NGINX_STOP + fi + + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + then + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE_STOP + fi + + else + + # Get The Domain Name + SITENAMECHECK=$EE_DEBUG_SITENAME + EESITENAME + + if [ "$EE_DEBUG_NGINX" = "--nginx" ] + then + # Debug Nginx + DEBUG_NGINX_SITE_STOP + fi + + if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] + then + # Debug Nginx Rewrite Logs + DEBUG_NGINX_REWRITE_SITE_STOP + fi + + if [ "$EE_DEBUG_WP" = "--wp" ] + then + # Debug WordPress Debug Log + DEBUG_WORDPRESS_STOP + fi + fi - fi + if [ "$EE_DEBUG_PHP" = "--php" ] + then + # Debug PHP + DEBUG_PHP_STOP + fi - if [ "$EE_DEBUG_PHP" = "--php" ] - then - # Debug PHP - DEBUG_PHP - fi + if [ "$EE_DEBUG_FPM" = "--fpm" ] + then + # Debug PHP FPM + DEBUG_PHP_FPM_STOP + fi - if [ "$EE_DEBUG_FPM" = "--fpm" ] - then - # Debug PHP FPM - DEBUG_PHP_FPM - fi + if [ "$EE_DEBUG_MYSQL" = "--mysql" ] + then + # Debug MySQL Slow Query + DEBUG_MYSQL_STOP + fi - if [ "$EE_DEBUG_MYSQL" = "--mysql" ] - then - # Debug MySQL Slow Query - DEBUG_MYSQL + fi - # Lets Restart Services if [ "$EE_DEBUG_NGINX" = "--nginx" ] || [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then From 17eebdf133a80b9934d8b40be471292523b0407d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 31 Mar 2014 17:33:04 +0530 Subject: [PATCH 26/50] fix if statement --- usr/local/sbin/easyengine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 470b1e2c..7d719e40 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1637,7 +1637,7 @@ DEBUG_PHP_STOP() if [ $? -eq 0 ] then echo -e "\033[34mDisable Xdebug, Please Wait...\e[0m" - sed "/xdebug.profiler_/d" /etc/php5/fpm/conf.d/20-xdebug.ini + sed -i "/xdebug.profiler_/d" /etc/php5/fpm/conf.d/20-xdebug.ini # Lets Trigger The PHP5-FPM Restart EE_DEBUG_PHP="--php" @@ -1664,7 +1664,7 @@ DEBUG_PHP_FPM() DEBUG_PHP_FPM_STOP() { grep "log_level = notice" /etc/php5/fpm/php-fpm.conf &>> $INSTALLLOG - if [ $? -nq 0 ] + if [ $? -ne 0 ] then # Disable PHP5-FPM Error Logs In Debug Mode echo -e "\033[34mStopping PHP5-FPM Log Level In Debug Mode, Please Wait...\e[0m" From 7397bea4b6d37e78505cc9eacd67d09684b23a7b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 31 Mar 2014 18:53:27 +0530 Subject: [PATCH 27/50] ee debug -i start debug and ctrl+c stop debug mode --- usr/local/sbin/easyengine | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 7d719e40..02a3e3f5 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1442,9 +1442,10 @@ DEBUG_NGINX() then # Enable Debug Connection echo -e "\033[34mSetting Up Nginx Debug Connection, Please Wait...\e[0m" - sed -i "/events {/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf # EasyEngine Found New IP Address Which Is Not Present In nginx.conf + sed -i "/events {/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf + # Lets Trigger The Nginx Restart EE_DEBUG_NGINX="--nginx" fi @@ -1671,7 +1672,7 @@ DEBUG_PHP_FPM_STOP() sed -i "s/log_level = debug/log_level = notice/" /etc/php5/fpm/php-fpm.conf else EE_DEBUG_FPM="" - echo -e "\033[34mDiPHP5-FPM Log Level Already In Notice (Default) Mode\e[0m" + echo -e "\033[34mPHP5-FPM Log Level Already In Notice (Default) Mode\e[0m" fi } @@ -1736,6 +1737,38 @@ DEBUG_WORDPRESS_STOP() fi } +DEBUG_KILL() +{ + if [ -z "$EE_DEBUG_SITENAME" ] + then + ee debug --stop + else + ee debug --stop $EE_DEBUG_SITENAME + fi + + # Unset Trap So We Don't Get Infinate Loop + trap - EXIT + + # Flush File System Buffers + # More Details: info coreutils 'sync invocation' + sync + + # Successfull Exit + exit 0; +} +trap "DEBUG_KILL" EXIT + +DEBUG_INTERACTIVE() +{ + if [ -z "$EE_DEBUG_SITENAME" ] + then + tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log + else + tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log /var/www/$DOMAIN/htdocs/wp-content/debug.log + fi +} + + # Easy Engine Version if [ "$1" = "version" ] || [ "$1" = "--version" ] || [ "$1" = "-v" ] then @@ -2792,6 +2825,7 @@ then # Auto Arrenge Options for ARGS in $@ do + [ "$ARGS" = "-i" ] && EE_DEBUG_INTERACTIVE=$ARGS && echo EE_DEBUG_INTERACTIVE = $EE_DEBUG_INTERACTIVE &>> $INSTALLLOG [ "$ARGS" = "--stop" ] && EE_DEBUG=$ARGS && echo EE_DEBUG = $EE_DEBUG &>> $INSTALLLOG [ "$ARGS" = "--nginx" ] && EE_DEBUG_NGINX=$ARGS && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG [ "$ARGS" = "--rewrite" ] && EE_DEBUG_REWRITE=$ARGS && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $INSTALLLOG @@ -2799,7 +2833,7 @@ then [ "$ARGS" = "--fpm" ] && EE_DEBUG_FPM=$ARGS && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG [ "$ARGS" = "--mysql" ] && EE_DEBUG_MYSQL=$ARGS && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG [ "$ARGS" = "--wp" ] && EE_DEBUG_WP=$ARGS && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG - if [ "$ARGS" != "debug" ] && [ "$ARGS" != "--start" ] && [ "$ARGS" != "--stop" ] && [ "$ARGS" != "--nginx" ] && [ "$ARGS" != "--rewrite" ] && [ "$ARGS" != "--php" ] && [ "$ARGS" != "--fpm" ] && [ "$ARGS" != "--mysql" ] && [ "$ARGS" != "--wp" ] + if [ "$ARGS" != "debug" ] && [ "$ARGS" != "-i" ] && [ "$ARGS" != "--start" ] && [ "$ARGS" != "--stop" ] && [ "$ARGS" != "--nginx" ] && [ "$ARGS" != "--rewrite" ] && [ "$ARGS" != "--php" ] && [ "$ARGS" != "--fpm" ] && [ "$ARGS" != "--mysql" ] && [ "$ARGS" != "--wp" ] then ls /etc/nginx/sites-available/ | grep $ARGS &>> $INSTALLLOG if [ $? -eq 0 ] @@ -2954,8 +2988,8 @@ then DEBUG_MYSQL_STOP fi - fi + # Lets Restart Services if [ "$EE_DEBUG_NGINX" = "--nginx" ] || [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then @@ -2975,6 +3009,12 @@ then MYSQLRESTART fi + if [ "$EE_DEBUG_INTERACTIVE" = "-i" ] + then + # Lets Start Debug In Interactive Mode + DEBUG_INTERACTIVE + fi + elif [ "$1" = "update" ] From 77f5411b924eddcdba32d4322007b95b66d2abec Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 8 Apr 2014 11:11:48 +0530 Subject: [PATCH 28/50] Fixed Debug Stop on Ctrl+C --- usr/local/sbin/easyengine | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 02a3e3f5..41460ca0 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1678,14 +1678,15 @@ DEBUG_PHP_FPM_STOP() DEBUG_MYSQL() { - grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG + mysql -u show variables like 'slow_query_log'; + #grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG if [ $? -ne 0 ] then # Enable MySQL Slow Logs echo -e "\033[34mSetting Up MySQL Slow Log, Please Wait...\e[0m" - sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf - sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf - sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf + #sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf + #sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf + #sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf else EE_DEBUG_MYSQL="" echo -e "\033[34mMySQL Slow Log Already Enabled\e[0m" @@ -1739,11 +1740,14 @@ DEBUG_WORDPRESS_STOP() DEBUG_KILL() { - if [ -z "$EE_DEBUG_SITENAME" ] + if [ "$EE_DEBUG" = "--start" ] then - ee debug --stop - else - ee debug --stop $EE_DEBUG_SITENAME + if [ -z "$EE_DEBUG_SITENAME" ] + then + ee debug --stop + else + ee debug --stop $EE_DEBUG_SITENAME + fi fi # Unset Trap So We Don't Get Infinate Loop From cb638f85dd5cb0e50b0a79db1631a42e136653d5 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 8 Apr 2014 11:51:52 +0530 Subject: [PATCH 29/50] Start/Stop MySQL Slow Log Without Restart --- usr/local/sbin/easyengine | 43 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 41460ca0..f3843f36 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1678,33 +1678,54 @@ DEBUG_PHP_FPM_STOP() DEBUG_MYSQL() { - mysql -u show variables like 'slow_query_log'; + # Collect MySQL Login Details + MYSQLROOT + + # Check MySql Slow Logs Is ON #grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG + mysql -u $MYSQLUSER -p$MYSQLPASS -e "show variables like 'slow_query_log';" | grep ON + if [ $? -ne 0 ] then # Enable MySQL Slow Logs echo -e "\033[34mSetting Up MySQL Slow Log, Please Wait...\e[0m" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global slow_query_log = 'ON';" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global long_query_time=2;" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global log_queries_not_using_indexes = 'ON';" #sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf #sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf #sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf else - EE_DEBUG_MYSQL="" + # Lets Disable MySQL Restart Trigger + #EE_DEBUG_MYSQL="" echo -e "\033[34mMySQL Slow Log Already Enabled\e[0m" fi } DEBUG_MYSQL_STOP() { - grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG + # Collect MySQL Login Details + MYSQLROOT + + # Check MySql Slow Logs Is OFF + #grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG + mysql -u $MYSQLUSER -p$MYSQLPASS -e "show variables like 'slow_query_log';" | grep ON + if [ $? -eq 0 ] then # Disable MySQL Slow Logs echo -e "\033[34mStopping MySQL Slow Log, Please Wait...\e[0m" - sed -i "/slow-query-log/d" /etc/mysql/my.cnf - sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf - sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global slow_query_log = 'OFF';" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global long_query_time=10;" + mysql -u $MYSQLUSER -p$MYSQLPASS -e "set global log_queries_not_using_indexes = 'OFF';" + #sed -i "/slow-query-log/d" /etc/mysql/my.cnf + #sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf + #sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf else - EE_DEBUG_MYSQL="" + # Lets Disable MySQL Restart Trigger + #EE_DEBUG_MYSQL="" echo -e "\033[34mMySQL Slow Log Already Disable\e[0m" fi } @@ -3007,11 +3028,11 @@ then PHPRESTART fi - if [ "$EE_DEBUG_MYSQL" = "--mysql" ] - then + #if [ "$EE_DEBUG_MYSQL" = "--mysql" ] + #then # Restart MySQL - MYSQLRESTART - fi + #MYSQLRESTART + #fi if [ "$EE_DEBUG_INTERACTIVE" = "-i" ] then From 30ef7689d8ba3fe35e1e7d4858c2f10a29ef19ad Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 8 Apr 2014 12:29:59 +0530 Subject: [PATCH 30/50] Fixed debug.log --- usr/local/sbin/easyengine | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index f3843f36..169dcdca 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1683,7 +1683,7 @@ DEBUG_MYSQL() # Check MySql Slow Logs Is ON #grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG - mysql -u $MYSQLUSER -p$MYSQLPASS -e "show variables like 'slow_query_log';" | grep ON + mysql -u $MYSQLUSER -p$MYSQLPASS -e "show variables like 'slow_query_log';" | grep ON &>> $INSTALLLOG if [ $? -ne 0 ] then @@ -1710,7 +1710,7 @@ DEBUG_MYSQL_STOP() # Check MySql Slow Logs Is OFF #grep slow-query-log /etc/mysql/my.cnf &>> $INSTALLLOG - mysql -u $MYSQLUSER -p$MYSQLPASS -e "show variables like 'slow_query_log';" | grep ON + mysql -u $MYSQLUSER -p$MYSQLPASS -e "show variables like 'slow_query_log';" | grep ON &>> $INSTALLLOG if [ $? -eq 0 ] then @@ -1737,6 +1737,15 @@ DEBUG_WORDPRESS() then # Debug WordPress echo -e "\033[34mStart WordPress Debug Logs For $DOMAIN\e[0m" + + # Call PHPUSERINFO Function For PHP User Details + PHPUSERINFO + + # Create debug.log & Change Permission + touch /var/www/$DOMAIN/htdocs/wp-content/debug.log + chown $PHPUSER:$PHPUSER /var/www/$DOMAIN/htdocs/wp-content/debug.log + + # Turn On Debug sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php else echo -e "\033[34mWordPress Debug Log Already Started For $DOMAIN\e[0m" From dfd9f86dad546438722af596a9e28d5ce6caaa7d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 8 Apr 2014 15:26:48 +0530 Subject: [PATCH 31/50] Separate PHP Pool For Slowlog --- usr/local/sbin/easyengine | 117 ++++++++++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 29 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 169dcdca..7afb8f21 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -365,6 +365,14 @@ COMMONPHP() # Change PHP Fastcgi Socket sed -i "s'listen = /var/run/php5-fpm.sock'listen = 127.0.0.1:9000'" /etc/php5/fpm/pool.d/www.conf || OwnError "Unable To Change PHP Fastcgi Socket" + + # Separate PHP POOL For Slow Logs + cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/slowlog.conf + sed -i "s'\[www\]'[slowlog]'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Pool Name" + sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Fastcgi Listen Port" + sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Chnage Process Manager From Dynamic To Ondemand" + sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Slowlog" + sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Request Slowlog Timeout" fi } @@ -1432,7 +1440,7 @@ DEBUG_NGINX() read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS fi - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" for DEBUG_IP_ADDRESS in $(echo $EE_IP_ADDRESS) @@ -1446,7 +1454,7 @@ DEBUG_NGINX() # EasyEngine Found New IP Address Which Is Not Present In nginx.conf sed -i "/events {/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf - # Lets Trigger The Nginx Restart + # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" fi done @@ -1465,7 +1473,7 @@ DEBUG_NGINX_STOP() echo -e "\033[34mStopping Nginx Debug Connection, Please Wait...\e[0m" sed -i "/debug_connection.*/d" /etc/nginx/nginx.conf else - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" echo -e "\033[34mNginx Debug Connection Already Stopped\e[0m" fi @@ -1480,6 +1488,7 @@ DEBUG_NGINX_REWRITE() echo -e "\033[34mSetting Up Nginx Rewrite Logs, Please Wait...\e[0m" sed -i '/http {/a \\trewrite_log on;' /etc/nginx/nginx.conf else + # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" echo -e "\033[34mNginx Rewrites Logs Already ON\e[0m" fi @@ -1494,7 +1503,7 @@ DEBUG_NGINX_REWRITE_STOP() echo -e "\033[34mStopping Nginx Rewrite Logs, Please Wait...\e[0m" sed -i "/rewrite_log.*/d" /etc/nginx/nginx.conf else - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" echo -e "\033[34mNginx Rewrites Logs Already STOP\e[0m" fi @@ -1509,7 +1518,7 @@ DEBUG_NGINX_SITE() echo -e "\033[34mSetting Up $DOMAIN Error Logs In Debugging Mode,Please Wait...\e[0m" sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$DOMAIN else - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" echo -e "\033[34mAlready Started $DOMAIN Error Logs In Debugging Mode\e[0m" fi @@ -1524,7 +1533,7 @@ DEBUG_NGINX_SITE_STOP() echo -e "\033[34mDisable $DOMAIN Error Logs In Debugging Mode,Please Wait...\e[0m" sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$DOMAIN else - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" echo -e "\033[34mAlready Stopped $DOMAIN Error Logs In Debugging Mode\e[0m" fi @@ -1539,7 +1548,7 @@ DEBUG_NGINX_REWRITE_SITE() echo -e "\033[34mSetting Up Nginx Rewrite Logs For $DOMAIN\e[0m" sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$DOMAIN else - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" echo -e "\033[34mRewrites Logs Already ON For $DOMAIN\e[0m" fi @@ -1554,7 +1563,7 @@ DEBUG_NGINX_REWRITE_SITE_STOP() echo -e "\033[34mStopping Up Nginx Rewrite Logs For $DOMAIN\e[0m" sed -i "/rewrite_log.*/d" /etc/nginx/sites-available/$DOMAIN else - # Lets Disable Nginx Restart Trigger + # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" echo -e "\033[34mRewrites Logs Already Stop For $DOMAIN\e[0m" fi @@ -1566,18 +1575,42 @@ DEBUG_PHP() EE_DEBUG_PHP="" # Slowlog Settings - grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG - if [ $? -ne 0 ] - then - echo -e "\033[34mSetting Up PHP5-FPM Slow Log, Please Wait...\e[0m" - sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/www.conf - sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/www.conf + #grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/slowlog.conf &>> $INSTALLLOG + #if [ $? -ne 0 ] + #hen + #echo -e "\033[34mSetting Up PHP5-FPM Slow Log, Please Wait...\e[0m" + #sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/slowlog.conf + #sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/slowlog.conf + + #else + #echo -e "\033[34mPHP5-FPM Slow Log Already Enabled\e[0m" + #fi - # Lets Trigger The PHP5-FPM Restart - EE_DEBUG_PHP="--php" + if [ -z $EE_DEBUG_SITENAME ] + then + grep 9001 /etc/nginx/conf.d/upstream.conf &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "\033[34mEnable PHP5-FPM Slow Log, Please Wait...\e[0m" + sed -i "s/9000/9001/" /etc/nginx/conf.d/upstream.conf + # Lets Trigger The Nginx Reload + EE_DEBUG_NGINX="--nginx" + else + echo -e "\033[34mPHP5-FPM Slow Log Already Enabled\e[0m" + fi else - echo -e "\033[34mPHP5-FPM Slow Log Already Enabled\e[0m" + grep 9001 /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "\033[34mEnable PHP5-FPM Slow Log For $DOMAIN, Please Wait...\e[0m" + sed -i "s/fastcgi_pass.*/fastcgi_pass 127.0.0.1:9001;/g" /etc/nginx/sites-available/$DOMAIN + + # Lets Trigger The Nginx Reload + EE_DEBUG_NGINX="--nginx" + else + echo -e "\033[34mPHP5-FPM Slow Log Already Enabled For $DOMAIN\e[0m" + fi fi # Xdebug Settings @@ -1619,18 +1652,45 @@ DEBUG_PHP_STOP() EE_DEBUG_PHP="" # Slowlog Settings - grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG - if [ $? -eq 0 ] - then - echo -e "\033[34mStopping Up PHP5-FPM Slow Log, Please Wait...\e[0m" - sed -i "s'slowlog =';slowlog ='" /etc/php5/fpm/pool.d/www.conf - sed -i "s'request_slowlog_timeout';request_slowlog_timeout'" /etc/php5/fpm/pool.d/www.conf + #grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG + #if [ $? -eq 0 ] + #then + #echo -e "\033[34mStopping Up PHP5-FPM Slow Log, Please Wait...\e[0m" + #sed -i "s'slowlog =';slowlog ='" /etc/php5/fpm/pool.d/www.conf + #sed -i "s'request_slowlog_timeout';request_slowlog_timeout'" /etc/php5/fpm/pool.d/www.conf # Lets Trigger The PHP5-FPM Restart - EE_DEBUG_PHP="--php" + #EE_DEBUG_PHP="--php" + #else + #echo -e "\033[34mPHP5-FPM Slow Log Already Disable\e[0m" + #fi + + if [ -z $EE_DEBUG_SITENAME ] + then + grep 9001 /etc/nginx/conf.d/upstream.conf &>> $INSTALLLOG + if [ $? -eq 0 ] + then + echo -e "\033[34mDisable PHP5-FPM Slow Log, Please Wait...\e[0m" + sed -i "s/9001/9000/" /etc/nginx/conf.d/upstream.conf + + # Lets Trigger The Nginx Reload + EE_DEBUG_NGINX="--nginx" + else + echo -e "\033[34mPHP5-FPM Slow Log Already Disabled\e[0m" + fi else - echo -e "\033[34mPHP5-FPM Slow Log Already Disable\e[0m" + grep 9001 /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "\033[34mDisable PHP5-FPM Slow Log For $DOMAIN, Please Wait...\e[0m" + sed -i "s/fastcgi_pass.*/fastcgi_pass php;/g" /etc/nginx/sites-available/$DOMAIN + + # Lets Trigger The Nginx Reload + EE_DEBUG_NGINX="--nginx" + else + echo -e "\033[34mPHP5-FPM Slow Log Already Disabled For $DOMAIN\e[0m" + fi fi # Xdebug Settings @@ -2879,7 +2939,7 @@ then if [ "$EE_DEBUG" = "--start" ] then - echo -e "\033[34mLets Start Debugging Server\e[0m" + if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] then EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG @@ -2951,7 +3011,6 @@ then elif [ "$EE_DEBUG" = "--stop" ] then - echo -e "\033[34mLets Stop Debugging Server\e[0m" if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] then @@ -3027,8 +3086,8 @@ then # Lets Restart Services if [ "$EE_DEBUG_NGINX" = "--nginx" ] || [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then - # Restart Nginx - NGINXRESTART + # Reload Nginx + NGINXRELOAD fi if [ "$EE_DEBUG_PHP" = "--php" ] || [ "$EE_DEBUG_FPM" = "--fpm" ] From 7220e116cbd15eacd3503184809ac07ee0ab1bb0 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 8 Apr 2014 16:03:39 +0530 Subject: [PATCH 32/50] Fixed If Statements --- usr/local/sbin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 7afb8f21..4fee812b 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1681,7 +1681,7 @@ DEBUG_PHP_STOP() fi else grep 9001 /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG - if [ $? -ne 0 ] + if [ $? -eq 0 ] then echo -e "\033[34mDisable PHP5-FPM Slow Log For $DOMAIN, Please Wait...\e[0m" sed -i "s/fastcgi_pass.*/fastcgi_pass php;/g" /etc/nginx/sites-available/$DOMAIN From 51812f46ffb9706662c0417db6bc2a21ecc8331a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 9 Apr 2014 16:22:09 +0530 Subject: [PATCH 33/50] Rename eeadmin.conf to 22222 --- etc/nginx/conf.d/eeadmin.conf | 28 ----------- usr/local/sbin/easyengine | 84 ++++++++++++++++---------------- usr/share/easyengine/nginx/22222 | 40 +++++++++++++++ 3 files changed, 82 insertions(+), 70 deletions(-) delete mode 100644 etc/nginx/conf.d/eeadmin.conf create mode 100644 usr/share/easyengine/nginx/22222 diff --git a/etc/nginx/conf.d/eeadmin.conf b/etc/nginx/conf.d/eeadmin.conf deleted file mode 100644 index 2e1a4399..00000000 --- a/etc/nginx/conf.d/eeadmin.conf +++ /dev/null @@ -1,28 +0,0 @@ -# EasyEngine Admin Configuration -server { - - listen 22222 ssl; - server_name _; - - access_log /var/log/nginx/eeadmin.access.log rt_cache; - error_log /var/log/nginx/eeadmin.error.log; - - ssl_certificate /etc/nginx/ssl/eeadmin.crt; - ssl_certificate_key /etc/nginx/ssl/eeadmin.key; - - root /var/www/eeadmin/htdocs; - index index.php index.htm index.html; - - location / { - autoindex on; - include common/acl.conf; - try_files $uri $uri/ /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass php; - } - -} diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 4fee812b..542eff71 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -275,27 +275,27 @@ COMMONNGINX() EEMD5SUM # EEAdmin SSL Setup - if [ ! -d /etc/nginx/ssl ] + if [ ! -d /var/www/22222/cert ] then - mkdir /etc/nginx/ssl || OwnError "Unable To Create /etc/nginx/ssl" + mkdir -p /var/www/22222/cert || OwnError "Unable To Create /var/www/22222/cert" fi # Generate SSL Key echo -e "\033[34mGenerating SSL Private Key, Please Wait...\e[0m" - openssl genrsa -out /etc/nginx/ssl/eeadmin.key 2048 &>> $INSTALLLOG \ + openssl genrsa -out /var/www/22222/cert/22222.key 2048 &>> $INSTALLLOG \ || OwnError "Unable To Generate SSL Private Key" echo -e "\033[34mGenerating a Certificate Signing Request (CSR), Please Wait...\e[0m" - openssl req -new -batch -subj /commonName=127.0.0.1/ -key /etc/nginx/ssl/eeadmin.key -out /etc/nginx/ssl/eeadmin.csr &>> $INSTALLLOG \ + openssl req -new -batch -subj /commonName=127.0.0.1/ -key /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.csr &>> $INSTALLLOG \ || OwnError "Unable To Generate Certificate Signing Request (CSR)" echo -e "\033[34mRemoving Passphrase From SSL Private Key, Please Wait...\e[0m" - mv /etc/nginx/ssl/eeadmin.key /etc/nginx/ssl/eeadmin.key.org - openssl rsa -in /etc/nginx/ssl/eeadmin.key.org -out /etc/nginx/ssl/eeadmin.key &>> $INSTALLLOG \ + mv /var/www/22222/cert/22222.key /var/www/22222/cert/22222.key.org + openssl rsa -in /var/www/22222/cert/22222.key.org -out /var/www/22222/cert/22222.key &>> $INSTALLLOG \ || OwnError "Unable To Remove Passphrase From SSL Private Key" echo -e "\033[34mGenerating SSL Certificate, Please Wait...\e[0m" - openssl x509 -req -days 3652 -in /etc/nginx/ssl/eeadmin.csr -signkey /etc/nginx/ssl/eeadmin.key -out /etc/nginx/ssl/eeadmin.crt &>> $INSTALLLOG \ + openssl x509 -req -days 3652 -in /var/www/22222/cert/22222.csr -signkey /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.crt &>> $INSTALLLOG \ || OwnError "Unable To Generate SSL Certificate" # White List IP Address @@ -400,42 +400,42 @@ WP-CLI() INSTALLPMA() { # Install PMA/phpMyAdmin - if [ ! -d /var/www/eeadmin/htdocs/db ] + if [ ! -d /var/www/22222/htdocs/db ] then - if [ ! -d /var/www/eeadmin/htdocs/db/pma ] + if [ ! -d /var/www/22222/htdocs/db/pma ] then echo -e "\033[34mDownloading phpMyAdmin, Please Wait...\e[0m" # Setup PMA/phpMyAdmin - mkdir -p /var/www/eeadmin/htdocs/db/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/eeadmin/htdocs/db/pma/" + mkdir -p /var/www/22222/htdocs/db/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/22222/htdocs/db/pma/" # Download PMA/phpMyAdmin - wget -cqO /var/www/eeadmin/htdocs/db/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ + wget -cqO /var/www/22222/htdocs/db/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ || OwnError "Unable To Download phpMyAdmin" # Extract PMA/phpMyAdmin - tar --strip-components=1 -zxf /var/www/eeadmin/htdocs/db/pma/pma.tar.gz -C /var/www/eeadmin/htdocs/db/pma/ \ + tar --strip-components=1 -zxf /var/www/22222/htdocs/db/pma/pma.tar.gz -C /var/www/22222/htdocs/db/pma/ \ || OwnError "Unable To Extract phpMyAdmin" # Remove Unwanted Files - rm -f /var/www/eeadmin/htdocs/db/pma/pma.tar.gz + rm -f /var/www/22222/htdocs/db/pma/pma.tar.gz fi - if [ ! -d /var/www/eeadmin/htdocs/db/adminer ] + if [ ! -d /var/www/22222/htdocs/db/adminer ] then echo -e "\033[34mDownloading Adminer, Please Wait...\e[0m" # Setup Adminer - mkdir -p /var/www/eeadmin/htdocs/db/adminer/ || OwnError "Unable To Create Adminer Directory: /var/www/eeadmin/htdocs/db/adminer/" + mkdir -p /var/www/22222/htdocs/db/adminer/ || OwnError "Unable To Create Adminer Directory: /var/www/22222/htdocs/db/adminer/" # Download Adminer - wget -cqO /var/www/eeadmin/htdocs/db/adminer/index.php http://downloads.sourceforge.net/adminer/adminer-4.0.3.php \ + wget -cqO /var/www/22222/htdocs/db/adminer/index.php http://downloads.sourceforge.net/adminer/adminer-4.0.3.php \ || OwnError "Unable To Download Adminer" fi else - echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/eeadmin/htdocs/db/pma)...\e[0m" + echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/22222/htdocs/db/pma)...\e[0m" fi } @@ -532,7 +532,7 @@ REMOVEPMA() { # Remove PMA/phpMyAdmin echo -e "\033[34mRemoving phpMyAdmin, Please Wait...\e[0m" - rm -rf /var/www/eeadmin/htdocs/db/pma || OwnError "Unable To Remove phpMyAdmin" + rm -rf /var/www/22222/htdocs/db/pma || OwnError "Unable To Remove phpMyAdmin" } REMOVEMYSQL() @@ -1279,29 +1279,29 @@ PERMISSIONANDGIT() EEOPMEMCACHE() { # Opcache Settings - if [ ! -d /var/www/eeadmin/htdocs/php/opcache ] + if [ ! -d /var/www/22222/htdocs/php/opcache ] then - mkdir -p /var/www/eeadmin/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" + mkdir -p /var/www/22222/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" # Download Opcache Status Files - wget -cqO /var/www/eeadmin/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php - wget -cqO /var/www/eeadmin/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php - wget -cqO /var/www/eeadmin/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php + wget -cqO /var/www/22222/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php + wget -cqO /var/www/22222/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php + wget -cqO /var/www/22222/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php fi # Memcache Settings - if [ ! -d /var/www/eeadmin/htdocs/php/memcache ] + if [ ! -d /var/www/22222/htdocs/php/memcache ] then - mkdir -p /var/www/eeadmin/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" + mkdir -p /var/www/22222/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" # Download phpMemcachedAdmin - wget -cqO /var/www/eeadmin/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz + wget -cqO /var/www/22222/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz # Extract phpMemcachedAdmin - tar -zxf /var/www/eeadmin/htdocs/php/memcache/memcache.tar.gz -C /var/www/eeadmin/htdocs/php/memcache + tar -zxf /var/www/22222/htdocs/php/memcache/memcache.tar.gz -C /var/www/22222/htdocs/php/memcache # Remove Unwanted Files - rm -f /var/www/eeadmin/htdocs/php/memcache/memcache.tar.gz + rm -f /var/www/22222/htdocs/php/memcache/memcache.tar.gz fi } @@ -1627,13 +1627,13 @@ DEBUG_PHP() echo -e "\033[34mXdebug Already Enabled\e[0m" fi - if [ ! -d /var/www/eeadmin/htdocs/php/webgrind/ ] + if [ ! -d /var/www/22222/htdocs/php/webgrind/ ] then # Webgrind Install - mkdir -p mkdir -p /var/www/eeadmin/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory: /var/www/eeadmin/htdocs/php/webgrind/" + mkdir -p mkdir -p /var/www/22222/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory: /var/www/22222/htdocs/php/webgrind/" echo -e "\033[34mCloning webgrind, Please Wait...\e[0m" - git clone https://github.com/jokkedk/webgrind.git /var/www/eeadmin/htdocs/php/webgrind/ - sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/eeadmin/htdocs/php/webgrind/config.php + git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ + sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php # Install Graphviz dpkg -l | grep graphviz &>> $INSTALLLOG @@ -1968,7 +1968,7 @@ then INSTALLPMA # Initialise Git - #EEGITDIR=/var/www/eeadmin/htdocs/db/pma/ + #EEGITDIR=/var/www/22222/htdocs/db/pma/ #EEGITINIT # Display Success Message @@ -2058,7 +2058,7 @@ then EEGITINIT # Initialize Git - #EEGITDIR=/var/www/eeadmin/htdocs/db/pma/ + #EEGITDIR=/var/www/22222/htdocs/db/pma/ #EEGITINIT # Initialize Git @@ -2566,7 +2566,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display Success Message echo @@ -2590,7 +2590,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2621,7 +2621,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2652,7 +2652,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2688,7 +2688,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display Success Message echo @@ -2712,7 +2712,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2743,7 +2743,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo @@ -2774,7 +2774,7 @@ then PERMISSIONANDGIT # Setup phpMyAdmin - #ln -s /var/www/eeadmin/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma + #ln -s /var/www/22222/htdocs/db/pma /var/www/$DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo diff --git a/usr/share/easyengine/nginx/22222 b/usr/share/easyengine/nginx/22222 new file mode 100644 index 00000000..59ae9cb8 --- /dev/null +++ b/usr/share/easyengine/nginx/22222 @@ -0,0 +1,40 @@ +# EasyEngine Admin Configuration +server { + + listen 22222 default_server ssl spdy; + + access_log /var/log/nginx/eeadmin.access.log rt_cache; + error_log /var/log/nginx/eeadmin.error.log; + + ssl_certificate /var/www/22222/cert/22222.crt; + ssl_certificate_key /var/www/22222/cert/22222.key; + + # Force HTTP To HTTPS + error_page 497 =200 https://$host:22222$request_uri; + + root /var/www/eeadmin/htdocs; + index index.php index.htm index.html; + + # Turn On Directory List + autoindex on; + + location / { + include common/acl.conf; + try_files $uri $uri/ /index.php?$args; + } + + location = /php/status/ {} + + location ~ /php/status/(.*) { + include fastcgi_params; + fastcgi_param SCRIPT_NAME /status; + fastcgi_pass $1; + } + + location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; + } + +} From af85799a1bd2d50c7351aaf1e0baac6d00964697 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 9 Apr 2014 16:33:33 +0530 Subject: [PATCH 34/50] Copy 22222 Nginx Conf File In /etc/nginx --- usr/local/sbin/easyengine | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 542eff71..606914b0 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -274,7 +274,11 @@ COMMONNGINX() EEDEST="/etc/nginx/common" EEMD5SUM - # EEAdmin SSL Setup + # EasyEngine Admin Setup + cp -v /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ || OwnError "Unable To Copy 22222 Nginx Configuration File" + ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/ || OwnError "Unable To Create Symbolic Link For 22222 Nginx Configuration" + + # EasyEngine Admin SSL Setup if [ ! -d /var/www/22222/cert ] then mkdir -p /var/www/22222/cert || OwnError "Unable To Create /var/www/22222/cert" From e401f3ed76369c271eed542e2901ec8615f1c2f5 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 9 Apr 2014 17:19:57 +0530 Subject: [PATCH 35/50] Fixed ee site edit command --- usr/local/sbin/easyengine | 4 ++-- usr/share/easyengine/nginx/22222 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 606914b0..809ee94a 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -275,7 +275,7 @@ COMMONNGINX() EEMD5SUM # EasyEngine Admin Setup - cp -v /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ || OwnError "Unable To Copy 22222 Nginx Configuration File" + cp /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ || OwnError "Unable To Copy 22222 Nginx Configuration File" ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/ || OwnError "Unable To Create Symbolic Link For 22222 Nginx Configuration" # EasyEngine Admin SSL Setup @@ -2890,7 +2890,7 @@ then # Edit The Nginx Configuration For $DOMAIN EESITEEDIT - if [ $(git status -s /etc/nginx/sites-available/$DOMAIN | wc -l) -ne 0 ] + if [ $(cd /etc/nginx; git status -s /etc/nginx/sites-available/$DOMAIN | wc -l) -ne 0 ] then # Take Nginx Configuration In Git Version Control EEGITDIR=/etc/nginx diff --git a/usr/share/easyengine/nginx/22222 b/usr/share/easyengine/nginx/22222 index 59ae9cb8..74f89a47 100644 --- a/usr/share/easyengine/nginx/22222 +++ b/usr/share/easyengine/nginx/22222 @@ -12,7 +12,7 @@ server { # Force HTTP To HTTPS error_page 497 =200 https://$host:22222$request_uri; - root /var/www/eeadmin/htdocs; + root /var/www/22222/htdocs; index index.php index.htm index.html; # Turn On Directory List From f491736c9420e12634da405843941320885fb891 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 9 Apr 2014 17:27:39 +0530 Subject: [PATCH 36/50] Chnage debug pool name --- usr/local/sbin/easyengine | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 809ee94a..5504a316 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -371,12 +371,13 @@ COMMONPHP() sed -i "s'listen = /var/run/php5-fpm.sock'listen = 127.0.0.1:9000'" /etc/php5/fpm/pool.d/www.conf || OwnError "Unable To Change PHP Fastcgi Socket" # Separate PHP POOL For Slow Logs - cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/slowlog.conf - sed -i "s'\[www\]'[slowlog]'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Pool Name" - sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Fastcgi Listen Port" - sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Chnage Process Manager From Dynamic To Ondemand" - sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Slowlog" - sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/slowlog.conf || OwnError "Unable To Change PHP Request Slowlog Timeout" + cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/debug.conf + sed -i "s'\[www\]'[debug]'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Pool Name" + sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Fastcgi Listen Port" + sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Chnage Process Manager From Dynamic To Ondemand" + sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Slowlog" + sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Request Slowlog Timeout" + echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/xdebug \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG fi } @@ -1579,12 +1580,12 @@ DEBUG_PHP() EE_DEBUG_PHP="" # Slowlog Settings - #grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/slowlog.conf &>> $INSTALLLOG + #grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG #if [ $? -ne 0 ] #hen #echo -e "\033[34mSetting Up PHP5-FPM Slow Log, Please Wait...\e[0m" - #sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/slowlog.conf - #sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/slowlog.conf + #sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf + #sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf #else #echo -e "\033[34mPHP5-FPM Slow Log Already Enabled\e[0m" From 1e2f5b14f9b30e322629233cea09b8788053fbe3 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 9 Apr 2014 18:58:05 +0530 Subject: [PATCH 37/50] Install Debug Tools --- usr/local/sbin/easyengine | 157 ++++++++++++++++++++++++-------------- 1 file changed, 100 insertions(+), 57 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 5504a316..8d6db6a5 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -110,6 +110,15 @@ PHPREPO() fi } +PERCONA_REPO() +{ + # Fetch And Install The GnuPG Key + gpg --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && gpg --export CD2EFD2A | apt-key add - &>> $INSTALLLOG || OwnError "Unable To Add Percona GnuPG Key" + + # Add Percona Repository + echo -e "deb http://repo.percona.com/apt $(lsb_release -cs) main \ndeb-src http://repo.percona.com/apt $(lsb_release -cs) main" > /etc/apt/sources.list.d/percona.list +} + GPGKEY() { # Force GPG KEYS Check @@ -377,7 +386,8 @@ COMMONPHP() sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Chnage Process Manager From Dynamic To Ondemand" sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Slowlog" sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Request Slowlog Timeout" - echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/xdebug \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG + echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/xdebug \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG \ + || OwnError "Unable To Add Xdebug Settings" fi } @@ -402,6 +412,80 @@ WP-CLI() fi } +PHP_PACKAGES() +{ + # Opcache Settings + if [ ! -d /var/www/22222/htdocs/php/opcache ] + then + # Create Directory + mkdir -p /var/www/22222/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" + + # Download Opcache Status Files + echo -e "\033[34mInstalling Opcache Tools, Please Wait...\e[0m" + wget -cqO /var/www/22222/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php + wget -cqO /var/www/22222/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php + wget -cqO /var/www/22222/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php + fi + + # Memcache Settings + if [ ! -d /var/www/22222/htdocs/php/memcache ] + then + # Create Directory + mkdir -p /var/www/22222/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" + + # Download phpMemcachedAdmin + echo -e "\033[34mInstalling Memcache Tools, Please Wait...\e[0m" + wget -cqO /var/www/22222/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz + + # Extract phpMemcachedAdmin + tar -zxf /var/www/22222/htdocs/php/memcache/memcache.tar.gz -C /var/www/22222/htdocs/php/memcache + + # Remove Unwanted Files + rm -f /var/www/22222/htdocs/php/memcache/memcache.tar.gz + fi + + if [ ! -d /var/www/22222/htdocs/php/webgrind/ ] + then + # Download Opcache Status Files + mkdir -p mkdir -p /var/www/22222/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory" + + # Download Webgrind + echo -e "\033[34mCloning webgrind, Please Wait...\e[0m" + git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ + sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php + + # Install Graphviz + dpkg -l | grep graphviz &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "\033[34mInstalling Graphviz, Please Wait...\e[0m" + apt-get -y install graphviz || OwnError "Unable To Install Graphviz" + fi + fi + + # Create info.php File To Display The phpinfo Information + echo -e "" &>> /var/www/22222/htdocs/php/info.php + + # Fake PHP5-FPM Status Pages + if [ ! -d /var/www/22222/htdocs/php/status/ ] + then + mkdir -p /var/www/22222/htdocs/php/status/ || OwnError "Unable To Create webgrind Directory" + touch /var/www/22222/htdocs/php/status/{www,debug} + fi + + # Anemometer Setup + if [ ! -d /var/www/22222/htdocs/db/anemometer/ ] + then + mkdir -p /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Create Anemometer Directory" + + # Download Anemometer + git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $INSTALLLOG || OwnError "Unable To Clone Anemometer" + fi + + + +} + INSTALLPMA() { # Install PMA/phpMyAdmin @@ -469,7 +553,7 @@ INSTALLMYSQL() # Install MySQL echo -e "\033[34mInstalling MySQL, Please Wait...\e[0m" - $EEAPTGET install mysql-server mysqltuner \ + $EEAPTGET install mysql-server mysqltuner percona-toolkit \ || OwnError "Unable To Install MySQL" } @@ -501,7 +585,7 @@ INSTALLALL() echo -e "\033[34mInstalling Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET install $NGINXPACKAGE php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached mysql-server mysqltuner postfix \ + php5-memcache memcached mysql-server mysqltuner percona-toolkit postfix \ || OwnError "Unable To Install Nginx PHP5 MySQL Postfix" } @@ -544,7 +628,7 @@ REMOVEMYSQL() { # Remove MySQL echo -e "\033[34mRemoving MySQL, Please Wait...\e[0m" - $EEAPTGET remove mysql-server mysqltuner \ + $EEAPTGET remove mysql-server mysqltuner percona-toolkit \ || OwnError "Unable To Remove MySQL" } @@ -564,7 +648,7 @@ REMOVEALL() echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET remove $NGINXPACKAGE nginx-common php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached mysql-server mysqltuner postfix \ + php5-memcache memcached mysql-server mysqltuner percona-toolkit postfix \ || OwnError "Unable To Remove Nginx PHP5 MySQL Postfix" } @@ -600,7 +684,7 @@ PURGEMYSQL() { # Purge MySQL echo -e "\033[34mPurge MySQL, Please Wait...\e[0m" - $EEAPTGET purge mysql-server mysqltuner \ + $EEAPTGET purge mysql-server mysqltuner percona-toolkit \ || OwnError "Unable To Purge MySQL" } @@ -617,7 +701,7 @@ PURGEALL() echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m" $EEAPTGET purge $NGINXPACKAGE nginx-common php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached mysql-server mysqltuner postfix \ + php5-memcache memcached mysql-server mysqltuner percona-toolkit postfix \ || OwnError "Unable To Purge Nginx PHP5 MySQL Postfix" } @@ -1281,35 +1365,6 @@ PERMISSIONANDGIT() EEGITCOMMIT } -EEOPMEMCACHE() -{ - # Opcache Settings - if [ ! -d /var/www/22222/htdocs/php/opcache ] - then - mkdir -p /var/www/22222/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" - - # Download Opcache Status Files - wget -cqO /var/www/22222/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php - wget -cqO /var/www/22222/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php - wget -cqO /var/www/22222/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php - fi - - # Memcache Settings - if [ ! -d /var/www/22222/htdocs/php/memcache ] - then - mkdir -p /var/www/22222/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" - - # Download phpMemcachedAdmin - wget -cqO /var/www/22222/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz - - # Extract phpMemcachedAdmin - tar -zxf /var/www/22222/htdocs/php/memcache/memcache.tar.gz -C /var/www/22222/htdocs/php/memcache - - # Remove Unwanted Files - rm -f /var/www/22222/htdocs/php/memcache/memcache.tar.gz - fi -} - TOTALCACHENGINX() { # Installing W3 Total Cache @@ -1319,9 +1374,6 @@ TOTALCACHENGINX() # Activate W3 Total Cache wp plugin --allow-root activate w3-total-cache $NETWORKACTIVATE &>> $INSTALLLOG || OwnError "Unable To Activate W3 Total Cache Plugin" - - # Install Opcache & Memcache - EEOPMEMCACHE } SUPERCACHENGINX() @@ -1631,24 +1683,6 @@ DEBUG_PHP() else echo -e "\033[34mXdebug Already Enabled\e[0m" fi - - if [ ! -d /var/www/22222/htdocs/php/webgrind/ ] - then - # Webgrind Install - mkdir -p mkdir -p /var/www/22222/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory: /var/www/22222/htdocs/php/webgrind/" - echo -e "\033[34mCloning webgrind, Please Wait...\e[0m" - git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ - sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php - - # Install Graphviz - dpkg -l | grep graphviz &>> $INSTALLLOG - if [ $? -ne 0 ] - then - echo -e "\033[34mInstalling Graphviz, Please Wait...\e[0m" - APTASSUMEYES - $EEAPTGET install graphviz || OwnError "Unable To Install Graphviz" - fi - fi } DEBUG_PHP_STOP() @@ -1982,6 +2016,12 @@ then elif [ "$3" = "mysql" ] then + # Add Percona Repository + PERCONA_REPO + + # Fix GPG Key Problems + GPGKEY + # Update The APT Cache UPDATEAPT @@ -2023,6 +2063,9 @@ then # Add PHP Launchpad Repository PHPREPO + # Add Percona Repository + PERCONA_REPO + # Fix GPG Key Problems GPGKEY From 2c0a89771d4e02bee8e9027c9ff30a00bff75e74 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 10 Apr 2014 12:02:22 +0530 Subject: [PATCH 38/50] Do Not Modify Notice --- etc/nginx/common/locations.conf | 1 + etc/nginx/common/wpcommon.conf | 1 + 2 files changed, 2 insertions(+) diff --git a/etc/nginx/common/locations.conf b/etc/nginx/common/locations.conf index f03551b6..287f6a66 100644 --- a/etc/nginx/common/locations.conf +++ b/etc/nginx/common/locations.conf @@ -1,3 +1,4 @@ +# DO NOT MODIFIED ALL CHNAGES LOST AFTER UPDATE EasyEngine # Common Locations diff --git a/etc/nginx/common/wpcommon.conf b/etc/nginx/common/wpcommon.conf index a5ec0023..8dffc405 100644 --- a/etc/nginx/common/wpcommon.conf +++ b/etc/nginx/common/wpcommon.conf @@ -1,3 +1,4 @@ +# DO NOT MODIFIED ALL CHNAGES LOST AFTER UPDATE EasyEngine # WordPress Common Settings From 948b4ab5ad2bd84d403688da327234c6bd6ef83e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 10 Apr 2014 14:22:11 +0530 Subject: [PATCH 39/50] Fix Major Debug Release --- etc/nginx/conf.d/upstream.conf | 5 ++ usr/local/sbin/easyengine | 110 ++++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 24 deletions(-) diff --git a/etc/nginx/conf.d/upstream.conf b/etc/nginx/conf.d/upstream.conf index 7c965d7a..4645e69d 100644 --- a/etc/nginx/conf.d/upstream.conf +++ b/etc/nginx/conf.d/upstream.conf @@ -3,3 +3,8 @@ upstream php { # server unix:/run/php5-fpm.sock; server 127.0.0.1:9000; } + +upstream debug { + # Debug Pool + server 127.0.0.1:9001; +} diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 8d6db6a5..7f1f91b5 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -110,14 +110,15 @@ PHPREPO() fi } -PERCONA_REPO() -{ - # Fetch And Install The GnuPG Key - gpg --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && gpg --export CD2EFD2A | apt-key add - &>> $INSTALLLOG || OwnError "Unable To Add Percona GnuPG Key" +# PERCONA_REPO() +# { +# # Fetch And Install The GnuPG Key +# gpg --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A &>> $INSTALLLOG || OwnError "Unable To Fetch Percona GnuPG Key" +# gpg --export CD2EFD2A | apt-key add - &>> $INSTALLLOG || OwnError "Unable To Add Percona GnuPG Key" - # Add Percona Repository - echo -e "deb http://repo.percona.com/apt $(lsb_release -cs) main \ndeb-src http://repo.percona.com/apt $(lsb_release -cs) main" > /etc/apt/sources.list.d/percona.list -} +# # Add Percona Repository +# echo -e "deb http://repo.percona.com/apt $(lsb_release -cs) main \ndeb-src http://repo.percona.com/apt $(lsb_release -cs) main" > /etc/apt/sources.list.d/percona.list +# } GPGKEY() { @@ -287,6 +288,16 @@ COMMONNGINX() cp /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ || OwnError "Unable To Copy 22222 Nginx Configuration File" ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/ || OwnError "Unable To Create Symbolic Link For 22222 Nginx Configuration" + # EasyEngine Admin Logs Setup + if [ ! -d /var/www/22222/logs ] + then + mkdir -p /var/www/22222/logs || OwnError "Unable To Create /var/www/22222/logs" + fi + + # Symbolic Links + ln -s /var/log/nginx/eeadmin.access.log /var/www/22222/logs/access.log + ln -s /var/log/nginx/eeadmin.error.log /var/www/22222/logs/error.log + # EasyEngine Admin SSL Setup if [ ! -d /var/www/22222/cert ] then @@ -351,6 +362,8 @@ COMMONPHP() if [ $? -ne 0 ] then + TIME_ZONE=$(cat /etc/timezone | sed "s'/'\\\/'") + # Move PHP’s Session Storage To Memcache sed -i "/extension/a \session.save_handler = memcache\nsession.save_path = \"tcp://localhost:11211\"" /etc/php5/mods-available/memcache.ini @@ -360,6 +373,7 @@ COMMONPHP() sed -i "s/post_max_size.*/post_max_size = 100M/" /etc/php5/fpm/php.ini sed -i "s/upload_max_filesize.*/upload_max_filesize = 100M/" /etc/php5/fpm/php.ini sed -i "s/max_execution_time.*/max_execution_time = 300/" /etc/php5/fpm/php.ini + sed -i "s/;date.timezone.*/date.timezone = $TIME_ZONE/" /etc/php5/fpm/php.ini # Change PHP5-FPM Error Logs Location sed -i "s'error_log.*'error_log = /var/log/php5/fpm.log'" /etc/php5/fpm/php-fpm.conf @@ -386,7 +400,7 @@ COMMONPHP() sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Chnage Process Manager From Dynamic To Ondemand" sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Slowlog" sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Request Slowlog Timeout" - echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/xdebug \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG \ + echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG \ || OwnError "Unable To Add Xdebug Settings" fi } @@ -408,7 +422,7 @@ WP-CLI() cp -i /usr/share/easyengine/wp-cli/vendor/wp-cli/wp-cli/utils/wp-completion.bash /etc/bash_completion.d/ source /etc/bash_completion.d/wp-completion.bash else - echo -e "\033[34mAlready Installed WP-CLI (/usr/share/easyengine/wp-cli)...\e[0m" + echo -e "\033[34mAlready Installed WP-CLI (/usr/share/easyengine/wp-cli)\e[0m" fi } @@ -451,7 +465,7 @@ PHP_PACKAGES() # Download Webgrind echo -e "\033[34mCloning webgrind, Please Wait...\e[0m" - git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ + git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ &>> $INSTALLLOG || OwnError "Unable To Clone Webgrind" sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php # Install Graphviz @@ -470,7 +484,7 @@ PHP_PACKAGES() if [ ! -d /var/www/22222/htdocs/php/status/ ] then mkdir -p /var/www/22222/htdocs/php/status/ || OwnError "Unable To Create webgrind Directory" - touch /var/www/22222/htdocs/php/status/{www,debug} + touch /var/www/22222/htdocs/php/status/{php,debug} fi # Anemometer Setup @@ -479,11 +493,35 @@ PHP_PACKAGES() mkdir -p /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Create Anemometer Directory" # Download Anemometer - git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $INSTALLLOG || OwnError "Unable To Clone Anemometer" - fi + git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $INSTALLLOG \ + || OwnError "Unable To Clone Anemometer" + # Setup Anemometer + # Collect MySQL Login Details + MYSQLROOT + + # Setup Anemometer Database + mysql -u $MYSQLUSER -p$MYSQLPASS < /var/www/22222/htdocs/db/anemometer/install.sql \ + || OwnError "Unable To Import Anemometer Database" + + # Setup Anemometer Database Grants + ANEMOMETERPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) + mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';" + + # Put Data In Anemometer Database + pt-query-digest --user=anemometer --password=$ANEMOMETERPASS --review D=slow_query_log,t=global_query_review --history D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG + # Copy Anemometer Configuration File + cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ + || OwnError "Unable To Copy Anemometer Configuration File" + + fi + + # Call PHPUSERINFO Function For PHP User Details + PHPUSERINFO + # Change Ownership + chown -R $PHPUSER:$PHPUSER /var/www/22222/htdocs || OwnError "Unable To Change Ownership For /var/www/22222/htdocs" } INSTALLPMA() @@ -557,6 +595,15 @@ INSTALLMYSQL() || OwnError "Unable To Install MySQL" } +COMMONMYSQL() +{ + # Personal Settings For MySQL + echo -e "\033[34mUpdating MySQL Configuration Files, Please Wait...\e[0m" + + # Decrease MySQL Wait Timeout + sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60/" /etc/mysql/my.cnf +} + POSTFIXINSTALLTWEAKS() { # Setting Up Postfix @@ -1122,21 +1169,21 @@ PHPSTART() { # Start PHP5-FPM Service echo -e "\033[34mStarting PHP5-FPM Service, Please Wait...\e[0m" - service php5-fpm start &>> $INSTALLLOG || OwnError "Unable To Start PHP5-FPM" + (php5-fpm -t && service php5-fpm start) &>> $INSTALLLOG || OwnError "Unable To Start PHP5-FPM" } PHPRELOAD() { # Reload PHP5-FPM Service echo -e "\033[34mReloading PHP5-FPM Service, Please Wait...\e[0m" - service php5-fpm reload &>> $INSTALLLOG || OwnError "Unable To Reloading PHP5-FPM" + (php5-fpm -t && service php5-fpm reload) &>> $INSTALLLOG || OwnError "Unable To Reloading PHP5-FPM" } PHPRESTART() { # Restart PHP5-FPM Service echo -e "\033[34mRestarting PHP5-FPM Service, Please Wait...\e[0m" - service php5-fpm restart &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM" + (php5-fpm -t && service php5-fpm restart) &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM" } MYSQLSTART() @@ -1492,13 +1539,14 @@ REMOVENGINXCONF() DEBUG_NGINX() { + # Lets Disable Nginx Reload Trigger + EE_DEBUG_NGINX="" + if [ -z "$EE_IP_ADDRESS" ] then - read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS + #read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS + EE_IP_ADDRESS="0.0.0.0/0" fi - - # Lets Disable Nginx Reload Trigger - EE_DEBUG_NGINX="" for DEBUG_IP_ADDRESS in $(echo $EE_IP_ADDRESS) do @@ -1990,8 +2038,9 @@ then # Restart PHP To Take Effect Of COMMONPHP Functions PHPRESTART - # Install WP-CLI + # Install WP-CLI & PHP Packages WP-CLI + PHP_PACKAGES # Initialise Git EEGITDIR=/etc/php5/ @@ -2017,7 +2066,7 @@ then then # Add Percona Repository - PERCONA_REPO + #PERCONA_REPO # Fix GPG Key Problems GPGKEY @@ -2028,6 +2077,12 @@ then # Install MySQL INSTALLMYSQL + # Personal Settings For MySQL + COMMONMYSQL + + # Restart MySQL + MYSQLRESTART + # Initialize Git EEGITDIR=/etc/mysql/ EEGITINIT @@ -2064,7 +2119,7 @@ then PHPREPO # Add Percona Repository - PERCONA_REPO + #PERCONA_REPO # Fix GPG Key Problems GPGKEY @@ -2087,12 +2142,19 @@ then # Restart PHP To Take Effect Of COMMONPHP Functions PHPRESTART - # Install WP-CLI + # Install WP-CLI & PHP Packages WP-CLI + PHP_PACKAGES # Install PMA/phpMyAdmin INSTALLPMA + # Personal Settings For MySQL + COMMONMYSQL + + # Restart MySQL + MYSQLRESTART + # Initialize Git EEGITDIR=/etc/nginx/ EEGITINIT From c73d440b9ccf4ce4aa15dc3f0e90c343b4328364 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 10 Apr 2014 14:40:17 +0530 Subject: [PATCH 40/50] Fix Minor Changes And Version --- usr/local/sbin/easyengine | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 7f1f91b5..8b14a573 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -435,7 +435,7 @@ PHP_PACKAGES() mkdir -p /var/www/22222/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" # Download Opcache Status Files - echo -e "\033[34mInstalling Opcache Tools, Please Wait...\e[0m" + echo -e "\033[34mInstalling Opcache Tool, Please Wait...\e[0m" wget -cqO /var/www/22222/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php wget -cqO /var/www/22222/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php wget -cqO /var/www/22222/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php @@ -448,7 +448,7 @@ PHP_PACKAGES() mkdir -p /var/www/22222/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" # Download phpMemcachedAdmin - echo -e "\033[34mInstalling Memcache Tools, Please Wait...\e[0m" + echo -e "\033[34mInstalling Memcache Tool, Please Wait...\e[0m" wget -cqO /var/www/22222/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz # Extract phpMemcachedAdmin @@ -521,7 +521,7 @@ PHP_PACKAGES() PHPUSERINFO # Change Ownership - chown -R $PHPUSER:$PHPUSER /var/www/22222/htdocs || OwnError "Unable To Change Ownership For /var/www/22222/htdocs" + chown -R $PHPUSER:$PHPUSER /var/www/22222 || OwnError "Unable To Change Ownership For /var/www/22222" } INSTALLPMA() @@ -601,7 +601,7 @@ COMMONMYSQL() echo -e "\033[34mUpdating MySQL Configuration Files, Please Wait...\e[0m" # Decrease MySQL Wait Timeout - sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60/" /etc/mysql/my.cnf + sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf } POSTFIXINSTALLTWEAKS() @@ -1955,7 +1955,7 @@ if [ "$1" = "version" ] || [ "$1" = "--version" ] || [ "$1" = "-v" ] then # Display Easy Engine Version - echo "easyengine version: 1.2.2" + echo "easyengine version: 1.2.3" # Easy Engine Info elif [ "$1" = "info" ] From 82b35f314aac559a968b5f3a669d22b0ef7a5f69 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 10 Apr 2014 15:22:26 +0530 Subject: [PATCH 41/50] Fix Anemometer --- usr/local/sbin/easyengine | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 8b14a573..1599a2e6 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -331,7 +331,7 @@ COMMONNGINX() sed -i "/deny/i $(echo allow $WHITELIST_IP_ADDRESS\;)" /etc/nginx/common/acl.conf done else - echo -e "\033[34mEasyEngine Don't Find IP Address in /etc/easyengine/ee.conf file\e[0m" + echo -e "\033[34mEasyEngine (ee) Don't Find IP Address in /etc/easyengine/ee.conf file\e[0m" fi # Protect EE Locations @@ -464,7 +464,7 @@ PHP_PACKAGES() mkdir -p mkdir -p /var/www/22222/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory" # Download Webgrind - echo -e "\033[34mCloning webgrind, Please Wait...\e[0m" + echo -e "\033[34mCloning Webgrind, Please Wait...\e[0m" git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ &>> $INSTALLLOG || OwnError "Unable To Clone Webgrind" sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php @@ -509,12 +509,16 @@ PHP_PACKAGES() mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';" # Put Data In Anemometer Database - pt-query-digest --user=anemometer --password=$ANEMOMETERPASS --review D=slow_query_log,t=global_query_review --history D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG + pt-query-digest --user=anemometer --password=$ANEMOMETERPASS --review D=slow_query_log,t=global_query_review --review-history D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG # Copy Anemometer Configuration File cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ || OwnError "Unable To Copy Anemometer Configuration File" + # Update Anemoneter Configuration File + sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php + sed -i "/password/ s/''/'$ANEMOMETERPASS'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php + fi # Call PHPUSERINFO Function For PHP User Details @@ -527,7 +531,7 @@ PHP_PACKAGES() INSTALLPMA() { # Install PMA/phpMyAdmin - if [ ! -d /var/www/22222/htdocs/db ] + if [ ! -d /var/www/22222/htdocs/db/pma ] || [ ! -d /var/www/22222/htdocs/db/adminer ] then if [ ! -d /var/www/22222/htdocs/db/pma ] then From 0396d12f0dff30c76678cc88ed1d7ed5edcde7c4 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 10 Apr 2014 19:04:35 +0530 Subject: [PATCH 42/50] Anemometer Logroation Fix --- usr/local/sbin/easyengine | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 1599a2e6..10bd25ab 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -509,7 +509,20 @@ PHP_PACKAGES() mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';" # Put Data In Anemometer Database - pt-query-digest --user=anemometer --password=$ANEMOMETERPASS --review D=slow_query_log,t=global_query_review --review-history D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG + pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \ + --review D=slow_query_log,t=global_query_review \ + --review-history D=slow_query_log,t=global_query_review_history \ + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG + + # Execute On MySQL Logrotation + ANEMOMETERLOG=$(echo "pt-query-digest --user=anemometer --password=$ANEMOMETERPASS --review D=slow_query_log,t=global_query_review --review-history D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event-\>{Bytes} = length\(\$event-\>{arg}\) and \$event-\>{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &> /dev/null 2>&1") + sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server + echo -e " pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \\" >> /etc/logrotate.d/mysql-server + echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server + echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server + echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"\$HOSTNAME\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server + echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server + echo -e "}" >> /etc/logrotate.d/mysql-server # Copy Anemometer Configuration File cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ From cfe0d4c9faf9ce021e51b26459e519413faea66c Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 10 Apr 2014 19:07:27 +0530 Subject: [PATCH 43/50] Anemometer Logroation Fix --- usr/local/sbin/easyengine | 1 - 1 file changed, 1 deletion(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 10bd25ab..290d404d 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -515,7 +515,6 @@ PHP_PACKAGES() --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG # Execute On MySQL Logrotation - ANEMOMETERLOG=$(echo "pt-query-digest --user=anemometer --password=$ANEMOMETERPASS --review D=slow_query_log,t=global_query_review --review-history D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event-\>{Bytes} = length\(\$event-\>{arg}\) and \$event-\>{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &> /dev/null 2>&1") sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server echo -e " pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \\" >> /etc/logrotate.d/mysql-server echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server From 4eb427f5331b924c0742774375393653fe128576 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 11:59:55 +0530 Subject: [PATCH 44/50] Fixed Issue #171 --- usr/local/sbin/easyengine | 70 +++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 290d404d..8912f818 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1895,23 +1895,36 @@ DEBUG_MYSQL_STOP() DEBUG_WORDPRESS() { - grep "'WP_DEBUG'" /var/www/$DOMAIN/wp-config.php | grep true &>> $INSTALLLOG - if [ $? -ne 0 ] + if [ -e /var/www/$DOMAIN/wp-config.php ] then - # Debug WordPress - echo -e "\033[34mStart WordPress Debug Logs For $DOMAIN\e[0m" - # Call PHPUSERINFO Function For PHP User Details - PHPUSERINFO + grep "'WP_DEBUG'" /var/www/$DOMAIN/wp-config.php | grep true &>> $INSTALLLOG + if [ $? -ne 0 ] + then + # Debug WordPress + echo -e "\033[34mStart WordPress Debug Logs For $DOMAIN\e[0m" + + # Call PHPUSERINFO Function For PHP User Details + PHPUSERINFO - # Create debug.log & Change Permission - touch /var/www/$DOMAIN/htdocs/wp-content/debug.log - chown $PHPUSER:$PHPUSER /var/www/$DOMAIN/htdocs/wp-content/debug.log + # Create debug.log & Change Permission + touch /var/www/$DOMAIN/htdocs/wp-content/debug.log + chown $PHPUSER:$PHPUSER /var/www/$DOMAIN/htdocs/wp-content/debug.log - # Turn On Debug - sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php + # Turn On Debug + sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$DOMAIN/wp-config.php + + # Install Developer Plugin + # Installing Nginx Helper + cd /var/www/$DOMAIN/htdocs/ + echo -e "\033[34mInstalling Developer Plugin, Please Wait...\e[0m" + wp plugin --allow-root install developer &>> $INSTALLLOG || OwnError "Unable To Install Developer Plugin" + + else + echo -e "\033[34mWordPress Debug Log Already Started For $DOMAIN\e[0m" + fi else - echo -e "\033[34mWordPress Debug Log Already Started For $DOMAIN\e[0m" + echo -e "\033[31mUnable To Find wp-config.php File, Seems Like Not WordPress Site\e[0m" fi } @@ -3083,12 +3096,23 @@ then then # Debug Nginx DEBUG_NGINX + + # Log Message + LOGMESSAGE="/var/log/nginx/*.error.log" fi if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs DEBUG_NGINX_REWRITE + + # Log Message + LOGMESSAGE="$LOGMESSAGE /var/log/nginx/*.error.log" + fi + + if [ "$EE_DEBUG_WP" = "--wp" ] + then + echo -e "\033[31mThe --wp Option Can Be Enabled For WordPress Site Only\e[0m" fi else @@ -3101,18 +3125,27 @@ then then # Debug Nginx DEBUG_NGINX_SITE + + # Log Message + LOGMESSAGE="/var/www/$DOMAIN/logs/error.log" fi if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs DEBUG_NGINX_REWRITE_SITE + + # Log Message + LOGMESSAGE="$LOGMESSAGE /var/log/$DOMAIN/logs/error.log" fi if [ "$EE_DEBUG_WP" = "--wp" ] then # Debug WordPress Debug Log DEBUG_WORDPRESS + + # Log Message + LOGMESSAGE="$LOGMESSAGE /var/log/$DOMAIN/htdocs/wp-content/debug.log" fi fi @@ -3121,18 +3154,27 @@ then then # Debug PHP DEBUG_PHP + + # Log Message + LOGMESSAGE="$LOGMESSAGE /var/log/php5/slow.log" fi if [ "$EE_DEBUG_FPM" = "--fpm" ] then # Debug PHP FPM DEBUG_PHP_FPM + + # Log Message + LOGMESSAGE="$LOGMESSAGE /var/log/php5/fpm.log" fi if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then # Debug MySQL Slow Query DEBUG_MYSQL + + # Log Message + LOGMESSAGE="$LOGMESSAGE /var/log/mysql/slow.log" fi elif [ "$EE_DEBUG" = "--stop" ] @@ -3232,10 +3274,12 @@ then then # Lets Start Debug In Interactive Mode DEBUG_INTERACTIVE + elif [ "$EE_DEBUG_INTERACTIVE" != "-i" ] && [ "$EE_DEBUG" != "--stop" ] + then + echo -e "\033[37mtail -f $LOGMESSAGE\e[0m" fi - elif [ "$1" = "update" ] then From 5bc3d7513e111080eedfbd2e2d2e41af0a090e30 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 12:30:11 +0530 Subject: [PATCH 45/50] Fixed PHP Pool Changes --- usr/local/sbin/easyengine | 77 +++++++-------------------------------- 1 file changed, 14 insertions(+), 63 deletions(-) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 8912f818..86cf4f22 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -1695,25 +1695,13 @@ DEBUG_PHP() # Lets Disable PHP Restart Trigger EE_DEBUG_PHP="" - # Slowlog Settings - #grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG - #if [ $? -ne 0 ] - #hen - #echo -e "\033[34mSetting Up PHP5-FPM Slow Log, Please Wait...\e[0m" - #sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf - #sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf - - #else - #echo -e "\033[34mPHP5-FPM Slow Log Already Enabled\e[0m" - #fi - if [ -z $EE_DEBUG_SITENAME ] then - grep 9001 /etc/nginx/conf.d/upstream.conf &>> $INSTALLLOG + grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $INSTALLLOG if [ $? -ne 0 ] then echo -e "\033[34mEnable PHP5-FPM Slow Log, Please Wait...\e[0m" - sed -i "s/9000/9001/" /etc/nginx/conf.d/upstream.conf + sed -i "4 s/9000/9001/" /etc/nginx/conf.d/upstream.conf # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" @@ -1725,7 +1713,7 @@ DEBUG_PHP() if [ $? -ne 0 ] then echo -e "\033[34mEnable PHP5-FPM Slow Log For $DOMAIN, Please Wait...\e[0m" - sed -i "s/fastcgi_pass.*/fastcgi_pass 127.0.0.1:9001;/g" /etc/nginx/sites-available/$DOMAIN + sed -i "s/fastcgi_pass.*/fastcgi_pass debug;/g" /etc/nginx/sites-available/$DOMAIN # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" @@ -1733,20 +1721,6 @@ DEBUG_PHP() echo -e "\033[34mPHP5-FPM Slow Log Already Enabled For $DOMAIN\e[0m" fi fi - - # Xdebug Settings - grep xdebug.profiler_ /etc/php5/fpm/conf.d/20-xdebug.ini &>> $INSTALLLOG - if [ $? -ne 0 ] - then - echo -e "\033[34mSetting Up Xdebug, Please Wait...\e[0m" - echo -e "xdebug.profiler_output_dir=/tmp \nxdebug.profiler_output_name=cachegrind.out.%p-%H-%R \nxdebug.profiler_enable_trigger=1 \nxdebug.profiler_enable=0" >> /etc/php5/fpm/conf.d/20-xdebug.ini - - # Lets Trigger The PHP5-FPM Restart - EE_DEBUG_PHP="--php" - - else - echo -e "\033[34mXdebug Already Enabled\e[0m" - fi } DEBUG_PHP_STOP() @@ -1754,28 +1728,13 @@ DEBUG_PHP_STOP() # Lets Disable PHP Restart Trigger EE_DEBUG_PHP="" - # Slowlog Settings - #grep "^slowlog = /var/log/php5/slow.log" /etc/php5/fpm/pool.d/www.conf &>> $INSTALLLOG - #if [ $? -eq 0 ] - #then - #echo -e "\033[34mStopping Up PHP5-FPM Slow Log, Please Wait...\e[0m" - #sed -i "s'slowlog =';slowlog ='" /etc/php5/fpm/pool.d/www.conf - #sed -i "s'request_slowlog_timeout';request_slowlog_timeout'" /etc/php5/fpm/pool.d/www.conf - - # Lets Trigger The PHP5-FPM Restart - #EE_DEBUG_PHP="--php" - - #else - #echo -e "\033[34mPHP5-FPM Slow Log Already Disable\e[0m" - #fi - if [ -z $EE_DEBUG_SITENAME ] then - grep 9001 /etc/nginx/conf.d/upstream.conf &>> $INSTALLLOG + grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $INSTALLLOG if [ $? -eq 0 ] then echo -e "\033[34mDisable PHP5-FPM Slow Log, Please Wait...\e[0m" - sed -i "s/9001/9000/" /etc/nginx/conf.d/upstream.conf + sed -i "4 s/9001/9000/" /etc/nginx/conf.d/upstream.conf # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" @@ -1783,7 +1742,7 @@ DEBUG_PHP_STOP() echo -e "\033[34mPHP5-FPM Slow Log Already Disabled\e[0m" fi else - grep 9001 /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG + grep "fastcgi_pass debug;" /etc/nginx/sites-available/$DOMAIN &>> $INSTALLLOG if [ $? -eq 0 ] then echo -e "\033[34mDisable PHP5-FPM Slow Log For $DOMAIN, Please Wait...\e[0m" @@ -1795,20 +1754,6 @@ DEBUG_PHP_STOP() echo -e "\033[34mPHP5-FPM Slow Log Already Disabled For $DOMAIN\e[0m" fi fi - - # Xdebug Settings - grep xdebug.profiler_ /etc/php5/fpm/conf.d/20-xdebug.ini &>> $INSTALLLOG - if [ $? -eq 0 ] - then - echo -e "\033[34mDisable Xdebug, Please Wait...\e[0m" - sed -i "/xdebug.profiler_/d" /etc/php5/fpm/conf.d/20-xdebug.ini - - # Lets Trigger The PHP5-FPM Restart - EE_DEBUG_PHP="--php" - - else - echo -e "\033[34mXdebug Already Disable\e[0m" - fi } DEBUG_PHP_FPM() @@ -3079,6 +3024,7 @@ then if [ "$EE_DEBUG" = "--start" ] then + if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ] then EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $INSTALLLOG @@ -3086,8 +3032,13 @@ then EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $INSTALLLOG EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $INSTALLLOG EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $INSTALLLOG - EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG - fi + + if [ -n "$EE_DEBUG_SITENAME" ] + then + EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $INSTALLLOG + fi + fi + if [ -z "$EE_DEBUG_SITENAME" ] then From e5c365c10bb134f77eef88d7fc84865c7999bbd5 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 13:03:43 +0530 Subject: [PATCH 46/50] Debug Autocompletion --- etc/bash_completion.d/ee | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/etc/bash_completion.d/ee b/etc/bash_completion.d/ee index c1e01d9d..bf800c4b 100644 --- a/etc/bash_completion.d/ee +++ b/etc/bash_completion.d/ee @@ -18,7 +18,7 @@ EEAUTO() # List Of Suggested Words easyengine|ee) - COMPREPLY=( $(compgen -W "version info update help system site" -- $CURRENT) ) + COMPREPLY=( $(compgen -W "version info update help system site debug" -- $CURRENT) ) return 0 ;; @@ -32,6 +32,41 @@ EEAUTO() return 0 ;; + debug) + COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --mysql --wp --stop" -- $CURRENT) ) + return 0 + ;; + + --nginx) + COMPREPLY=( $(compgen -W "--rewrite --php --fpm --mysql --wp --stop" -- $CURRENT) ) + return 0 + ;; + + --rewrite) + COMPREPLY=( $(compgen -W "--nginx --php --fpm --mysql --wp --stop" -- $CURRENT) ) + return 0 + ;; + + --php) + COMPREPLY=( $(compgen -W "--nginx --rewrite --fpm --mysql --wp --stop" -- $CURRENT) ) + return 0 + ;; + + --fpm) + COMPREPLY=( $(compgen -W "--nginx --rewrite --php --mysql --wp --stop" -- $CURRENT) ) + return 0 + ;; + + --mysql) + COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --wp --stop" -- $CURRENT) ) + return 0 + ;; + + --wp) + COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --mysql --stop" -- $CURRENT) ) + return 0 + ;; + site) COMPREPLY=( $( compgen -W "list show info create enable disable delete edit" -- $CURRENT ) ) return 0 @@ -42,7 +77,7 @@ EEAUTO() return 0 ;; - show|enable|delete) + show|enable|delete|--stop) COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) ) return 0 ;; From 29cafe042ac83b6f2a623d9345dd29d0c5dee10d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 13:26:44 +0530 Subject: [PATCH 47/50] Add debug in help --- usr/local/sbin/easyengine | 1 + 1 file changed, 1 insertion(+) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index 86cf4f22..c43805f0 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -3243,6 +3243,7 @@ else echo -e "\tinfo:\t Display Nginx PHP MySQL Information\t" echo -e "\thelp:\t Display EasyEngine Help\t" echo -e "\tsite:\t Do Various Site Specific Operations\t" + echo -e "\tdebug:\t Do Various Debugging Operations\t" echo -e "\tsystem:\t Do Various System Level Operations\t" echo -e "\tupdate:\t Update EasyEngine (ee)\t" echo -e "\tversion: Display EasyEngine (ee) Version\t" From aee932d411d234996f9c150919a137fa6585d57f Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 14:29:00 +0530 Subject: [PATCH 48/50] Fixed Issue #160 --- usr/local/sbin/eeupdate | 261 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 251 insertions(+), 10 deletions(-) diff --git a/usr/local/sbin/eeupdate b/usr/local/sbin/eeupdate index 6e171a3d..e85a084a 100644 --- a/usr/local/sbin/eeupdate +++ b/usr/local/sbin/eeupdate @@ -60,14 +60,7 @@ EEUPDATE() if [ ! -L /usr/local/sbin/ee ] then ln -s /usr/local/sbin/easyengine /usr/local/sbin/ee - fi - - # Adjust FastCGI Cache Size 20% Of /var/run - VARRUNSIZE=$(df --block-size=M /var/run | awk '{print $4}' | tail -n1 |cut -d'M' -f1) - FCSIZE=$(expr $VARRUNSIZE \* 25 / 100) - - # Change Size - sed -i "s/500m/$FCSIZE\m/" /usr/share/easyengine/nginx/conf.d/fastcgi.conf || OwnError "Unable To Change Fastcgi Cache Size" + fi # Git Config Settings EEGITNAME=$(git config user.name) @@ -181,6 +174,248 @@ EE110() sed -i '/allow ;/d' /etc/nginx/common/acl.conf } +PHP_PACKAGES() +{ + # Opcache Settings + if [ ! -d /var/www/22222/htdocs/php/opcache ] + then + # Create Directory + mkdir -p /var/www/22222/htdocs/php/opcache || OwnError "Unable To Create Opcache Directory" + + # Download Opcache Status Files + echo -e "\033[34mInstalling Opcache Tool, Please Wait...\e[0m" + wget -cqO /var/www/22222/htdocs/php/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php + wget -cqO /var/www/22222/htdocs/php/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php + wget -cqO /var/www/22222/htdocs/php/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php + fi + + # Memcache Settings + if [ ! -d /var/www/22222/htdocs/php/memcache ] + then + # Create Directory + mkdir -p /var/www/22222/htdocs/php/memcache || OwnError "Unable To Create Memcache Directory" + + # Download phpMemcachedAdmin + echo -e "\033[34mInstalling Memcache Tool, Please Wait...\e[0m" + wget -cqO /var/www/22222/htdocs/php/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz + + # Extract phpMemcachedAdmin + tar -zxf /var/www/22222/htdocs/php/memcache/memcache.tar.gz -C /var/www/22222/htdocs/php/memcache + + # Remove Unwanted Files + rm -f /var/www/22222/htdocs/php/memcache/memcache.tar.gz + fi + + if [ ! -d /var/www/22222/htdocs/php/webgrind/ ] + then + # Download Opcache Status Files + mkdir -p mkdir -p /var/www/22222/htdocs/php/webgrind/ || OwnError "Unable To Create webgrind Directory" + + # Download Webgrind + echo -e "\033[34mCloning Webgrind, Please Wait...\e[0m" + git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ &>> $INSTALLLOG || OwnError "Unable To Clone Webgrind" + sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php + + # Install Graphviz + dpkg -l | grep graphviz &>> $INSTALLLOG + if [ $? -ne 0 ] + then + echo -e "\033[34mInstalling Graphviz, Please Wait...\e[0m" + apt-get -y install graphviz || OwnError "Unable To Install Graphviz" + fi + fi + + # Create info.php File To Display The phpinfo Information + echo -e "" &>> /var/www/22222/htdocs/php/info.php + + # Fake PHP5-FPM Status Pages + if [ ! -d /var/www/22222/htdocs/php/status/ ] + then + mkdir -p /var/www/22222/htdocs/php/status/ || OwnError "Unable To Create webgrind Directory" + touch /var/www/22222/htdocs/php/status/{php,debug} + fi + + # Anemometer Setup + if [ ! -d /var/www/22222/htdocs/db/anemometer/ ] + then + mkdir -p /var/www/22222/htdocs/db/anemometer/ || OwnError "Unable To Create Anemometer Directory" + + # Download Anemometer + git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $INSTALLLOG \ + || OwnError "Unable To Clone Anemometer" + + # Setup Anemometer + # Collect MySQL Login Details + MYSQLROOT + + # Setup Anemometer Database + mysql -u $MYSQLUSER -p$MYSQLPASS < /var/www/22222/htdocs/db/anemometer/install.sql \ + || OwnError "Unable To Import Anemometer Database" + + # Setup Anemometer Database Grants + ANEMOMETERPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) + mysql -u $MYSQLUSER -p$MYSQLPASS -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ANEMOMETERPASS';" + + # Put Data In Anemometer Database + pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \ + --review D=slow_query_log,t=global_query_review \ + --review-history D=slow_query_log,t=global_query_review_history \ + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /var/log/mysql/slow.log &>> $INSTALLLOG + + # Execute On MySQL Logrotation + sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server + echo -e " pt-query-digest --user=anemometer --password=$ANEMOMETERPASS \\" >> /etc/logrotate.d/mysql-server + echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server + echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server + echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"\$HOSTNAME\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server + echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server + echo -e "}" >> /etc/logrotate.d/mysql-server + + # Copy Anemometer Configuration File + cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ + || OwnError "Unable To Copy Anemometer Configuration File" + + # Update Anemoneter Configuration File + sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php + sed -i "/password/ s/''/'$ANEMOMETERPASS'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php + + fi + + # Call PHPUSERINFO Function For PHP User Details + PHPUSERINFO + + # Change Ownership + chown -R $PHPUSER:$PHPUSER /var/www/22222 || OwnError "Unable To Change Ownership For /var/www/22222" +} + +INSTALLPMA() +{ + # Install PMA/phpMyAdmin + if [ ! -d /var/www/22222/htdocs/db/pma ] || [ ! -d /var/www/22222/htdocs/db/adminer ] + then + if [ ! -d /var/www/22222/htdocs/db/pma ] + then + echo -e "\033[34mDownloading phpMyAdmin, Please Wait...\e[0m" + + # Setup PMA/phpMyAdmin + mkdir -p /var/www/22222/htdocs/db/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/22222/htdocs/db/pma/" + + # Download PMA/phpMyAdmin + wget -cqO /var/www/22222/htdocs/db/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \ + || OwnError "Unable To Download phpMyAdmin" + + # Extract PMA/phpMyAdmin + tar --strip-components=1 -zxf /var/www/22222/htdocs/db/pma/pma.tar.gz -C /var/www/22222/htdocs/db/pma/ \ + || OwnError "Unable To Extract phpMyAdmin" + + # Remove Unwanted Files + rm -f /var/www/22222/htdocs/db/pma/pma.tar.gz + + fi + + if [ ! -d /var/www/22222/htdocs/db/adminer ] + then + echo -e "\033[34mDownloading Adminer, Please Wait...\e[0m" + # Setup Adminer + mkdir -p /var/www/22222/htdocs/db/adminer/ || OwnError "Unable To Create Adminer Directory: /var/www/22222/htdocs/db/adminer/" + + # Download Adminer + wget -cqO /var/www/22222/htdocs/db/adminer/index.php http://downloads.sourceforge.net/adminer/adminer-4.0.3.php \ + || OwnError "Unable To Download Adminer" + + fi + + else + echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/22222/htdocs/db/pma)...\e[0m" + fi +} +EE122() +{ + # Install Packages: + apt-get -y install php5-xdebug percona-toolkit graphviz + + + # EasyEngine Config File + sed -i "/# WordPress Defaults/i # Comma Separated Whitelist/Debugging IP Address\nip_address = \n" /etc/easyengine/ee.conf + + # Nginx File Copy + cp /usr/share/easyengine/nginx/conf.d/upstream.conf /etc/nginx/conf.d/ || OwnError "Unable To Copy Nginx Upstream File" + cp /usr/share/easyengine/nginx/common/locations.conf /etc/nginx/common/ || OwnError "Unable To Copy Nginx Common Location File" + cp /usr/share/easyengine/nginx/common/wpcommon.conf /etc/nginx/common/ || OwnError "Unable To Copy Nginx Common WordPress File" + + # Nginx Changes + sed -i "/worker_processes/a \worker_rlimit_nofile 100000;" /etc/nginx/nginx.conf + sed -i "s/# multi_accept/multi_accept/" /etc/nginx/nginx.conf + sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf + + # EasyEngine Admin Setup + cp /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ || OwnError "Unable To Copy 22222 Nginx Configuration File" + ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/ || OwnError "Unable To Create Symbolic Link For 22222 Nginx Configuration" + + # EasyEngine Admin Logs Setup + if [ ! -d /var/www/22222/logs ] + then + mkdir -p /var/www/22222/logs || OwnError "Unable To Create /var/www/22222/logs" + fi + + # Symbolic Links + ln -s /var/log/nginx/eeadmin.access.log /var/www/22222/logs/access.log + ln -s /var/log/nginx/eeadmin.error.log /var/www/22222/logs/error.log + + # EasyEngine Admin SSL Setup + if [ ! -d /var/www/22222/cert ] + then + mkdir -p /var/www/22222/cert || OwnError "Unable To Create /var/www/22222/cert" + fi + + # Generate SSL Key + echo -e "\033[34mGenerating SSL Private Key, Please Wait...\e[0m" + openssl genrsa -out /var/www/22222/cert/22222.key 2048 &>> $INSTALLLOG \ + || OwnError "Unable To Generate SSL Private Key" + + echo -e "\033[34mGenerating a Certificate Signing Request (CSR), Please Wait...\e[0m" + openssl req -new -batch -subj /commonName=127.0.0.1/ -key /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.csr &>> $INSTALLLOG \ + || OwnError "Unable To Generate Certificate Signing Request (CSR)" + + echo -e "\033[34mRemoving Passphrase From SSL Private Key, Please Wait...\e[0m" + mv /var/www/22222/cert/22222.key /var/www/22222/cert/22222.key.org + openssl rsa -in /var/www/22222/cert/22222.key.org -out /var/www/22222/cert/22222.key &>> $INSTALLLOG \ + || OwnError "Unable To Remove Passphrase From SSL Private Key" + + echo -e "\033[34mGenerating SSL Certificate, Please Wait...\e[0m" + openssl x509 -req -days 3652 -in /var/www/22222/cert/22222.csr -signkey /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.crt &>> $INSTALLLOG \ + || OwnError "Unable To Generate SSL Certificate" + + # Personal Settings For PHP + echo -e "\033[34mUpdating PHP Configuration Files, Please Wait...\e[0m" + + # Needed For Custome PHP5 Logs + if [ ! -d /var/log/php5/ ] + then + mkdir -p /var/log/php5/ || OwnError "Unable To Create PHP5 Log Directory: /var/log/php5/" + fi + + TIME_ZONE=$(cat /etc/timezone | sed "s'/'\\\/'") + sed -i "s/;date.timezone.*/date.timezone = $TIME_ZONE/" /etc/php5/fpm/php.ini + + # Change PHP5-FPM Error Logs Location + sed -i "s'error_log.*'error_log = /var/log/php5/fpm.log'" /etc/php5/fpm/php-fpm.conf + + # Separate PHP POOL For Slow Logs + cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/debug.conf + sed -i "s'\[www\]'[debug]'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Pool Name" + sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Fastcgi Listen Port" + sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Chnage Process Manager From Dynamic To Ondemand" + sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Slowlog" + sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf || OwnError "Unable To Change PHP Request Slowlog Timeout" + echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $INSTALLLOG \ + || OwnError "Unable To Add Xdebug Settings" + + # Install PHP Packages + PHP_PACKAGES + INSTALLPMA +} + HTTPAUTH() { # Get The htpasswd Details @@ -220,7 +455,7 @@ HTTPAUTH() RESTARTSERVICE() { echo -e "\033[34mRestarting Nginx & PHP5-FPM Configuration, Please Wait...\e[0m" - service php5-fpm restart &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM After Update" + (php5-fpm -t && service php5-fpm restart) &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM After Update" (nginx -t && service nginx restart) &>> $INSTALLLOG || OwnError "Unable To Restart Nginx After Update" } @@ -264,12 +499,18 @@ then EE101 HTTPAUTH MYCNFCHECK - EE110 + EECURRENTVERSION="1.1.0" fi if [[ $EECURRENTVERSION = 1.1.0 ]] then EE110 + EECURRENTVERSION="1.2.2" + fi + + if [[ $EECURRENTVERSION = 1.2.2 ]] + then + EE122 fi fi From 932a881bd4b79435007903c3ff87fdc9f2b85e4d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 14:29:16 +0530 Subject: [PATCH 49/50] Minor changes --- install.sh | 6 ------ usr/local/sbin/easyengine | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 0233e06e..544da491 100644 --- a/install.sh +++ b/install.sh @@ -186,12 +186,6 @@ then ln -s /usr/local/sbin/easyengine /usr/local/sbin/ee fi -# Adjust FastCGI Cache Size 20% Of /var/run -#VARRUNSIZE=$(df --block-size=M /var/run | awk '{print $4}' | tail -n1 |cut -d'M' -f1) -#FCSIZE=$(expr $VARRUNSIZE \* 25 / 100) - -# Change Size -#sed -i "s/500m/$FCSIZE\m/" /usr/share/easyengine/nginx/conf.d/fastcgi.conf || OwnError "Unable To Change Fastcgi Cache Size" # Git Config Settings EEGITNAME=$(git config user.name) diff --git a/usr/local/sbin/easyengine b/usr/local/sbin/easyengine index c43805f0..031635a6 100644 --- a/usr/local/sbin/easyengine +++ b/usr/local/sbin/easyengine @@ -2043,7 +2043,7 @@ then #PERCONA_REPO # Fix GPG Key Problems - GPGKEY + #GPGKEY # Update The APT Cache UPDATEAPT From 2aed208b292229306e58fa9b48cfd9847468d4fa Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Apr 2014 15:08:08 +0530 Subject: [PATCH 50/50] EasyEngine Update Ready --- usr/local/sbin/eeupdate | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usr/local/sbin/eeupdate b/usr/local/sbin/eeupdate index e85a084a..2355a68f 100644 --- a/usr/local/sbin/eeupdate +++ b/usr/local/sbin/eeupdate @@ -174,6 +174,13 @@ EE110() sed -i '/allow ;/d' /etc/nginx/common/acl.conf } +PHPUSERINFO() +{ + # PHP User + PHPUSER=$(grep ^user /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2 | cut -d' ' -f2) \ + || OwnError "Unable To Find Out PHP Username" +} + PHP_PACKAGES() { # Opcache Settings @@ -246,7 +253,7 @@ PHP_PACKAGES() # Setup Anemometer # Collect MySQL Login Details - MYSQLROOT + MYCNFCHECK # Setup Anemometer Database mysql -u $MYSQLUSER -p$MYSQLPASS < /var/www/22222/htdocs/db/anemometer/install.sql \ @@ -331,7 +338,8 @@ INSTALLPMA() } EE122() { - # Install Packages: + # Install Packages + echo -e "\033[34mInstalling php5-xdebug percona-toolkit graphviz, Please Wait...\e[0m" apt-get -y install php5-xdebug percona-toolkit graphviz