lemp.sh 8.3 KB

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