Last active
November 28, 2024 22:20
-
-
Save eusonlito/1f3dc8d667f30709b457 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "`whoami`" != 'root' ]; then | |
echo "" | |
echo "This script only can be executed by root" | |
echo "" | |
exit 1 | |
fi | |
cat <<EOF > /etc/environment | |
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | |
LC_ALL=en_US.UTF-8 | |
LANG=en_US.UTF-8 | |
EOF | |
echo 'export LC_ALL="en_US.UTF-8"' >> /root/.bashrc | |
update-locale LANG=en_US.UTF-8 | |
dpkg-reconfigure locales | |
cd /etc/apt/ | |
sed -i -e 's/^deb-src/# deb-src/' \ | |
-e 's/#\s*deb /deb /' \ | |
-e 's/^deb cdrom.*//' \ | |
sources.list | |
cd /usr/local/bin/ | |
cat <<EOF > update | |
apt-get clean | |
apt-get autoclean | |
apt-get update && apt-get dist-upgrade --assume-yes --allow-unauthenticated | |
apt-get autoremove --assume-yes | |
EOF | |
chmod 700 update | |
update | |
mysqlpassword=`cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 18 | head -n 1` | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password $mysqlpassword" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $mysqlpassword" | |
cat <<EOF > $HOME/.my.cnf | |
[mysql] | |
user=root | |
password=$mysqlpassword | |
EOF | |
export DEBIAN_FRONTEND=noninteractive | |
add-apt-repository ppa:ondrej/apache2 | |
add-apt-repository ppa:ondrej/php | |
wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb -O /tmp/mysql-apt.deb | |
dpkg -i /tmp/mysql-apt.deb | |
apt-get install -y debconf-utils apache2 curl vim-scripts vim-tiny ntpdate \ | |
language-pack-en htop lynx screen tree rsync mysql-server \ | |
php8.4 php8.4-bcmath php8.4-bz2 php8.4-cli php8.4-common php8.4-curl \ | |
php8.4-gd php8.4-fpm php8.4-imagick php8.4-intl php8.4-memcached php8.4-mbstring \ | |
php8.4-mysql php8.4-opcache php8.4-pgsql php8.4-readline php8.4-redis php8.4-tidy \ | |
php8.4-xml php8.4-soap php8.4-xsl php8.4-zip php-apcu php-imagick \ | |
php-memcached php-redis memcached redis-server | |
if [ ! -d /etc/apache2 ] \ | |
|| [ ! -d /etc/php/8.4 ] \ | |
|| [ ! -d /etc/mysql ]; then | |
echo "" | |
echo "Installation failed. Please check previous errors before continue." | |
echo "" | |
exit 1 | |
fi | |
cd /etc/apache2/ | |
if [ -f conf.d/security ]; then | |
security=conf.d/security | |
elif [ -f conf-enabled/security.conf ]; then | |
security=conf-enabled/security.conf | |
else | |
security='' | |
fi | |
if [ "$security" != "" ]; then | |
sed -i -e 's/^ServerTokens.*$/ServerTokens Prod/' \ | |
-e 's/^ServerSignature.*$/ServerSignature Off/' \ | |
-e 's/^TraceEnable.*$/TraceEnable Off/' \ | |
$security | |
fi | |
a2enmod deflate expires filter headers include proxy_fcgi rewrite setenvif socache_shmcb ssl | |
cd /etc/php/8.4/fpm/ | |
timezone=`cat /etc/timezone | sed -e 's#/#\\\/#'` | |
sed -i -e 's/^expose_php =.*$/expose_php = Off/' \ | |
-e 's/^max_execution_time =.*$/max_execution_time = 180/' \ | |
-e 's/^max_input_time =.*$/max_input_time = 240/' \ | |
-e 's/^memory_limit =.*$/memory_limit = 512M/' \ | |
-e 's/^upload_max_filesize =.*$/upload_max_filesize = 200M/' \ | |
-e 's/^post_max_size =.*$/post_max_size = 2G/' \ | |
-e 's/^.*date\.timezone =.*$/date.timezone = "'$timezone'"/' \ | |
-e 's/^.*max_input_vars =.*$/max_input_vars = 10000/' \ | |
php.ini | |
cp php.ini /etc/php/8.4/cli/ | |
service apache2 restart | |
echo "" | |
echo "Finished" | |
echo "" | |
echo "MySQL password was stored in $HOME/.my.cnf" | |
echo "" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment