lemp.sh 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. systemctl enable redis-server
  116. systemctl restart redis-server
  117. echo -e "\033[92;1mRedis installed\033[Om"
  118. echo -e '\033[35m
  119. ______
  120. / ____/___ ____ ___ ____ ____ ________ _____
  121. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  122. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  123. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  124. /_/
  125. \033[0m'
  126. echo -e "\033[35;1mInstalling Composer \033[0m"
  127. sleep 3
  128. export COMPOSER_HOME=/usr/local/composer
  129. curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  130. echo -e "\033[92;1mComposer installed\033[Om"
  131. echo -e '\033[35m
  132. ____ __
  133. / __ \_______ _______/ /_
  134. / / / / ___/ / / / ___/ __ \
  135. / /_/ / / / /_/ (__ ) / / /
  136. /_____/_/ \__,_/____/_/ /_/
  137. \033[0m'
  138. echo -e "\033[35;1mInstalling Drush and DrupalConsole\033[0m"
  139. sleep 3
  140. curl https://drupalconsole.com/installer -L -o /usr/local/bin/drupal
  141. chmod +x /usr/local/bin/drupal
  142. curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o /usr/local/bin/drush
  143. chmod +x /usr/local/bin/drush
  144. echo -e "\033[92;1mDrush and DrupalConsoleinstalled\033[Om"
  145. # TODO supervising
  146. # echo -e '\033[35m
  147. # __ ___ _ __ __ __ ___ _
  148. # / |/ /__ ___ (_) /_ _/_/ / |/ /_ _____ (_)__
  149. # / /|_/ / _ \/ _ \/ / __/ _/_/ / /|_/ / // / _ \/ / _ \
  150. # /_/ /_/\___/_//_/_/\__/ /_/ /_/ /_/\_,_/_//_/_/_//_/
  151. # \033[0m'
  152. # echo -e "\033[35;1mInstalling Munin \033[0m"
  153. # sleep 3
  154. # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/
  155. # apt-get --yes --force-yes install munin munin-node munin-plugins-extra
  156. # # Configure Munin
  157. # # enable plugins
  158. # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_
  159. # ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes
  160. # ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/mysql_innodb
  161. # ln -s /usr/share/munin/plugins/mysql_isam_space_ /etc/munin/plugins/mysql_isam_space_
  162. # ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries
  163. # ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/mysql_slowqueries
  164. # ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads
  165. #
  166. # ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/
  167. # ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/
  168. # ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/
  169. #
  170. # # ln -s /usr/share/munin/plugins/fail2ban /etc/munin/plugins/
  171. #
  172. # # dbdir, htmldir, logdir, rundir, and tmpldir
  173. # sed -i 's/^#dbdir/dbdir/' /etc/munin/munin.conf
  174. # sed -i 's/^#htmldir/htmldir/' /etc/munin/munin.conf
  175. # sed -i 's/^#logdir/logdir/' /etc/munin/munin.conf
  176. # sed -i 's/^#rundir/rundir/' /etc/munin/munin.conf
  177. # sed -i 's/^#tmpldir/tmpldir/' /etc/munin/munin.conf
  178. #
  179. # sed -i "s/^\[localhost.localdomain\]/[${HOSTNAME}]/" /etc/munin/munin.conf
  180. #
  181. # # ln -s /etc/munin/apache24.conf /etc/apache2/conf-enabled/munin.conf
  182. # sed -i 's/Require local/Require all granted\nOptions FollowSymLinks SymLinksIfOwnerMatch/g' /etc/munin/apache24.conf
  183. # htpasswd -c /etc/munin/munin-htpasswd admin
  184. # sed -i 's/Require all granted/AuthUserFile \/etc\/munin\/munin-htpasswd\nAuthName "Munin"\nAuthType Basic\nRequire valid-user/g' /etc/munin/apache24.conf
  185. #
  186. #
  187. # service apache2 restart
  188. # service munin-node restart
  189. # echo -e "\033[92;1mMunin installed\033[Om"
  190. #
  191. # echo -e "\033[35;1mInstalling Monit \033[0m"
  192. # sleep 3
  193. # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/2/
  194. # apt-get --yes --force-yes install monit
  195. # # TODO setup monit rc
  196. # cat "$_assets"/monitrc > /etc/monit/monitrc
  197. #
  198. # # TODO setup webaccess
  199. # passok=0
  200. # while [ "$passok" = "0" ]
  201. # do
  202. # echo -n "Write web access password to monit"
  203. # read passwda
  204. # echo -n "ReWrite web access password to monit"
  205. # read passwdb
  206. # if [ "$passwda" = "$passwdb" ]; then
  207. # sed -i 's/PASSWD_TO_REPLACE/$passwda/g' /etc/monit/monitrc
  208. # passok=1
  209. # else
  210. # echo -e "pass words don't match, please try again"
  211. # fi
  212. # done
  213. #
  214. # # TODO setup mail settings
  215. # sed -i "s/server1\.example\.com/$HOSTNAME/g" /etc/monit/monitrc
  216. #
  217. # mkdir /var/www/html/monit
  218. # echo -e "hello" > /var/www/html/monit/token
  219. #
  220. # service monit start
  221. #
  222. # echo -e "\033[92;1mMonit installed\033[Om"
  223. # echo -e '\033[35m
  224. # ___ __ __
  225. # / |_ _______/ /_____ _/ /_
  226. # / /| | | /| / / ___/ __/ __ `/ __/
  227. # / ___ | |/ |/ (__ ) /_/ /_/ / /_
  228. # /_/ |_|__/|__/____/\__/\__,_/\__/
  229. # \033[0m'
  230. # echo -e "\033[35;1mInstalling Awstat \033[0m"
  231. # sleep 3
  232. # apt-get --yes --force-yes install awstats
  233. # # Configure AWStats
  234. # temp=`grep -i sitedomain /etc/awstats/awstats.conf.local | wc -l`
  235. # if [ $temp -lt 1 ]; then
  236. # echo SiteDomain="$_domain" >> /etc/awstats/awstats.conf.local
  237. # fi
  238. # # Disable Awstats from executing every 10 minutes. Put a hash in front of any line.
  239. # sed -i 's/^[^#]/#&/' /etc/cron.d/awstats
  240. # echo -e "\033[92;1mAwstat installed\033[Om"