lemp.sh 8.8 KB

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