lemp.sh 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 -e "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 --force-yes install mariadb-server
  38. mysql_secure_installation
  39. systemctl enable mariadb.service
  40. systemctl restart mariadb.service
  41. echo -e "\033[92;1mmysql installed\033[Om"
  42. echo -e '\033[35m
  43. ____ __ ______
  44. / __ \/ / / / __ \
  45. / /_/ / /_/ / /_/ /
  46. / ____/ __ / ____/
  47. /_/ /_/ /_/_/
  48. \033[0m'
  49. echo -e "\033[35;1mInstalling PHP 7.0 \033[0m"
  50. sleep 3
  51. apt-get --yes --force-yes install php7.0-fpm php7.0-mysql php7.0-opcache php7.0-curl php7.0-mbstring php7.0-zip php7.0-xml php7.0-gd php7.0-mcrypt php-memcached
  52. mv /etc/php/7.0/fpm/php.ini /etc/php/7.0/fpm/php.ini.back
  53. cp "$_assets"/php-fpm.ini /etc/php/7.0/fpm/php.ini
  54. echo -e "Configuring PHP"
  55. mkdir /var/log/php
  56. chown www-data /var/log/php
  57. cp "$_assets"/logrotate-php /etc/logrotate.d/php
  58. systemctl enable php7.0-fpm
  59. systemctl start php7.0-fpm
  60. # echo -e "Installing memecached"
  61. # replaced by redis
  62. # apt-get --yes --force-yes install memcached
  63. # sed -i "s/-m\s64/-m 128/g" /etc/memcached.conf
  64. #
  65. # systemctl start memcached
  66. echo -e "\033[92;1mphp installed\033[Om"
  67. echo -e '\033[35m
  68. _ __ _
  69. / | / /___ _(_)___ _ __
  70. / |/ / __ `/ / __ \| |/_/
  71. / /| / /_/ / / / / /> <
  72. /_/ |_/\__, /_/_/ /_/_/|_|
  73. /____/
  74. \033[0m'
  75. echo -e "\033[35;1mInstalling Nginx \033[0m"
  76. sleep 3
  77. apt-get --yes --force-yes install nginx
  78. mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.ori
  79. cp "$_assets"/default.nginxconf /etc/nginx/sites-available/default
  80. systemctl enable nginx
  81. systemctl restart nginx
  82. echo -e "\033[92;1mNginx installed\033[Om"
  83. echo -e '\033[35m
  84. __ __ ___ ___ __ _
  85. ____ / /_ ____ / |/ /_ __/ | ____/ /___ ___ (_)___
  86. / __ \/ __ \/ __ \/ /|_/ / / / / /| |/ __ / __ `__ \/ / __ \
  87. / /_/ / / / / /_/ / / / / /_/ / ___ / /_/ / / / / / / / / / /
  88. / .___/_/ /_/ .___/_/ /_/\__, /_/ |_\__,_/_/ /_/ /_/_/_/ /_/
  89. /_/ /_/ /____/
  90. \033[0m'
  91. echo -e "\033[35;1mInstalling phpMyAdmin \033[0m"
  92. apt-get --yes --force-yes install phpmyadmin
  93. ln -s /usr/share/phpmyadmin /var/www/html/
  94. # cp "$_assets"/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf
  95. # ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
  96. # echo -e "\033[35;1msecuring phpMyAdmin \033[0m"
  97. # sed -i "s/DirectoryIndex index.php/DirectoryIndex index.php\nAllowOverride all/"
  98. # cp "$_assets"/phpmyadmin_htaccess > /usr/share/phpmyadmin/.htaccess
  99. # echo -n "define a user name for phpmyadmin : "
  100. # read un
  101. # htpasswd -c /etc/phpmyadmin/.htpasswd $un
  102. # service apache2 restart
  103. echo -e "\033[92;1mphpMyAdmin installed\033[Om"
  104. echo -e "\033[92;1mYou can access it at yourip/phpmyadmin\033[Om"
  105. echo -e '\033[35m
  106. ____ ___
  107. / __ \___ ____/ (_)____
  108. / /_/ / _ \/ __ / / ___/
  109. / _, _/ __/ /_/ / (__ )
  110. /_/ |_|\___/\__,_/_/____/
  111. \033[0m'
  112. echo -e "\033[35;1mInstalling Redis \033[0m"
  113. sleep 3
  114. apt-get --yes --force-yes install redis-server php-redis
  115. # TODO set maxmemory=2gb
  116. # TODO set maxmemory-policy=volatile-lru
  117. # TODO comment all save line
  118. systemctl enable redis-server
  119. systemctl restart redis-server
  120. echo -e "\033[92;1mRedis installed\033[Om"
  121. echo -e '\033[35m
  122. ______
  123. / ____/___ ____ ___ ____ ____ ________ _____
  124. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  125. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  126. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  127. /_/
  128. \033[0m'
  129. echo -e "\033[35;1mInstalling Composer \033[0m"
  130. sleep 3
  131. export COMPOSER_HOME=/usr/local/composer
  132. curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  133. echo -e "\033[92;1mComposer installed\033[Om"
  134. echo -e '\033[35m
  135. ____ __
  136. / __ \_______ _______/ /_
  137. / / / / ___/ / / / ___/ __ \
  138. / /_/ / / / /_/ (__ ) / / /
  139. /_____/_/ \__,_/____/_/ /_/
  140. \033[0m'
  141. echo -e "\033[35;1mInstalling Drush and DrupalConsole\033[0m"
  142. sleep 3
  143. curl https://drupalconsole.com/installer -L -o /usr/local/bin/drupal
  144. chmod +x /usr/local/bin/drupal
  145. curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o /usr/local/bin/drush
  146. chmod +x /usr/local/bin/drush
  147. echo -e "\033[92;1mDrush and DrupalConsoleinstalled\033[Om"
  148. # TODO supervising
  149. # echo -e '\033[35m
  150. # __ ___ _ __ __ __ ___ _
  151. # / |/ /__ ___ (_) /_ _/_/ / |/ /_ _____ (_)__
  152. # / /|_/ / _ \/ _ \/ / __/ _/_/ / /|_/ / // / _ \/ / _ \
  153. # /_/ /_/\___/_//_/_/\__/ /_/ /_/ /_/\_,_/_//_/_/_//_/
  154. # \033[0m'
  155. # echo -e "\033[35;1mInstalling Munin \033[0m"
  156. # sleep 3
  157. # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/
  158. # apt-get --yes --force-yes install munin munin-node munin-plugins-extra
  159. # # Configure Munin
  160. # # enable plugins
  161. # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_
  162. # ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes
  163. # ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/mysql_innodb
  164. # ln -s /usr/share/munin/plugins/mysql_isam_space_ /etc/munin/plugins/mysql_isam_space_
  165. # ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries
  166. # ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/mysql_slowqueries
  167. # ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads
  168. #
  169. # ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/
  170. # ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/
  171. # ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/
  172. #
  173. # # ln -s /usr/share/munin/plugins/fail2ban /etc/munin/plugins/
  174. #
  175. # # dbdir, htmldir, logdir, rundir, and tmpldir
  176. # sed -i 's/^#dbdir/dbdir/' /etc/munin/munin.conf
  177. # sed -i 's/^#htmldir/htmldir/' /etc/munin/munin.conf
  178. # sed -i 's/^#logdir/logdir/' /etc/munin/munin.conf
  179. # sed -i 's/^#rundir/rundir/' /etc/munin/munin.conf
  180. # sed -i 's/^#tmpldir/tmpldir/' /etc/munin/munin.conf
  181. #
  182. # sed -i "s/^\[localhost.localdomain\]/[${HOSTNAME}]/" /etc/munin/munin.conf
  183. #
  184. # # ln -s /etc/munin/apache24.conf /etc/apache2/conf-enabled/munin.conf
  185. # sed -i 's/Require local/Require all granted\nOptions FollowSymLinks SymLinksIfOwnerMatch/g' /etc/munin/apache24.conf
  186. # htpasswd -c /etc/munin/munin-htpasswd admin
  187. # sed -i 's/Require all granted/AuthUserFile \/etc\/munin\/munin-htpasswd\nAuthName "Munin"\nAuthType Basic\nRequire valid-user/g' /etc/munin/apache24.conf
  188. #
  189. #
  190. # service apache2 restart
  191. # service munin-node restart
  192. # echo -e "\033[92;1mMunin installed\033[Om"
  193. #
  194. # echo -e "\033[35;1mInstalling Monit \033[0m"
  195. # sleep 3
  196. # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/2/
  197. # apt-get --yes --force-yes install monit
  198. # # TODO setup monit rc
  199. # cat "$_assets"/monitrc > /etc/monit/monitrc
  200. #
  201. # # TODO setup webaccess
  202. # passok=0
  203. # while [ "$passok" = "0" ]
  204. # do
  205. # echo -n "Write web access password to monit"
  206. # read passwda
  207. # echo -n "ReWrite web access password to monit"
  208. # read passwdb
  209. # if [ "$passwda" = "$passwdb" ]; then
  210. # sed -i 's/PASSWD_TO_REPLACE/$passwda/g' /etc/monit/monitrc
  211. # passok=1
  212. # else
  213. # echo -e "pass words don't match, please try again"
  214. # fi
  215. # done
  216. #
  217. # # TODO setup mail settings
  218. # sed -i "s/server1\.example\.com/$HOSTNAME/g" /etc/monit/monitrc
  219. #
  220. # mkdir /var/www/html/monit
  221. # echo -e "hello" > /var/www/html/monit/token
  222. #
  223. # service monit start
  224. #
  225. # echo -e "\033[92;1mMonit installed\033[Om"
  226. # echo -e '\033[35m
  227. # ___ __ __
  228. # / |_ _______/ /_____ _/ /_
  229. # / /| | | /| / / ___/ __/ __ `/ __/
  230. # / ___ | |/ |/ (__ ) /_/ /_/ / /_
  231. # /_/ |_|__/|__/____/\__/\__,_/\__/
  232. # \033[0m'
  233. # echo -e "\033[35;1mInstalling Awstat \033[0m"
  234. # sleep 3
  235. # apt-get --yes --force-yes install awstats
  236. # # Configure AWStats
  237. # temp=`grep -i sitedomain /etc/awstats/awstats.conf.local | wc -l`
  238. # if [ $temp -lt 1 ]; then
  239. # echo SiteDomain="$_domain" >> /etc/awstats/awstats.conf.local
  240. # fi
  241. # # Disable Awstats from executing every 10 minutes. Put a hash in front of any line.
  242. # sed -i 's/^[^#]/#&/' /etc/cron.d/awstats
  243. # echo -e "\033[92;1mAwstat installed\033[Om"