Last active
March 5, 2025 10:04
-
-
Save alhoqbani/9d4efc303800004c1632c01394911556 to your computer and use it in GitHub Desktop.
Bash script to install LAMP on ubuntu
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
#!/usr/bin/env bash | |
C='\033[1;34m' # Purple Color | |
NC='\033[0m' # No Color | |
echo '##Installation: statrs' >> installation.log | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password root" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root" | |
apt-get update -q &>> installation.log | |
#install utilities | |
echo '##Installation: utilities' >> installation.log | |
sudo apt-get install -y vim curl tmux wget unzip htop | |
# Inatall apache2 in mysql | |
echo '##Installation: apache2' >> installation.log | |
echo -e "${C}Installing apche2 and mysql...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
apache2 &>> installation.log | |
echo '##Installation: mysql' >> installation.log | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
mysql-server &>> installation.log | |
# Install php7.0 | |
echo '##Installation: php' >> installation.log | |
echo -e "${C}Installing php7.0...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
php7.0 \ | |
libapache2-mod-php7.0 \ | |
php7.0-cli \ | |
php7.0-common \ | |
php7.0-mbstring \ | |
php7.0-curl \ | |
php7.0-gd \ | |
php7.0-intl \ | |
php7.0-xml \ | |
php7.0-mysql \ | |
php7.0-mcrypt \ | |
php7.0-fpm \ | |
php7.0-sqlite \ | |
php7.0-zip &>> installation.log | |
rm /var/www/html/index.html | |
echo '<?php phpinfo();' > /var/www/html/index.php | |
# Inatall Composer | |
echo -e "${C}Installing Composer...${NC}" | |
echo '##Installation: Composer' >> installation.log | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
echo -e "${C}$RESULT${NC}" | |
mv composer.phar /usr/local/bin/composer | |
echo -e "${C} Done !! ${NC}" |
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
#!/usr/bin/env bash | |
C='\033[1;34m' # Purple Color | |
NC='\033[0m' # No Color | |
echo '##Installation: statrs' >> installation.log | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password root" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root" | |
apt-get update -q &>> installation.log | |
#install utilities | |
echo '##Installation: utilities' >> installation.log | |
sudo add-apt-repository -y ppa:nginx/development | |
sudo add-apt-repository -y ppa:ondrej/php | |
sudo apt-get update | |
sudo apt-get install -y vim curl tmux wget unzip htop tree | |
# Inatall nginx in mysql | |
echo '##Installation: nginx' >> installation.log | |
echo -e "${C}Installing nginx and mysql...${NC}" | |
echo '##Installation: mysql' >> installation.log | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
mysql-server &>> installation.log | |
# Install php7.2 | |
echo '##Installation: php' >> installation.log | |
echo -e "${C}Installing php7.0...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
git tmux vim curl wget zip unzip htop tree \ | |
nginx \ | |
php7.2-fpm \ | |
php7.2-cli \ | |
php7.2-sqlite3 \ | |
php7.2-mysql \ | |
php7.2-gd \ | |
php7.2-curl \ | |
php7.2-memcached \ | |
php7.2-imap \ | |
php7.2-mbstring \ | |
php7.2-xml \ | |
php7.2-zip \ | |
php7.2-bcmath \ | |
php7.2-soap \ | |
php7.2-intl \ | |
php7.2-readline \ | |
php7.2-xdebug \ | |
&>> installation.log | |
# Composer | |
php -r "readfile('http://getcomposer.org/installer');" | sudo php -- --install-dir=/usr/bin/ --filename=composer | |
&>> installation.log | |
rm /var/www/html/index.html | |
echo '<?php phpinfo();' > /var/www/html/index.php | |
# Inatall Composer | |
echo -e "${C}Installing Composer...${NC}" | |
echo '##Installation: Composer' >> installation.log | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
echo -e "${C}$RESULT${NC}" | |
mv composer.phar /usr/local/bin/composer | |
# Install redis | |
sudo apt-add-repository -y ppa:chris-lea/redis-server | |
sudo apt-get update | |
sudo apt-get install -y redis-server | |
echo -e "${C} Done !! ${NC}" |
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
# Swap | |
sudo fallocate -l 1G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab | |
echo "vm.swappiness=30" | sudo tee -a /etc/sysctl.conf | |
echo "vm.vfs_cache_pressure=50" | sudo tee -a /etc/sysctl.conf |
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
#!/usr/bin/env bash | |
C='\033[1;34m' # Purple Color | |
NC='\033[0m' # No Color | |
echo '##Installation: statrs' >> installation.log | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password root" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root" | |
apt-get update -q &>> installation.log | |
#install utilities | |
echo '##Installation: utilities' >> installation.log | |
sudo apt-get install -y vim curl tmux wget unzip htop | |
# Inatall apache2 in mysql | |
echo '##Installation: apache2' >> installation.log | |
echo -e "${C}Installing apche2 and mysql...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
apache2 &>> installation.log | |
echo '##Installation: mysql' >> installation.log | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
mysql-server &>> installation.log | |
# Install php7.1 | |
apt-add-repository ppa:/ondrej/php | |
apt-get update | |
echo '##Installation: php' >> installation.log | |
echo -e "${C}Installing php7.1...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
php7.1 \ | |
libapache2-mod-php7.1 \ | |
php7.1-cli \ | |
php7.1-common \ | |
php7.1-mbstring \ | |
php7.1-curl \ | |
php7.1-gd \ | |
php7.1-intl \ | |
php7.1-xml \ | |
php7.1-mysql \ | |
php7.1-mcrypt \ | |
php7.1-sqlite \ | |
php7.1-zip &>> installation.log | |
rm /var/www/html/index.html | |
echo '<?php phpinfo();' > /var/www/html/index.php | |
# Inatall Composer | |
echo -e "${C}Installing Composer...${NC}" | |
echo '##Installation: Composer' >> installation.log | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
echo -e "${C}$RESULT${NC}" | |
mv composer.phar /usr/local/bin/composer | |
echo -e "${C} Done !! ${NC}" | |
#!/usr/bin/env bash | |
C='\033[1;34m' # Purple Color | |
NC='\033[0m' # No Color | |
echo '##Installation: statrs' >> installation.log | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password root" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root" | |
apt-get update -q &>> installation.log | |
#install utilities | |
echo '##Installation: utilities' >> installation.log | |
sudo apt-get install -y vim curl tmux wget unzip htop | |
# Inatall apache2 in mysql | |
echo '##Installation: apache2' >> installation.log | |
echo -e "${C}Installing apche2 and mysql...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
apache2 &>> installation.log | |
echo '##Installation: mysql' >> installation.log | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
mysql-server &>> installation.log | |
# Install php7.2 | |
apt-add-repository ppa:/ondrej/php | |
apt-get update | |
echo '##Installation: php' >> installation.log | |
echo -e "${C}Installing php7.1...${NC}" | |
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ | |
php7.2 \ | |
libapache2-mod-php7.2 \ | |
php7.2-cli \ | |
php7.2-common \ | |
php7.2-mbstring \ | |
php7.2-curl \ | |
php7.2-gd \ | |
php7.2-readline \ | |
php7.2-memcached \ | |
php7.2-intl \ | |
php7.2-xml \ | |
php7.2-mysql \ | |
php7.2-bcmath \ | |
php7.2-soap \ | |
php7.2-sqlite3 \ | |
php7.2-zip &>> installation.log | |
rm /var/www/html/index.html | |
echo '<?php phpinfo();' > /var/www/html/index.php | |
# Inatall Composer | |
echo -e "${C}Installing Composer...${NC}" | |
echo '##Installation: Composer' >> installation.log | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
echo -e "${C}$RESULT${NC}" | |
mv composer.phar /usr/local/bin/composer | |
# Install redis | |
sudo apt-add-repository -y ppa:chris-lea/redis-server | |
sudo apt-get update | |
sudo apt-get install -y redis-server | |
echo -e "${C} Done !! ${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment