lemp.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #!/bin/sh
  2. echo -e '
  3. _
  4. | |___ _ __ _ __
  5. | / -_) ' \| '_ \
  6. |_\___|_|_|_| .__/
  7. |_|
  8. '
  9. echo -e "LEMP server (Nginx Mysql Php-fpm)"
  10. . bin/checkroot.sh
  11. # get the current position
  12. _cwd="$(pwd)"
  13. # check for assets forlder
  14. _assets="$_cwd/assets"
  15. if [ ! -d "$_assets" ]; then
  16. _assets="$_cwd/../assets"
  17. if [ ! -d "$_assets" ]; then
  18. echo "!! can't find assets directory !!"
  19. exit
  20. fi
  21. fi
  22. sleep 2
  23. echo -e '
  24. _
  25. _ __ _ _ ___ __ _| |
  26. | . \ || (_-</ _` | |
  27. |_|_|_\_, /__/\__, |_|
  28. |__/ |_|
  29. '
  30. echo -e "installing Mysql"
  31. sleep 3
  32. apk add mariadb mariadb-client
  33. # https://bugs.alpinelinux.org/issues/9046
  34. DB_DATA_PATH="/var/lib/mysql"
  35. DB_ROOT_PASS="mariadb_root_password"
  36. DB_USER="mariadb_user"
  37. DB_PASS="mariadb_user_password"
  38. MAX_ALLOWED_PACKET="200M"
  39. mysql_install_db --user=mysql --datadir=${DB_DATA_PATH}
  40. rc-update add mariadb
  41. service mariadb start
  42. echo -e "mysql installed"
  43. echo -e '
  44. _
  45. _ __| |_ _ __
  46. | `_ \ ` \| `_ \
  47. | .__/_||_| .__/
  48. |_| |_|
  49. '
  50. echo -e "Installing PHP 7.0"
  51. sleep 3
  52. apk add php7 php7-fpm php7-pdo_mysql php7-opcache php7-curl php7-mbstring php7-zip php7-xml php7-gd php7-mcrypt php7-imagick php7-phar php7-json
  53. echo -e "Configuring PHP"
  54. sed -i "s/memory_limit\ =\ 128M/memory_limit = 512M/g" /etc/php7/php.ini
  55. TIMEZONE="Europe/Helsinki"
  56. sed -i "s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i" /etc/php7/php.ini
  57. rc-update add php-fpm7
  58. service php-fpm7 start
  59. echo -e "php installed"
  60. echo -e '
  61. _
  62. _ _ __ _(_)_ _ __ __
  63. | ` \/ _` | | ` \\ \ /
  64. |_||_\__, |_|_||_/_\_\
  65. |___/
  66. '
  67. echo -e "Installing Nginx"
  68. sleep 3
  69. apk add nginx
  70. adduser -D -g 'www' www
  71. mkdir -p /var/www/html
  72. chown -R www:www /var/lib/nginx
  73. chown -R www:www /var/www/html
  74. mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.ori
  75. cp "$_assets"/lemp/default.nginxconf /etc/nginx/conf.d/default.conf
  76. cp "$_assets"/lemp/index.php /var/www/html/
  77. rc-update add nginx
  78. service nginx start
  79. echo -e "Nginx installed"
  80. # echo -e '
  81. # _ __ __ _ _ _
  82. # _ __| |_ _ __| \/ |_ _ /_\ __| |_ __ (_)_ _
  83. # | `_ \ ` \| `_ \ |\/| | || |/ _ \/ _` | ` \| | ` \
  84. # | .__/_||_| .__/_| |_|\_, /_/ \_\__,_|_|_|_|_|_||_|
  85. # |_| |_| |__/
  86. # '
  87. # echo -e "Installing phpMyAdmin"
  88. # apk add phpmyadmin
  89. # ln -s /usr/share/phpmyadmin /var/www/html/
  90. # cp "$_assets"/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf
  91. # ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
  92. #
  93. # # echo -e "securing phpMyAdmin"
  94. # # sed -i "s/DirectoryIndex index.php/DirectoryIndex index.php\nAllowOverride all/"
  95. # # cp "$_assets"/phpmyadmin_htaccess > /usr/share/phpmyadmin/.htaccess
  96. # # echo -n "define a user name for phpmyadmin : "
  97. # # read un
  98. # # htpasswd -c /etc/phpmyadmin/.htpasswd $un
  99. # # service apache2 restart
  100. # echo -e "phpMyAdmin installed"
  101. # echo -e "You can access it at yourip/phpmyadmin"
  102. echo -e '
  103. _ _
  104. _ _ ___ __| (_)___
  105. | `_/ -_) _` | (_-<
  106. |_| \___\__,_|_/__/
  107. '
  108. echo -e "Installing Redis"
  109. sleep 3
  110. apk add redis php7-pecl-redis
  111. # TODO set maxmemory=2gb
  112. # TODO set maxmemory-policy=volatile-lru
  113. # TODO comment all save line
  114. rc-update add redis
  115. service redis start
  116. service php-fpm7 restart
  117. echo -e "Redis installed"
  118. echo -e '
  119. __ ___ _ __ _ __ ___ ___ ___ _ _
  120. / _/ _ \ ` \| `_ \/ _ (_-</ -_) `_|
  121. \__\___/_|_|_| .__/\___/__/\___|_|
  122. |_|
  123. '
  124. echo -e "Installing Composer"
  125. sleep 3
  126. export COMPOSER_HOME=/usr/local/composer
  127. curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  128. echo -e "Composer installed"
  129. echo -e '
  130. _ _
  131. __| |_ _ _ _ __| |_
  132. / _` | `_| || (_-< ` \
  133. \__,_|_| \_,_/__/_||_|
  134. '
  135. echo -e "Installing Drush and DrupalConsole"
  136. sleep 3
  137. curl https://drupalconsole.com/installer -L -o /usr/local/bin/drupal
  138. chmod +x /usr/local/bin/drupal
  139. curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o /usr/local/bin/drush
  140. chmod +x /usr/local/bin/drush
  141. echo -e "Drush and DrupalConsoleinstalled"