Last active
February 6, 2025 11:56
-
-
Save ajayfroiden/902e2bcaecb6b8ca27bca971a9163ed6 to your computer and use it in GitHub Desktop.
Ubuntu 22 - PHP development (8.3, apache 2.4) credits ankurk91
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 | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Ubuntu 20.04 dev 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 - 8.3 \e[39m" | |
sudo apt-get -y install "php8.3-cli" "libapache2-mod-php8.3" | |
sudo apt-get -y install curl zip unzip | |
echo -e "\e[96m Installing php extensions \e[39m" | |
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 | |
#sudo apt-get -y install php-xdebug | |
sudo phpenmod curl | |
# Enable some apache modules | |
sudo a2enmod rewrite | |
sudo a2enmod ssl | |
sudo a2enmod headers | |
sudo a2enmod "php8.3" | |
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 | |
echo -e "\e[96m Installing mysql server \e[39m" | |
sudo apt install -y mysql-server | |
# 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 |
Change or SET mysql Password
sudo mysql -uroot
After running above command your will see below screen
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 264
Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
mysql> FLUSH PRIVILEGES;
mysql> exit;
Now TEST logging by
mysql -u root -p
You will be prompted to
Enter Password: yourpassword
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Method 1
You can run them in the terminal like this:
Method 2
You can try this method to run it in the terminal