Last active
January 19, 2022 10:33
-
-
Save RamyaIyer96/846cc504b4410872a48be9575ba5e364 to your computer and use it in GitHub Desktop.
Ubuntu Apache2, mysql, php, phpmyadmin Setup in one go.
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/sh | |
#COLORS | |
# Reset | |
Color_Off='\033[0m' # Text Reset | |
# Regular Colors | |
Red='\033[0;31m' # Red | |
Green='\033[0;32m' # Green | |
Yellow='\033[0;33m' # Yellow | |
Purple='\033[0;35m' # Purple | |
Cyan='\033[0;36m' # Cyan | |
# Update packages and Upgrade system | |
echo -e "$Cyan \n Updating System.. $Color_Off" | |
sudo apt-get update -y && sudo apt-get upgrade -y | |
## Install AMP | |
echo -e "$Cyan \n Installing Apache2 $Color_Off" | |
sudo apt-get install apache2 -y | |
## Install AMP | |
echo -e "$Cyan \n Allowing apache2 $Color_Off" | |
sudo sudo ufw allow in "Apache Full" | |
echo -e "$Cyan \n Installing PHP & Requirements $Color_Off" | |
sudo apt-get install libapache2-mod-php php php-common php-curl php-dev php-gd php-pear php-mysql -y | |
echo -e "$Cyan \n Installing MySQL $Color_Off" | |
sudo apt-get install mysql-server -y | |
echo -e "$Cyan \n Securing Mysql $Color_Off" | |
sudo mysql_secure_installation | |
echo -e "$Cyan \n Installing phpMyAdmin $Color_Off" | |
sudo apt-get install phpmyadmin -y | |
# Permissions | |
echo -e "$Cyan \n Permissions for /var/www $Color_Off" | |
sudo chown -R www-data:www-data /var/www | |
echo -e "$Green \n Permissions have been set $Color_Off" | |
# Enabling Mod Rewrite, required for WordPress permalinks and .htaccess files | |
echo -e "$Cyan \n Enabling Modules $Color_Off" | |
sudo a2enmod rewrite | |
# Restart Apache | |
echo -e "$Cyan \n Restarting Apache $Color_Off" | |
sudo service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to download a file from the server,
wget https://gist.githubusercontent.com/ashishpatel6958/846cc504b4410872a48be9575ba5e364/raw/shell.sh
chmod -x ./shell.sh
and run the script by $ sh serversetup.sh
Once the above process is complete, follow below steps,
Login to mySql
$ sudo mysql
Get list of users
mysql > SELECT user,authentication_string,plugin,host FROM mysql.user;
modify root/create a new user
modify root:
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
create new user:
mysql > CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Flush privileges:
mysql > FLUSH PRIVILEGES;
Check modification
mysql > SELECT user,authentication_string,plugin,host FROM mysql.user;
Exit.
mysql > exit
and your setup has been finished.