#!/bin/sh echo -e ' _ | |___ _ __ _ __ | / -_) ' \| '_ \ |_\___|_|_|_| .__/ |_| ' echo -e "LEMP server (Nginx Mysql Php-fpm)" . bin/checkroot.sh # get the current position _cwd="$(pwd)" # check for assets forlder _assets="$_cwd/assets" if [ ! -d "$_assets" ]; then _assets="$_cwd/../assets" if [ ! -d "$_assets" ]; then echo "!! can't find assets directory !!" exit fi fi sleep 2 echo -e ' _ _ __ _ _ ___ __ _| | | . \ || (_-> /etc/apk/repositories # echo -e "mariadb<10.1.99\nmariadb-client<10.1.99\nmariadb-common<10.1.99" >> /etc/apk/world sed -i "s|^mariadb$|mariadb<10.1.99|g" /etc/apk/world sed -i "s|^mariadb-client$|mariadb-client<10.1.99|g" /etc/apk/world sed -i "s|^mariadb-common$|mariadb-common<10.1.99|g" /etc/apk/world apk update && apk upgrade fi mysql_install_db --user=mysql --datadir="/var/lib/mysql" rc-update add mariadb service mariadb start mysql_secure_installation sed -i "s|max_allowed_packet\s*=\s*1M|max_allowed_packet = 200M|g" /etc/mysql/my.cnf sed -i "s|max_allowed_packet\s*=\s*16M|max_allowed_packet = 200M|g" /etc/mysql/my.cnf service mariadb restart echo -e "mysql installed" echo -e ' _ _ __| |_ _ __ | `_ \ ` \| `_ \ | .__/_||_| .__/ |_| |_| ' echo -e "Installing PHP 7.0" sleep 3 apk add php7 php7-fpm php7-pdo_mysql php7-opcache php7-curl php7-mbstring php7-zip php7-xml php7-gd php7-mcrypt php7-imagick php7-phar php7-json php7-dom php7-tokenizer php7-iconv php7-xmlwriter php7-simplexml # to make php5 availabe # echo "http://dl-cdn.alpinelinux.org/alpine/v3.7/main" >> /etc/apk/repositories # apk add php5-fpm php5-pdo_mysql php5-opcache php5-curl php5-zip php5-xml php5-gd php5-mcrypt php5-phar php5-json php5-dom php5-iconv echo -e "Configuring PHP" sed -i "s/memory_limit\ =\ 128M/memory_limit = 512M/g" /etc/php7/php.ini sed -i "s/post_max_size\ =\ 8M/post_max_size = 20M/g" /etc/php7/php.ini sed -i "s/upload_max_filesize\ =\ 2M/upload_max_filesize = 20M/g" /etc/php7/php.ini TIMEZONE="Europe/Paris" sed -i "s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i" /etc/php7/php.ini sed -i "s|user = nobody|user = www|i" /etc/php7/php-fpm.d/www.conf sed -i "s|group = nobody|group = www|i" /etc/php7/php-fpm.d/www.conf rc-update add php-fpm7 service php-fpm7 start echo -e "php installed" echo -e ' _ __ __ _ _ _ _ __| |_ _ __| \/ |_ _ /_\ __| |_ __ (_)_ _ | `_ \ ` \| `_ \ |\/| | || |/ _ \/ _` | ` \| | ` \ | .__/_||_| .__/_| |_|\_, /_/ \_\__,_|_|_|_|_|_||_| |_| |_| |__/ ' echo -e "Installing phpMyAdmin" apk add phpmyadmin php7-mysqli service php-fpm7 restart chmod +r /etc/phpmyadmin/config.inc.php # /** # * This is needed for cookie based authentication to encrypt password in # * cookie. Needs to be 32 chars long. # */ _blowfish="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)" sed -i "s|$cfg['blowfish_secret'] = ''|$cfg['blowfish_secret'] = '${_blowfish}'|i" /etc/phpmyadmin/config.inc.php mkdir /usr/share/webapps/phpmyadmin/tmp chmod 777 /usr/share/webapps/phpmyadmin/tmp # finishing the pma install after nginx echo -e ' _ _ _ _ ___ __| (_)___ | `_/ -_) _` | (_-< |_| \___\__,_|_/__/ ' echo -e "Installing Redis" sleep 3 apk add redis php7-pecl-redis # TODO set maxmemory=2gb # TODO set maxmemory-policy=volatile-lru # TODO comment all save line rc-update add redis service redis start service php-fpm7 restart echo -e "Redis installed" echo -e ' __ ___ _ __ _ __ ___ ___ ___ _ _ / _/ _ \ ` \| `_ \/ _ (_- /etc/nginx/passwds echo -e "phpMyAdmin installed" echo -e "You can access it at yourip/phpmyadmin" echo -e "please note the credentials user: pma passwd:$_pass" sleep 3