-
-
Save ankurk91/16a3d36b1afa3f9c91f02828adfedf6f to your computer and use it in GitHub Desktop.
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Ubuntu Server | |
# Run like (without sudo) - bash install_lamp.sh | |
# Script should auto terminate on errors | |
export DEBIAN_FRONTEND=noninteractive | |
echo -e "\e[96m Adding PPA \e[39m" | |
sudo add-apt-repository -y ppa:ondrej/apache2 | |
sudo add-apt-repository -y ppa:ondrej/php | |
sudo apt-get update | |
echo -e "\e[96m Installing apache \e[39m" | |
sudo apt-get -y install apache2 | |
INSTALL_PHP_VER=${1:-8.3} | |
echo -e "\e[96m Installing php - ${INSTALL_PHP_VER} \e[39m" | |
sudo apt-get -y install "php${INSTALL_PHP_VER}-cli" "libapache2-mod-php${INSTALL_PHP_VER}" | |
sudo a2enmod "php${INSTALL_PHP_VER}" | |
sudo apt-get -y install curl zip unzip | |
echo -e "\e[96m Installing php extensions \e[39m" | |
if [ "$INSTALL_PHP_VER" = "7.4" ]; then | |
sudo apt-get -y install php7.4-json php7.4-mysql php7.4-curl php7.4-ctype php7.4-uuid \ | |
php7.4-iconv php7.4-mbstring php7.4-gd php7.4-intl php7.4-xml \ | |
php7.4-zip php7.4-gettext php7.4-pgsql php7.4-bcmath php7.4-redis \ | |
php7.4-readline php7.4-soap php7.4-igbinary php7.4-msgpack \ | |
php7.4-sqlite3 | |
else | |
sudo apt-get -y install php8.3-cli php8.3-curl php8.3-ctype php8.3-uuid \ | |
php8.3-pgsql php8.3-sqlite3 php8.3-gd \ | |
php8.3-imap php8.3-mysql php8.3-mbstring php8.3-iconv \ | |
php8.3-xml php8.3-zip php8.3-bcmath php8.3-soap php8.3-gettext \ | |
php8.3-intl php8.3-readline \ | |
php8.3-msgpack php8.3-igbinary php8.3-ldap \ | |
php8.3-redis php8.3-grpc php8.3-opcache | |
fi | |
#sudo apt-get -y install php-xdebug | |
sudo phpenmod curl | |
# Enable some apache modules | |
sudo a2enmod rewrite | |
sudo a2enmod ssl | |
sudo a2enmod headers | |
echo -e "\e[96m Restart apache server to reflect changes \e[39m" | |
sudo service apache2 restart | |
# Download and install composer | |
echo -e "\e[96m Installing composer \e[39m" | |
# Notice: Still using the good old way | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --force --filename=composer | |
# Add this line to your .bash_profile | |
# export PATH=~/.composer/vendor/bin:$PATH | |
echo -e "\e[96m Installing mysql client \e[39m" | |
sudo apt install -y mysql-client | |
# Check php version | |
php -v | |
# Check apache version | |
apachectl -v | |
# Check if php is working or not | |
php -r 'echo "\nYour PHP installation is working fine.\n";' | |
# Fix composer folder permissions | |
mkdir -p ~/.composer | |
sudo chown -R "$USER" "$HOME/.composer" | |
# Check composer version | |
composer --version | |
echo -e "\e[92m Open http://localhost/ to check if apache is working or not. \e[39m" | |
# Clean up cache | |
sudo apt-get clean |
#!/bin/bash | |
# Script will auto terminate on errors | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Ubuntu 20/22/24, apache2.4, php 7.4+ | |
# Run like - bash install_phpmyadmin.sh | |
# You should have MySQL pre-installed, otherwise your will get warnings during installation | |
export DEBIAN_FRONTEND=noninteractive | |
echo -e "\e[96m Adding PPA \e[39m" | |
sudo add-apt-repository -y ppa:phpmyadmin/ppa | |
sudo apt update | |
echo -e "\e[96m Begin silent install phpMyAdmin \e[39m" | |
echo -e "\e[93m User: root, Password: root \e[39m" | |
# Set non-interactive mode | |
sudo debconf-set-selections <<<'phpmyadmin phpmyadmin/dbconfig-install boolean true' | |
sudo debconf-set-selections <<<'phpmyadmin phpmyadmin/app-password-confirm password root' | |
sudo debconf-set-selections <<<'phpmyadmin phpmyadmin/mysql/admin-pass password root' | |
sudo debconf-set-selections <<<'phpmyadmin phpmyadmin/mysql/app-pass password root' | |
sudo debconf-set-selections <<<'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | |
sudo apt-get -y install phpmyadmin | |
# Restart apache server | |
sudo service apache2 restart | |
# Clean up | |
sudo apt-get clean | |
echo -e "\e[92m phpMyAdmin installed successfully \e[39m" | |
echo -e "\e[92m Remember: password for root user is root \e[39m" |
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Ubuntu 20/22 | |
# Script will auto terminate on errors | |
# run like - bash install_version_control_git.sh | |
export DEBIAN_FRONTEND=noninteractive | |
# Install latest git | |
sudo add-apt-repository -y ppa:git-core/ppa | |
sudo apt-get update | |
sudo apt-get -y install git | |
# My Git Configs | |
git config --global --add merge.ff true | |
git config --global push.followTags true | |
git config --global core.autocrlf false | |
git config --global push.default simple | |
git config --global color.ui auto | |
git config --global branch.autosetuprebase always | |
git config --global core.compression 9 | |
git config --global credential.helper 'cache --timeout 43200' | |
git config --global core.filemode false | |
git config --global init.defaultBranch main | |
git config --global push.default current | |
git config --global core.editor "nano" | |
git config --global core.excludesfile "$HOME/.gitignore" | |
touch ~/.gitignore | |
git config --global alias.st status | |
git config --global alias.co checkout | |
git config --global alias.logout 'credential-cache exit' | |
# Clean up | |
sudo apt-get clean | |
# Check for git version | |
git --version |
#!/bin/bash | |
set -euo pipefail | |
# Use this script if the official package is no longer being updated | |
# https://askubuntu.com/questions/947805/how-to-upgrade-phpmyadmin-revisited | |
# https://docs.phpmyadmin.net/en/latest/setup.html#quick-install | |
# Note: You should install phpmyadmin with apt first | |
export DEBIAN_FRONTEND=noninteractive | |
PMA_VERSION=5.2.1 | |
cd ~ || exit | |
echo -e "\e[96m phpmyadmin installation script \e[39m" | |
echo -e "\e[96m Downloading phpmyadmin version $PMA_VERSION \e[39m" | |
wget -c https://files.phpmyadmin.net/phpMyAdmin/$PMA_VERSION/phpMyAdmin-$PMA_VERSION-english.zip -O phpMyAdmin-$PMA_VERSION-english.zip | |
echo -e "\e[96m Extracting zip \e[39m" | |
unzip -q -o phpMyAdmin-$PMA_VERSION-english.zip | |
echo -e "\e[96m Fix configs \e[39m" | |
# https://stackoverflow.com/questions/34539132/updating-phpmyadmin-blowfish-secret-via-bash-shell-script-in-linux | |
randomBlowfishSecret=$(openssl rand -base64 22) | |
sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" phpMyAdmin-$PMA_VERSION-english/config.sample.inc.php >phpMyAdmin-$PMA_VERSION-english/config.inc.php | |
echo -e "\e[96m Create missing folders \e[39m" | |
sudo mkdir -p /usr/share/phpmyadmin/tmp | |
sudo mkdir -p /var/lib/phpmyadmin/tmp | |
echo -e "\e[96m Backup old installation \e[39m" | |
sudo mv /usr/share/phpmyadmin /usr/share/phpmyadmin.bak | |
echo -e "\e[96m Move new installation \e[39m" | |
sudo mv phpMyAdmin-$PMA_VERSION-english /usr/share/phpmyadmin | |
echo -e "\e[96m Fix tmp folder ownership \e[39m" | |
sudo mkdir -p /usr/share/phpmyadmin/tmp | |
sudo mkdir -p /var/lib/phpmyadmin/tmp | |
# You might need to change group:user here | |
sudo chown -R www-data:www-data /usr/share/phpmyadmin/tmp | |
sudo chown -R www-data:www-data /var/lib/phpmyadmin/tmp | |
echo -e "\e[96m Cleanup \e[39m" | |
sudo rm -rf /usr/share/phpmyadmin.bak | |
sudo rm -rf /usr/share/phpmyadmin/setup | |
sudo rm -r phpMyAdmin-$PMA_VERSION-english.zip | |
echo "Config file location is:" | |
echo "/usr/share/phpmyadmin/config.inc.php" | |
# sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin | |
echo -e "\e[92m phpmyadmin version $PMA_VERSION installed \e[39m" |
Thank you 👍
You can run them in terminal like this ->
curl -o- https://gist.githubusercontent.com/ankurk91/16a3d36b1afa3f9c91f02828adfedf6f/raw/install_lamp_ubuntu.sh | bash
Keep php up to date
https://medium.com/code16/how-to-keep-php-updated-with-last-patch-version-on-ubuntu-62b313361c6f
Enable php-fpm
sudo apt install php8.3-fpm
sudo a2enmod proxy_fcgi
sudo a2enconf php8.3-fpm
sudo a2dismod php8.3
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
sudo a2enmod http2
sudo service apache2 restart
Optionally you can update your virtual host file to leverage http 2
<VirtualHost *:443>
Protocols h2 http/1.1
# ....
</VirtualHost>
Thanks man!
'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)
Best gist out there
can this work on Ubuntu 18.04?
@wagura-maurice it should, have not tested.
The PPA supports 18.04
https://launchpad.net/~ondrej/+archive/ubuntu/apache2?field.series_filter=bionic
You can try this method to run it in the terminal
wget https://gist.github.com/ankurk91/16a3d36b1afa3f9c91f02828adfedf6f/raw/94a6946aaeafa07a9eb63badd5590d4bb9e9e2a4/install_lamp_ubuntu.sh
chmod +x /path/to/file/install_lamp_ubuntu.sh
./install_lamp_ubuntu
Enjoy
Thank's!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Work for me very good!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DOESNT INSTALL MYSQL......!!!
LAMP means Linux Apache Myql PHP , but the lamp script doesnt install mysql,
after installing and trying
mysql -v
Command 'mysql' not found, but can be installed with:
apt install mysql-client-core-8.0 # version 8.0.23-0ubuntu0.20.04.1, or
apt install mariadb-client-core-10.3 # version 1:10.3.25-0ubuntu0.20.04.1
DOnt use if you need mysql as well!
@tollswap
The lamp script used to install mysql in past but not now. (see gist revision history)
It is recommended to install database inside docker.
PS
https://gist.github.com/ankurk91/aeda6722ca7b2205c4aca28b2429a0ab
@ankurk91
The lamp script used to install mysql in past but not now. (see gist revision history)
It is recommended to install database inside docker.
Hi! Can you please add install_docker.sh, install_docker_compose.sh and maybe Dockerfile for MySQL ))) It will be very useful
everythinks fine but you forget
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl restart apache2
@Devbaze
My update-phpmyadmin
script expect that you have already installed phpmyadmin with apt
Thanks :)