- Replace $EUID with $(id -u) for root checks across all bin/*.sh and install.sh: dash (Debian's /bin/sh) never sets $EUID, so the check was silently broken everywhere. - lemp.sh: make apt-get upgrade non-interactive (--yes), align the Redis PHP module and php-fpm restart with $PHP_VERSION instead of a hardcoded 8.1, and template the nginx PHP-FPM socket path via a PHP_FPM_SOCK placeholder substituted at install time. - nginx-phpmyadmin.conf: fix docroot to match the actual phpMyAdmin symlink location created by lemp.sh. - mysql-db.sh: inline the root check instead of sourcing the nonexistent bin/checkroot.sh. - webhook.sh: fix chowm typo (chown). - urbackup.sh: copy the systemd unit from assets/ instead of a relative path to a file that doesn't exist in the repo. - _addUserSite.sh: fix invalid `$var=value` assignment and an empty if-block that was a POSIX sh syntax error. Also carries over pending fixes to deploy-drupal.sh (drush now invoked via vendor/bin/drush) and gitbarrerepos.sh (comment cleanup). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
243 lines
8.6 KiB
Bash
Executable File
243 lines
8.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
echo -e '\033[35m
|
|
__
|
|
/ /__ ____ ___ ____
|
|
/ / _ \/ __ `__ \/ __ \
|
|
/ / __/ / / / / / /_/ /
|
|
/_/\___/_/ /_/ /_/ .___/
|
|
/_/
|
|
\033[0m'
|
|
echo -e "\033[35;1mLEMP server (Nginx Mysql Php-fpm) \033[0m"
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "Please run as root"
|
|
exit
|
|
fi
|
|
|
|
# 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 '\033[35m
|
|
____ __ ______
|
|
/ __ \/ / / / __ \
|
|
/ /_/ / /_/ / /_/ /
|
|
/ ____/ __ / ____/
|
|
/_/ /_/ /_/_/
|
|
\033[0m'
|
|
|
|
echo -e "\033[35;1mInstalling SURY \033[0m"
|
|
sleep 3
|
|
|
|
apt-get --yes install ca-certificates apt-transport-https software-properties-common curl lsb-release
|
|
curl -sSL https://packages.sury.org/php/README.txt | bash -x
|
|
apt-get update && apt-get --yes upgrade
|
|
|
|
echo -e "\033[35;1mInstalling PHP \033[0m"
|
|
sleep 3
|
|
|
|
|
|
|
|
# mv: cannot stat '/etc/php/7.0/fpm/php.ini': No such file or directory
|
|
# cp: cannot create regular file '/etc/php/7.0/fpm/php.ini': No such file or directory
|
|
# Configuring PHP
|
|
# Failed to enable unit: Unit file php7.0-fpm.service does not exist.
|
|
# Failed to start php7.0-fpm.service: Unit php7.0-fpm.service not found.
|
|
|
|
# apt-get --yes install php7.4-fpm php7.4-mysql php7.4-opcache php7.4-curl php7.4-mbstring php7.4-zip php7.4-xml php7.4-gd php-memcached php7.4-imagick php7.4-apcu
|
|
# php7.4-mcrypt ??
|
|
|
|
# apt-get --yes install php8.1-fpm php8.1-mysql php8.1-opcache php8.1-curl php8.1-mbstring php8.1-zip php8.1-xml php8.1-gd php8.1-memcached php8.1-imagick php8.1-apcu php8.1-redis php8.1-bz2 php8.1-bcmath
|
|
|
|
# apt-get --yes install php8.2-fpm php8.2-mysql php8.2-opcache php8.2-curl php8.2-mbstring php8.2-zip php8.2-xml php8.2-gd php-memcached php8.2-imagick php8.2-apcu php8.2-redis php8.2-bz2 php8.2-bcmath
|
|
|
|
# apt-get --yes install php8.3-fpm php8.3-mysql php8.3-opcache php8.3-curl php8.3-mbstring php8.3-zip php8.3-xml php8.3-gd php8.3-memcached php8.3-imagick php8.3-apcu php8.3-redis php8.3-bz2 php8.3-bcmath
|
|
|
|
PHP_VERSION="8.4"
|
|
|
|
apt-get --yes install php${PHP_VERSION}-fpm php${PHP_VERSION}-mysql php${PHP_VERSION}-opcache php${PHP_VERSION}-curl php${PHP_VERSION}-mbstring php${PHP_VERSION}-zip php${PHP_VERSION}-xml php${PHP_VERSION}-gd php${PHP_VERSION}-memcached php${PHP_VERSION}-imagick php${PHP_VERSION}-apcu php${PHP_VERSION}-redis php${PHP_VERSION}-bz2 php${PHP_VERSION}-bcmath
|
|
|
|
|
|
mv /etc/php/${PHP_VERSION}/fpm/php.ini /etc/php/${PHP_VERSION}/fpm/php.ini.back
|
|
cp "$_assets"/php${PHP_VERSION}-fpm.ini /etc/php/${PHP_VERSION}/fpm/php.ini
|
|
|
|
echo "Configuring PHP"
|
|
|
|
mkdir /var/log/php
|
|
chown www-data /var/log/php
|
|
cp "$_assets"/logrotate-php /etc/logrotate.d/php
|
|
|
|
systemctl enable php${PHP_VERSION}-fpm
|
|
systemctl start php${PHP_VERSION}-fpm
|
|
|
|
# echo "Installing memecached"
|
|
# replaced by redis
|
|
# apt-get --yes install memcached
|
|
# sed -i "s/-m\s64/-m 128/g" /etc/memcached.conf
|
|
#
|
|
# systemctl start memcached
|
|
|
|
echo -e "\033[92;1mphp installed\033[Om"
|
|
|
|
echo -e '\033[35m
|
|
_ __ _
|
|
/ | / /___ _(_)___ _ __
|
|
/ |/ / __ `/ / __ \| |/_/
|
|
/ /| / /_/ / / / / /> <
|
|
/_/ |_/\__, /_/_/ /_/_/|_|
|
|
/____/
|
|
\033[0m'
|
|
echo -e "\033[35;1mInstalling Nginx \033[0m"
|
|
sleep 3
|
|
apt-get --yes install nginx
|
|
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.ori
|
|
cp "$_assets"/default.nginxconf /etc/nginx/sites-available/default
|
|
sed -i "s/PHP_FPM_SOCK/php${PHP_VERSION}-fpm.sock/g" /etc/nginx/sites-available/default
|
|
|
|
systemctl enable nginx
|
|
systemctl restart nginx
|
|
echo -e "\033[92;1mNginx installed\033[Om"
|
|
|
|
|
|
|
|
while [ "$installmysql" != "yes" ] && [ "$installmysql" != "no" ]
|
|
do
|
|
echo -n "install mysql? [yes|no] "
|
|
read installmysql
|
|
# installmysql=${installmysql:-y}
|
|
done
|
|
if [ "$installmysql" = "yes" ]; then
|
|
|
|
echo -e '\033[35m
|
|
__ ___ __
|
|
/ |/ /_ ___________ _/ /
|
|
/ /|_/ / / / / ___/ __ `/ /
|
|
/ / / / /_/ (__ ) /_/ / /
|
|
/_/ /_/\__, /____/\__, /_/
|
|
/____/ /_/
|
|
\033[0m'
|
|
echo -e "\033[35;1minstalling Mysql \033[0m"
|
|
sleep 3
|
|
apt-get --yes install mariadb-server
|
|
mysql_secure_installation
|
|
|
|
cp "$_assets"/mysql/innodb-file-per-table.cnf /etc/mysql/conf.d/
|
|
|
|
# you may increase memory
|
|
# innodb_buffer_pool_size = 1024M
|
|
|
|
systemctl enable mariadb.service
|
|
systemctl restart mariadb.service
|
|
echo -e "\033[92;1mmysql installed\033[Om"
|
|
|
|
echo -e '\033[35m
|
|
__ __ ___ ___ __ _
|
|
____ / /_ ____ / |/ /_ __/ | ____/ /___ ___ (_)___
|
|
/ __ \/ __ \/ __ \/ /|_/ / / / / /| |/ __ / __ `__ \/ / __ \
|
|
/ /_/ / / / / /_/ / / / / /_/ / ___ / /_/ / / / / / / / / / /
|
|
/ .___/_/ /_/ .___/_/ /_/\__, /_/ |_\__,_/_/ /_/ /_/_/_/ /_/
|
|
/_/ /_/ /____/
|
|
\033[0m'
|
|
echo -e "\033[35;1mInstalling phpMyAdmin \033[0m"
|
|
##### Building dependency tree
|
|
##### Reading state information... Done
|
|
##### Package phpmyadmin is not available, but is referred to by another package.
|
|
##### This may mean that the package is missing, has been obsoleted, or
|
|
##### is only available from another source
|
|
#####
|
|
##### E: Package 'phpmyadmin' has no installation candidate
|
|
##### cp: missing destination file operand after '/root/debian-web-server/assets/nginx-phpmyadmin.conf'
|
|
##### Try 'cp --help' for more information.
|
|
|
|
# TODO no pma package available :(
|
|
apt-get --yes install phpmyadmin
|
|
ln -s /usr/share/phpmyadmin /var/www/html/
|
|
cp "$_assets"/nginx-phpmyadmin.conf /etc/nginx/sites-available/phpmyadmin.conf
|
|
sed -i "s/PHP_FPM_SOCK/php${PHP_VERSION}-fpm.sock/g" /etc/nginx/sites-available/phpmyadmin.conf
|
|
|
|
echo -e "\033[92;1mphpMyAdmin installed\033[Om"
|
|
echo -e "\033[92;1mYou can access it at yourip/phpmyadmin\033[Om"
|
|
|
|
# install from source
|
|
# apt-get --yes install php-{mbstring,zip,gd,xml,pear,gettext,cgi}
|
|
# cd /var/www/html/
|
|
# wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip
|
|
# unzip phpMyAdmin-latest-all-languages.zip
|
|
# mv phpMyAdmin-*-all-languages pma
|
|
# rm phpMyAdmin-latest-all-languages.zip
|
|
# # cp "$_assets"/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf
|
|
# # ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
|
|
# echo -e "\033[92;1mphpMyAdmin installed\033[Om"
|
|
# echo -e "\033[92;1mYou can access it at yourip/pma\033[Om"
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo -e '\033[35m
|
|
____ ___
|
|
/ __ \___ ____/ (_)____
|
|
/ /_/ / _ \/ __ / / ___/
|
|
/ _, _/ __/ /_/ / (__ )
|
|
/_/ |_|\___/\__,_/_/____/
|
|
\033[0m'
|
|
echo -e "\033[35;1mInstalling Redis \033[0m"
|
|
sleep 3
|
|
apt-get --yes install redis-server php${PHP_VERSION}-redis
|
|
|
|
# TODO set maxmemory=2gb
|
|
# TODO set maxmemory-policy=volatile-lru
|
|
# TODO comment all save line
|
|
|
|
# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
|
|
# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
|
|
# WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
|
|
|
|
# https://blog.opstree.com/2019/04/16/redis-best-practices-and-performance-tuning/
|
|
|
|
systemctl enable redis-server
|
|
systemctl restart redis-server
|
|
systemctl restart php${PHP_VERSION}-fpm
|
|
echo -e "\033[92;1mRedis installed\033[Om"
|
|
|
|
echo -e '\033[35m
|
|
______
|
|
/ ____/___ ____ ___ ____ ____ ________ _____
|
|
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
|
|
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
|
|
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
|
|
/_/
|
|
\033[0m'
|
|
echo -e "\033[35;1mInstalling Composer \033[0m"
|
|
sleep 3
|
|
export COMPOSER_HOME=/usr/local/composer
|
|
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
|
|
echo -e "\033[92;1mComposer installed\033[Om"
|
|
|
|
|
|
echo -e '\033[35m
|
|
____ __
|
|
/ __ \_______ _______/ /_
|
|
/ / / / ___/ / / / ___/ __ \
|
|
/ /_/ / / / /_/ (__ ) / / /
|
|
/_____/_/ \__,_/____/_/ /_/
|
|
\033[0m'
|
|
echo -e "\033[35;1mInstalling Drush\033[0m"
|
|
sleep 3
|
|
# curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o /usr/local/bin/drush
|
|
wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar
|
|
chmod +x /usr/local/bin/drush
|
|
echo -e "\033[92;1mDrush\033[Om"
|