lemp.sh 8.7 KB

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