Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 17.34 KB | None | 0 0
  1. #! /bin/bash
  2. ####
  3. ##   M2ADDON.SH
  4. ####
  5.  
  6. ####                                                    ####
  7. ## Edit stuff below this point if you don't want defaults ##
  8. ####                                                    ####
  9.  
  10. #Write your own domain in, just leave out the www
  11. #Can be left blank to use addon.com as a standin
  12. DOMAIN=$1
  13. #IP can be ext, int or write it in yourself
  14. IP="int"
  15. #Change SSL to "yes" if you want the nginx SSL section including
  16. SSL="no"
  17. #Check required PHP version (either 70 or 71)
  18. PHPV=""
  19.  
  20.  
  21. ####                                                        ####
  22. ## Don't edit stuff below here if you want the script to work ##
  23. ####                                                        ####
  24.  
  25. unset HISTFILE
  26.  
  27. ###
  28. # Variables 'n' shit
  29. ###
  30.  
  31. if [ -z ${DOMAIN} ]
  32.    then
  33.         DOMAIN="addon.com"
  34. fi
  35.  
  36. if [ "$IP" = "int" ]
  37.     then
  38.         IP=`ip a|egrep -m1 '(172\.|192.168\.|10\.0\.)'|awk '{print $2}'|sed -e 's_/.*__'`
  39. elif [ "$IP" = "ext" ]
  40.     then
  41.         IP=`curl -s icanhazip.com`
  42. fi
  43.  
  44. ####
  45. # Pwgen to stop dependency issues with my broken sites
  46. ####
  47.  
  48. yum install epel-release -y
  49. yum install pwgen --enablerepo=epel -y
  50.  
  51. ####
  52.  
  53. DOMNODOT=`echo $DOMAIN| sed 's/\.//g'`
  54. BACKEND=$(echo $(echo $DOMNODOT)backend)
  55. USERPASS=`pwgen -cn1`
  56. MYSQL=$(echo $DOMNODOT | sed -n 's/^\(......\).*/\1/p')
  57. MYSQL="${MYSQL}$(cat /dev/urandom | tr -dc '0-9a-zA-Z' | head -c 4)"
  58. MYSQLPASS=`pwgen -cn1`
  59. DBNAME=`echo $DOMNODOT|sed 's/-//g'`
  60.  
  61. ###
  62. # Adding domain
  63. ###
  64. if [ "$SSL" = "no" ]; then
  65.     echo "
  66. upstream $BACKEND {
  67.     server unix:/var/run/php-fpm-$DOMNODOT.sock;
  68. }
  69.  
  70. server {
  71.     listen $IP:80;
  72.     server_name $DOMAIN *.$DOMAIN;
  73.     set \$MAGE_ROOT /var/www/vhosts/$DOMAIN/htdocs;
  74.  
  75.     include /etc/nginx/ssl_offloading.inc;
  76.  
  77.     root \$MAGE_ROOT/pub;
  78.  
  79.     index index.php;
  80.     autoindex off;
  81.     charset UTF-8;
  82.     error_page 404 403 = /errors/404.php;
  83.     #add_header \"X-UA-Compatible\" \"IE=Edge\";
  84.  
  85.     # PHP entry point for setup application
  86.     location ~* ^/setup($|/) {
  87.         root \$MAGE_ROOT;
  88.         location ~ ^/setup/index.php {
  89.             fastcgi_pass $BACKEND;
  90.             fastcgi_index index.php;
  91.             fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  92.             include fastcgi_params;
  93.         }
  94.  
  95.         location ~ ^/setup/(?!pub/). {
  96.             deny all;
  97.         }
  98.  
  99.         location ~ ^/setup/pub/ {
  100.             add_header X-Frame-Options \"SAMEORIGIN\";
  101.         }
  102.     }
  103.  
  104.     # PHP entry point for update application
  105.     location ~* ^/update($|/) {
  106.         root \$MAGE_ROOT;
  107.  
  108.         location ~ ^/update/index.php {
  109.             fastcgi_split_path_info ^(/update/index.php)(/.+)$;
  110.             fastcgi_pass $BACKEND;
  111.             fastcgi_index index.php;
  112.             fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  113.             fastcgi_param PATH_INFO \$fastcgi_path_info;
  114.             include fastcgi_params;
  115.         }
  116.  
  117.         # Deny everything but index.php
  118.         location ~ ^/update/(?!pub/). {
  119.             deny all;
  120.         }
  121.  
  122.         location ~ ^/update/pub/ {
  123.             add_header X-Frame-Options \"SAMEORIGIN\";
  124.         }
  125.     }
  126.  
  127.     location / {
  128.         try_files \$uri \$uri/ /index.php?\$args;
  129.     }
  130.  
  131.    # Block known bad bots
  132.     if (\$http_user_agent ~* baidu|ahrefs|semrush|xovibot|360Spider|dotbot|genieo|megaindex\.ru|vagabondo|yandexbot|yelpspider|fatbot|tineye|blexbot|ascribebot|ia_archiver|moatbot|mixrankbot|orangebot|yoozbot|mj12bot|paperlibot|showyoubot|grapeshot|WeSee|haosouspider|spider|lexxebot|nutch) {
  133.         return 403;
  134.     }
  135.  
  136.     # Only allow GET - HEAD - POST requests
  137.     if (\$request_method !~ ^(GET|HEAD|POST|PUT)$ ) {
  138.         return 444;
  139.     }
  140.  
  141.  
  142.     location /pub/ {
  143.         location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
  144.             deny all;
  145.         }
  146.         alias \$MAGE_ROOT/pub/;
  147.         add_header X-Frame-Options \"SAMEORIGIN\";
  148.     }
  149.  
  150.     location /static/ {
  151.         expires max;
  152.  
  153.         # Remove signature of the static files that is used to overcome the browser cache
  154.         location ~ ^/static/version {
  155.             rewrite ^/static/(version\d*/)?(.*)$ /static/\$2 last;
  156.         }
  157.  
  158.         location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  159.             add_header Cache-Control \"public\";
  160.             add_header X-Frame-Options \"SAMEORIGIN\";
  161.             expires +1y;
  162.  
  163.             if (!-f \$request_filename) {
  164.                 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last;
  165.             }
  166.         }
  167.         location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  168.             add_header Cache-Control \"no-store\";
  169.             add_header X-Frame-Options \"SAMEORIGIN\";
  170.             expires off;
  171.  
  172.             if (!-f \$request_filename) {
  173.                 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last;
  174.             }
  175.         }
  176.         if (!-f \$request_filename) {
  177.             rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last;
  178.         }
  179.         add_header X-Frame-Options \"SAMEORIGIN\";
  180.     }
  181.  
  182.     location /media/ {
  183.         try_files \$uri \$uri/ /get.php?\$args;
  184.  
  185.         location ~ ^/media/theme_customization/.*\.xml {
  186.             deny all;
  187.         }
  188.  
  189.         location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  190.             add_header Cache-Control \"public\";
  191.             add_header X-Frame-Options \"SAMEORIGIN\";
  192.             expires +1y;
  193.             try_files \$uri \$uri/ /get.php?\$args;
  194.         }
  195.         location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  196.             add_header Cache-Control \"no-store\";
  197.             add_header X-Frame-Options \"SAMEORIGIN\";
  198.             expires off;
  199.             try_files \$uri \$uri/ /get.php?\$args;
  200.         }
  201.         add_header X-Frame-Options \"SAMEORIGIN\";
  202.     }
  203.  
  204.     location /media/customer/ {
  205.         deny all;
  206.     }
  207.  
  208.     location /media/downloadable/ {
  209.         deny all;
  210.     }
  211.  
  212.     location /media/import/ {
  213.         deny all;
  214.     }
  215.  
  216.     # PHP entry point for main application
  217.     location ~ (index|get|static|report|404|503)\.php$ {
  218.         try_files \$uri =404;
  219.         fastcgi_pass $BACKEND;
  220.         fastcgi_buffers 1024 4k;
  221.  
  222.         fastcgi_param PHP_FLAG \"session.auto_start=off \\n suhosin.session.cryptua=off\";
  223.         fastcgi_param PHP_VALUE \"memory_limit=768M \\n max_execution_time=600\";
  224.         fastcgi_read_timeout 600s;
  225.         fastcgi_connect_timeout 600s;
  226.  
  227.         #Uncomment the below to set multistore MAGE_RUN_CODE and MAGE_RUN_TYPE
  228.         #fastcgi_param  MAGE_RUN_CODE default;
  229.         #fastcgi_param  MAGE_RUN_TYPE store;
  230.  
  231.         fastcgi_index index.php;
  232.         fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  233.         include fastcgi_params;
  234.     }
  235.  
  236.     gzip on;
  237.     gzip_disable \"msie6\";
  238.  
  239.     gzip_comp_level 6;
  240.     gzip_min_length 1100;
  241.     gzip_buffers 16 8k;
  242.     gzip_proxied any;
  243.     gzip_types
  244.     text/plain
  245.     text/css
  246.     text/js
  247.     text/xml
  248.     text/javascript
  249.     application/javascript
  250.     application/x-javascript
  251.     application/json
  252.     application/xml
  253.     application/xml+rss
  254.     image/svg+xml;
  255.     gzip_vary on;
  256.  
  257.     # Banned locations (only reached if the earlier PHP entry point regexes don't match)
  258.     location ~* (\.php$|\.htaccess$|\.git) {
  259.         deny all;
  260.     }
  261. }
  262.     " >> /etc/nginx/conf.d/$DOMAIN.conf
  263. else
  264.         echo "
  265. upstream $BACKEND {
  266.     server unix:/var/run/php-fpm-$DOMNODOT.sock;
  267. }
  268.  
  269. server {
  270.     listen $IP:80;
  271.     listen $IP:443 ssl http2;
  272.     server_name $DOMAIN *.$DOMAIN;
  273.     set \$MAGE_ROOT /var/www/vhosts/$DOMAIN/htdocs;
  274.  
  275.     ssl_certificate /etc/nginx/ssl/$DOMAIN.crt;
  276.     ssl_certificate_key /etc/nginx/ssl/$DOMAIN.key;
  277.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  278.     ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
  279.     ssl_prefer_server_ciphers on;
  280.  
  281.     root \$MAGE_ROOT/pub;
  282.  
  283.     index index.php;
  284.     autoindex off;
  285.     charset UTF-8;
  286.     error_page 404 403 = /errors/404.php;
  287.     #add_header \"X-UA-Compatible\" \"IE=Edge\";
  288.  
  289.    # Block known bad bots
  290.     if (\$http_user_agent ~* baidu|ahrefs|semrush|xovibot|360Spider|dotbot|genieo|megaindex\.ru|vagabondo|yandexbot|yelpspider|fatbot|tineye|blexbot|ascribebot|ia_archiver|moatbot|mixrankbot|orangebot|yoozbot|mj12bot|paperlibot|showyoubot|grapeshot|WeSee|haosouspider|spider|lexxebot|nutch) {
  291.         return 403;
  292.     }
  293.  
  294.     # PHP entry point for setup application
  295.     location ~* ^/setup($|/) {
  296.         root \$MAGE_ROOT;
  297.         location ~ ^/setup/index.php {
  298.             fastcgi_pass $BACKEND;
  299.             fastcgi_index index.php;
  300.             fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  301.             include fastcgi_params;
  302.         }
  303.  
  304.         location ~ ^/setup/(?!pub/). {
  305.             deny all;
  306.         }
  307.  
  308.         location ~ ^/setup/pub/ {
  309.             add_header X-Frame-Options \"SAMEORIGIN\";
  310.         }
  311.     }
  312.  
  313.     # PHP entry point for update application
  314.     location ~* ^/update($|/) {
  315.         root \$MAGE_ROOT;
  316.  
  317.         location ~ ^/update/index.php {
  318.             fastcgi_split_path_info ^(/update/index.php)(/.+)$;
  319.             fastcgi_pass $BACKEND;
  320.             fastcgi_index index.php;
  321.             fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  322.             fastcgi_param PATH_INFO \$fastcgi_path_info;
  323.             include fastcgi_params;
  324.         }
  325.  
  326.         # Deny everything but index.php
  327.         location ~ ^/update/(?!pub/). {
  328.             deny all;
  329.         }
  330.  
  331.         location ~ ^/update/pub/ {
  332.             add_header X-Frame-Options \"SAMEORIGIN\";
  333.         }
  334.     }
  335.  
  336.     location / {
  337.         try_files \$uri \$uri/ /index.php?\$args;
  338.     }
  339.  
  340.     location /pub/ {
  341.         location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
  342.             deny all;
  343.         }
  344.         alias \$MAGE_ROOT/pub/;
  345.         add_header X-Frame-Options \"SAMEORIGIN\";
  346.     }
  347.  
  348.     location /static/ {
  349.         expires max;
  350.  
  351.         # Remove signature of the static files that is used to overcome the browser cache
  352.         location ~ ^/static/version {
  353.             rewrite ^/static/(version\d*/)?(.*)$ /static/\$2 last;
  354.         }
  355.  
  356.         location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  357.             add_header Cache-Control \"public\";
  358.             add_header X-Frame-Options \"SAMEORIGIN\";
  359.             expires +1y;
  360.  
  361.             if (!-f \$request_filename) {
  362.                 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last;
  363.             }
  364.         }
  365.         location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  366.             add_header Cache-Control \"no-store\";
  367.             add_header X-Frame-Options \"SAMEORIGIN\";
  368.             expires off;
  369.  
  370.             if (!-f \$request_filename) {
  371.                 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last;
  372.             }
  373.         }
  374.         if (!-f \$request_filename) {
  375.             rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last;
  376.         }
  377.         add_header X-Frame-Options \"SAMEORIGIN\";
  378.     }
  379.  
  380.     location /media/ {
  381.         try_files \$uri \$uri/ /get.php?\$args;
  382.  
  383.         location ~ ^/media/theme_customization/.*\.xml {
  384.             deny all;
  385.         }
  386.  
  387.         location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  388.             add_header Cache-Control \"public\";
  389.             add_header X-Frame-Options \"SAMEORIGIN\";
  390.             expires +1y;
  391.             try_files \$uri \$uri/ /get.php?\$args;
  392.         }
  393.         location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  394.             add_header Cache-Control \"no-store\";
  395.             add_header X-Frame-Options \"SAMEORIGIN\";
  396.             expires off;
  397.             try_files \$uri \$uri/ /get.php?\$args;
  398.         }
  399.         add_header X-Frame-Options \"SAMEORIGIN\";
  400.     }
  401.  
  402.     location /media/customer/ {
  403.         deny all;
  404.     }
  405.  
  406.     location /media/downloadable/ {
  407.         deny all;
  408.     }
  409.  
  410.     location /media/import/ {
  411.         deny all;
  412.     }
  413.  
  414.     # PHP entry point for main application
  415.     location ~ (index|get|static|report|404|503)\.php$ {
  416.         try_files \$uri =404;
  417.         fastcgi_pass $BACKEND;
  418.         fastcgi_buffers 1024 4k;
  419.  
  420.         fastcgi_param PHP_FLAG \"session.auto_start=off \\n suhosin.session.cryptua=off\";
  421.         fastcgi_param PHP_VALUE \"memory_limit=768M \\n max_execution_time=600\";
  422.         fastcgi_read_timeout 600s;
  423.         fastcgi_connect_timeout 600s;
  424.  
  425.         #Uncomment the below to set multistore MAGE_RUN_CODE and MAGE_RUN_TYPE
  426.         #fastcgi_param  MAGE_RUN_CODE default;
  427.         #fastcgi_param  MAGE_RUN_TYPE store;
  428.  
  429.         fastcgi_index index.php;
  430.         fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  431.         include fastcgi_params;
  432.     }
  433.  
  434.     gzip on;
  435.     gzip_disable \"msie6\";
  436.  
  437.     gzip_comp_level 6;
  438.     gzip_min_length 1100;
  439.     gzip_buffers 16 8k;
  440.     gzip_proxied any;
  441.     gzip_types
  442.     text/plain
  443.     text/css
  444.     text/js
  445.     text/xml
  446.     text/javascript
  447.     application/javascript
  448.     application/x-javascript
  449.     application/json
  450.     application/xml
  451.     application/xml+rss
  452.     image/svg+xml;
  453.     gzip_vary on;
  454.  
  455.     # Banned locations (only reached if the earlier PHP entry point regexes don't match)
  456.     location ~* (\.php$|\.htaccess$|\.git) {
  457.         deny all;
  458.     }
  459. }
  460.  
  461.        " >> /etc/nginx/conf.d/$DOMAIN.conf
  462.  
  463.         mkdir -p /etc/nginx/ssl
  464.  
  465.         #generate self signed for placeholder
  466.         openssl genrsa 1024 > /etc/nginx/ssl/$DOMAIN.key
  467.         openssl req -new -key /etc/nginx/ssl/$DOMAIN.key -x509 -days 365 -out /etc/nginx/ssl/$DOMAIN.crt -batch
  468. fi
  469.  
  470.  
  471. mkdir -p /var/www/vhosts/$DOMAIN/htdocs
  472. mkdir -p /var/www/vhosts/$DOMAIN/htdocs/pub
  473. useradd -d /var/www/vhosts/$DOMAIN -s /sbin/nologin $DOMAIN
  474. usermod -a -G $DOMAIN $(ps awux | grep nginx | egrep -v "grep|master" | awk '{print $1}' | sort | uniq)
  475. echo $USERPASS|passwd --stdin $DOMAIN
  476. touch /var/www/vhosts/$DOMAIN/phpfpm-slow.log
  477. touch /var/www/vhosts/$DOMAIN/phpfpm-error.log
  478. chown -R $DOMAIN:$DOMAIN /var/www/vhosts/$DOMAIN
  479.  
  480. ###
  481. # PHP time
  482. ###
  483.  
  484. echo "
  485. [$DOMNODOT]
  486.  
  487. listen = '/var/run/php-fpm-$DOMNODOT.sock'
  488. ;listen.backlog = -1
  489. listen.allowed_clients = 127.0.0.1
  490. listen.owner = nginx
  491. listen.group = nginx
  492. ;listen.mode = 0666
  493.  
  494. user = $DOMAIN
  495. group = $DOMAIN
  496.  
  497. pm = dynamic
  498. pm.max_children = 100
  499. pm.start_servers = 5
  500. pm.min_spare_servers = 5
  501. pm.max_spare_servers = 20
  502. pm.max_requests = 500
  503. ;pm.status_path = /status
  504.  
  505. ;request_terminate_timeout = 0
  506. ;request_slowlog_timeout = 0
  507. slowlog = /var/www/vhosts/$DOMAIN/phpfpm-slow.log
  508.  
  509. php_admin_value[error_log] = /var/www/vhosts/$DOMAIN/phpfpm-error.log
  510. php_admin_flag[log_errors] = on
  511. " >> /etc/php-fpm.d/$DOMNODOT.conf
  512.  
  513. ###
  514. # Create backups of php before doing install/upgrade
  515. ###
  516.  
  517. mkdir /root/php_upgrade_backup/
  518. php -v > /root/php_upgrade_backup/version
  519. php -m > /root/php_upgrade_backup/modules
  520. php -i > /root/php_upgrade_backup/info
  521. rpm -qa | grep -i php > /root/php_upgrade_backup/rpms
  522. cp -r /etc/php.d/ /root/php_upgrade_backup/
  523. cp -r /etc/php-fpm.conf /root/php_upgrade_backup/
  524. cp -r /etc/php-fpm.d/ /root/php_upgrade_backup/
  525. cp /etc/php.ini /root/php_upgrade_backup/
  526.  
  527. ###
  528. # Installing/upgrading PHP to required version
  529. ###
  530.  
  531. if [ "$PHPV" = "70" ];
  532.     then
  533.         wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm && rpm -Uvh remi-release-7.rpm && rm -f remi-release-7.rpm
  534.         sed -i 's/enabled\=1/enabled\=0/g' /etc/yum.repos.d/ius.repo
  535.         yum remove '*php*' -y
  536.         yum install --enablerepo=remi-php70,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-bcmath php-json php-iconv php-pecl-redis php-fpm php-zip php-soap -y
  537. elif [ "$PHPV" = "71" ]
  538.     then
  539.         wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm && rpm -Uvh remi-release-7.rpm && rm -f remi-release-7.rpm
  540.         sed -i 's/enabled\=1/enabled\=0/g' /etc/yum.repos.d/ius.repo
  541.         yum remove '*php*' -y
  542.         yum install --enablerepo=remi-php71,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-bcmath php-json php-iconv php-pecl-redis php-fpm php-zip php-soap -y
  543. fi
  544.  
  545. #Configure opcache for Magento 2+
  546. sed -i 's/opcache.memory_consumption=128/opcache.memory_consumption=512/g' /etc/php.d/*opcache.ini
  547. sed -i 's/opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=12/g' /etc/php.d/*opcache.ini
  548. sed -i 's/opcache.max_accelerated_files=4000/opcache.max_accelerated_files=60000/g' /etc/php.d/*opcache.ini
  549. sed -i 's/;opcache.save_comments=0/opcache.save_comments=1/g' /etc/php.d/*opcache.ini
  550. sed -i 's/;opcache.load_comments=1/opcache.load_comments=1/g' /etc/php.d/*opcache.ini
  551. sed -i 's/;opcache.enable_file_override=0/opcache.enable_file_override=1/g' /etc/php.d/*opcache.ini
  552.  
  553. #php.ini
  554. cp /etc/php.ini /root/php.ini.default
  555. sed -ie "s_;date.timezone =_date.timezone = \"Europe/London\"_g" /etc/php.ini
  556. sed -ie "s/memory_limit = 128M/memory_limit = 512M/" /etc/php.ini
  557. sed -ie "s/max_execution_time = 30/max_execution_time = 1800/" /etc/php.ini
  558. sed -ie "s/max_input_time = 60/max_input_time = 90/" /etc/php.ini
  559. sed -ie "s/short_open_tag = Off/short_open_tag = On/" /etc/php.ini
  560. sed -ie "s/;always_populate_raw_post_data = On/always_populate_raw_post_data = -1/" /etc/php.ini
  561. sed -ie "s/expose_php = On/expose_php = Off/" /etc/php.ini
  562. sed -ie "s/upload_max_filesize = 2M/upload_max_filesize = 8M/" /etc/php.ini
  563.  
  564. #Stopping the default PHP pool from running and enabling php-fpm
  565. echo ";Default file, please don't remove" > /etc/php-fpm.d/www.conf
  566.  
  567. ###
  568. # Create a default DB
  569. ###
  570.  
  571. echo "CREATE DATABASE $DBNAME;" | mysql
  572. echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO '$MYSQL'@'localhost' IDENTIFIED BY '$MYSQLPASS';" | mysql
  573. echo "FLUSH PRIVILEGES;" | mysql
  574.  
  575. ###
  576. # Start it all up
  577. ###
  578.  
  579. service nginx reload
  580. service php-fpm reload
  581.  
  582. ###
  583. # Installing Composer
  584. ###
  585. curl -sS https://getcomposer.org/installer | php
  586. mv composer.phar /usr/local/bin/composer
  587.  
  588. echo "
  589. #  $DOMAIN now set up
  590. #  Their username is $DOMAIN
  591. #  Their password is $USERPASS
  592. #
  593. #  Their database name is $DBNAME
  594. #  Their DB username is $MYSQL
  595. #  Their DB password is $MYSQLPASS
  596. " >> /root/finished$DOMAIN
  597.  
  598. cat /root/finished$DOMAIN
  599.  
  600. if [ "$SSL" = "yes" ]
  601.     then
  602.         echo "
  603.        # Self signed SSL certificates generated in the following location:
  604.        # /etc/nginx/ssl/$DOMNODOT.key
  605.        # /etc/nginx/ssl/$DOMNODOT.crt
  606.        # So don't forget to replace them with legit ones
  607.        " >> /root/finished$DOMAIN
  608. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement