lemp.sh 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. #!/bin/sh
  2. echo -e '\033[35m
  3. __
  4. / /__ ____ ___ ____
  5. / / _ \/ __ `__ \/ __ \
  6. / / __/ / / / / / /_/ /
  7. /_/\___/_/ /_/ /_/ .___/
  8. /_/
  9. \033[0m'
  10. echo -e "\033[35;1mLEMP server (Nginx Mysql Php-fpm) \033[0m"
  11. if [ "$EUID" -ne 0 ]; then
  12. echo "Please run as root"
  13. exit
  14. fi
  15. # get the current position
  16. _cwd="$(pwd)"
  17. # check for assets forlder
  18. _assets="$_cwd/assets"
  19. if [ ! -d "$_assets" ]; then
  20. _assets="$_cwd/../assets"
  21. if [ ! -d "$_assets" ]; then
  22. echo "!! can't find assets directory !!"
  23. exit
  24. fi
  25. fi
  26. sleep 2
  27. echo -e '\033[35m
  28. __ ___ __
  29. / |/ /_ ___________ _/ /
  30. / /|_/ / / / / ___/ __ `/ /
  31. / / / / /_/ (__ ) /_/ / /
  32. /_/ /_/\__, /____/\__, /_/
  33. /____/ /_/
  34. \033[0m'
  35. echo -e "\033[35;1minstalling Mysql \033[0m"
  36. sleep 3
  37. apt-get --yes install mariadb-server
  38. mysql_secure_installation
  39. cp "$_assets"/mysql/innodb-file-per-table.cnf /etc/mysql/conf.d/
  40. systemctl enable mariadb.service
  41. systemctl restart mariadb.service
  42. echo -e "\033[92;1mmysql installed\033[Om"
  43. echo -e '\033[35m
  44. ____ __ ______
  45. / __ \/ / / / __ \
  46. / /_/ / /_/ / /_/ /
  47. / ____/ __ / ____/
  48. /_/ /_/ /_/_/
  49. \033[0m'
  50. echo -e "\033[35;1mInstalling PHP 7.0 \033[0m"
  51. sleep 3
  52. # mv: cannot stat '/etc/php/7.0/fpm/php.ini': No such file or directory
  53. # cp: cannot create regular file '/etc/php/7.0/fpm/php.ini': No such file or directory
  54. # Configuring PHP
  55. # Failed to enable unit: Unit file php7.0-fpm.service does not exist.
  56. # Failed to start php7.0-fpm.service: Unit php7.0-fpm.service not found.
  57. apt-get --yes install php7.3-fpm php7.3-mysql php7.3-opcache php7.3-curl php7.3-mbstring php7.3-zip php7.3-xml php7.3-gd php-memcached php7.3-imagick
  58. # php7.3-mcrypt ??
  59. mv /etc/php/7.3/fpm/php.ini /etc/php/7.3/fpm/php.ini.back
  60. cp "$_assets"/php-fpm.ini /etc/php/7.3/fpm/php.ini
  61. echo "Configuring PHP"
  62. mkdir /var/log/php
  63. chown www-data /var/log/php
  64. cp "$_assets"/logrotate-php /etc/logrotate.d/php
  65. systemctl enable php7.3-fpm
  66. systemctl start php7.3-fpm
  67. # echo "Installing memecached"
  68. # replaced by redis
  69. # apt-get --yes install memcached
  70. # sed -i "s/-m\s64/-m 128/g" /etc/memcached.conf
  71. #
  72. # systemctl start memcached
  73. echo -e "\033[92;1mphp installed\033[Om"
  74. echo -e '\033[35m
  75. _ __ _
  76. / | / /___ _(_)___ _ __
  77. / |/ / __ `/ / __ \| |/_/
  78. / /| / /_/ / / / / /> <
  79. /_/ |_/\__, /_/_/ /_/_/|_|
  80. /____/
  81. \033[0m'
  82. echo -e "\033[35;1mInstalling Nginx \033[0m"
  83. sleep 3
  84. apt-get --yes install nginx
  85. mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.ori
  86. cp "$_assets"/default.nginxconf /etc/nginx/sites-available/default
  87. systemctl enable nginx
  88. systemctl restart nginx
  89. echo -e "\033[92;1mNginx installed\033[Om"
  90. echo -e '\033[35m
  91. __ __ ___ ___ __ _
  92. ____ / /_ ____ / |/ /_ __/ | ____/ /___ ___ (_)___
  93. / __ \/ __ \/ __ \/ /|_/ / / / / /| |/ __ / __ `__ \/ / __ \
  94. / /_/ / / / / /_/ / / / / /_/ / ___ / /_/ / / / / / / / / / /
  95. / .___/_/ /_/ .___/_/ /_/\__, /_/ |_\__,_/_/ /_/ /_/_/_/ /_/
  96. /_/ /_/ /____/
  97. \033[0m'
  98. echo -e "\033[35;1mInstalling phpMyAdmin \033[0m"
  99. ##### Building dependency tree
  100. ##### Reading state information... Done
  101. ##### Package phpmyadmin is not available, but is referred to by another package.
  102. ##### This may mean that the package is missing, has been obsoleted, or
  103. ##### is only available from another source
  104. #####
  105. ##### E: Package 'phpmyadmin' has no installation candidate
  106. ##### cp: missing destination file operand after '/root/debian-web-server/assets/nginx-phpmyadmin.conf'
  107. ##### Try 'cp --help' for more information.
  108. # TODO no pma package available :(
  109. # apt-get --yes install phpmyadmin
  110. # ln -s /usr/share/phpmyadmin /var/www/html/
  111. # cp "$_assets"/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf
  112. # ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
  113. # echo -e "\033[92;1mphpMyAdmin installed\033[Om"
  114. # echo -e "\033[92;1mYou can access it at yourip/phpmyadmin\033[Om"
  115. echo -e '\033[35m
  116. ____ ___
  117. / __ \___ ____/ (_)____
  118. / /_/ / _ \/ __ / / ___/
  119. / _, _/ __/ /_/ / (__ )
  120. /_/ |_|\___/\__,_/_/____/
  121. \033[0m'
  122. echo -e "\033[35;1mInstalling Redis \033[0m"
  123. sleep 3
  124. apt-get --yes install redis-server php-redis
  125. # TODO set maxmemory=2gb
  126. # TODO set maxmemory-policy=volatile-lru
  127. # TODO comment all save line
  128. systemctl enable redis-server
  129. systemctl restart redis-server
  130. systemctl restart php7.0-fpm
  131. echo -e "\033[92;1mRedis installed\033[Om"
  132. echo -e '\033[35m
  133. ______
  134. / ____/___ ____ ___ ____ ____ ________ _____
  135. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  136. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  137. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  138. /_/
  139. \033[0m'
  140. echo -e "\033[35;1mInstalling Composer \033[0m"
  141. sleep 3
  142. export COMPOSER_HOME=/usr/local/composer
  143. curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  144. echo -e "\033[92;1mComposer installed\033[Om"
  145. echo -e '\033[35m
  146. ____ __
  147. / __ \_______ _______/ /_
  148. / / / / ___/ / / / ___/ __ \
  149. / /_/ / / / /_/ (__ ) / / /
  150. /_____/_/ \__,_/____/_/ /_/
  151. \033[0m'
  152. echo -e "\033[35;1mInstalling Drush and DrupalConsole\033[0m"
  153. sleep 3
  154. curl https://drupalconsole.com/installer -L -o /usr/local/bin/drupal
  155. chmod +x /usr/local/bin/drupal
  156. curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o /usr/local/bin/drush
  157. chmod +x /usr/local/bin/drush
  158. echo -e "\033[92;1mDrush and DrupalConsoleinstalled\033[Om"
  159. # TODO supervising
  160. # echo -e '\033[35m
  161. # __ ___ _ __ __ __ ___ _
  162. # / |/ /__ ___ (_) /_ _/_/ / |/ /_ _____ (_)__
  163. # / /|_/ / _ \/ _ \/ / __/ _/_/ / /|_/ / // / _ \/ / _ \
  164. # /_/ /_/\___/_//_/_/\__/ /_/ /_/ /_/\_,_/_//_/_/_//_/
  165. # \033[0m'
  166. # echo -e "\033[35;1mInstalling Munin \033[0m"
  167. # sleep 3
  168. # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/
  169. # apt-get --yes install munin munin-node munin-plugins-extra
  170. # # Configure Munin
  171. # # enable plugins
  172. # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_
  173. # ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes
  174. # ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/mysql_innodb
  175. # ln -s /usr/share/munin/plugins/mysql_isam_space_ /etc/munin/plugins/mysql_isam_space_
  176. # ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries
  177. # ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/mysql_slowqueries
  178. # ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads
  179. #
  180. # ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/
  181. # ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/
  182. # ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/
  183. #
  184. # # ln -s /usr/share/munin/plugins/fail2ban /etc/munin/plugins/
  185. #
  186. # # dbdir, htmldir, logdir, rundir, and tmpldir
  187. # sed -i 's/^#dbdir/dbdir/' /etc/munin/munin.conf
  188. # sed -i 's/^#htmldir/htmldir/' /etc/munin/munin.conf
  189. # sed -i 's/^#logdir/logdir/' /etc/munin/munin.conf
  190. # sed -i 's/^#rundir/rundir/' /etc/munin/munin.conf
  191. # sed -i 's/^#tmpldir/tmpldir/' /etc/munin/munin.conf
  192. #
  193. # sed -i "s/^\[localhost.localdomain\]/[${HOSTNAME}]/" /etc/munin/munin.conf
  194. #
  195. # # ln -s /etc/munin/apache24.conf /etc/apache2/conf-enabled/munin.conf
  196. # sed -i 's/Require local/Require all granted\nOptions FollowSymLinks SymLinksIfOwnerMatch/g' /etc/munin/apache24.conf
  197. # htpasswd -c /etc/munin/munin-htpasswd admin
  198. # sed -i 's/Require all granted/AuthUserFile \/etc\/munin\/munin-htpasswd\nAuthName "Munin"\nAuthType Basic\nRequire valid-user/g' /etc/munin/apache24.conf
  199. #
  200. #
  201. # service apache2 restart
  202. # service munin-node restart
  203. # echo -e "\033[92;1mMunin installed\033[Om"
  204. #
  205. # echo -e "\033[35;1mInstalling Monit \033[0m"
  206. # sleep 3
  207. # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/2/
  208. # apt-get --yes install monit
  209. # # TODO setup monit rc
  210. # cat "$_assets"/monitrc > /etc/monit/monitrc
  211. #
  212. # # TODO setup webaccess
  213. # passok=0
  214. # while [ "$passok" = "0" ]
  215. # do
  216. # echo -n "Write web access password to monit"
  217. # read passwda
  218. # echo -n "ReWrite web access password to monit"
  219. # read passwdb
  220. # if [ "$passwda" = "$passwdb" ]; then
  221. # sed -i 's/PASSWD_TO_REPLACE/$passwda/g' /etc/monit/monitrc
  222. # passok=1
  223. # else
  224. # echo "pass words don't match, please try again"
  225. # fi
  226. # done
  227. #
  228. # # TODO setup mail settings
  229. # sed -i "s/server1\.example\.com/$HOSTNAME/g" /etc/monit/monitrc
  230. #
  231. # mkdir /var/www/html/monit
  232. # echo "hello" > /var/www/html/monit/token
  233. #
  234. # service monit start
  235. #
  236. # echo -e "\033[92;1mMonit installed\033[Om"
  237. # echo -e '\033[35m
  238. # ___ __ __
  239. # / |_ _______/ /_____ _/ /_
  240. # / /| | | /| / / ___/ __/ __ `/ __/
  241. # / ___ | |/ |/ (__ ) /_/ /_/ / /_
  242. # /_/ |_|__/|__/____/\__/\__,_/\__/
  243. # \033[0m'
  244. # echo -e "\033[35;1mInstalling Awstat \033[0m"
  245. # sleep 3
  246. # apt-get --yes install awstats
  247. # # Configure AWStats
  248. # temp=`grep -i sitedomain /etc/awstats/awstats.conf.local | wc -l`
  249. # if [ $temp -lt 1 ]; then
  250. # echo SiteDomain="$_domain" >> /etc/awstats/awstats.conf.local
  251. # fi
  252. # # Disable Awstats from executing every 10 minutes. Put a hash in front of any line.
  253. # sed -i 's/^[^#]/#&/' /etc/cron.d/awstats
  254. # echo -e "\033[92;1mAwstat installed\033[Om"