Set server timezone to Tehran:
dpkg-reconfigure tzdata
Upgrade server:
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt autoremove
sudo apt install ubuntu-release-upgrader-core
Install the required tools:
apt install htop git zip unzip curl python gettext screen cron supervisor redis-server software-properties-common openssh-server -y
install the nginx web server:
apt update
apt install nginx -y
Install PHP 7.4 and its modules:
add-apt-repository -y ppa:ondrej/php
Latest Version:
apt install php-fpm php-mysql php-common php-cli php-gd php-mbstring php-xml php-zip php-bcmath php-curl php-soap php-redis php-memcached -y
7.4
apt install php7.4-fpm php7.4-mysql php7.4-common php7.4-cli php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip php7.4-bcmath php7.4-gettext php7.4-curl php7.4-soap php7.4-redis php7.4-memcached -y
Install MySQL:
apt install mysql-server -y
systemctl status mysql
Run security script as validate password plugin:
mysql_secure_installation
mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '*********';
Create databases, users, and grant all corresponding privileges:
CREATE DATABASE DB_NAME_HERE CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER USERNAME_HERE@localhost IDENTIFIED BY 'DB_PASSWORD_HERE';
GRANT ALL PRIVILEGES ON DB_NAME_HERE.* TO 'USERNAME_HERE'@'localhost' IDENTIFIED BY 'DB_PASSWORD_HERE';
Apply the new settings:
FLUSH PRIVILEGES;
exit
Inistall phpMyAdmin:
apt update
apt install phpmyadmin -y
nano /etc/nginx/sites-available/default
ln -s /usr/share/phpmyadmin/ /var/www/html
Upgrade phpMyAdmin:
mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
cd /usr/share/
wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
unzip phpMyAdmin-5.2.1-all-languages.zip
mv phpMyAdmin-5.2.1-all-languages/ phpmyadmin
rm phpMyAdmin-5.2.1-all-languages.zip
cd /usr/share/phpmyadmin
Edit vendor_config.php:
mkdir /usr/share/phpmyadmin/tmp
sudo chmod 777 /usr/share/phpmyadmin/tmp/
nano /usr/share/phpmyadmin/libraries/vendor_config.php
If access denied issue:
nano /etc/phpmyadmin/config-db.php
Restart Nginx:
service nginx restart
cd /tmp
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt update
sudo apt install mongodb-org -y
sudo systemctl start mongod.service
sudo systemctl enable mongod
mongo --eval 'db.runCommand({ connectionStatus: 1 })'
sudo apt install php-mongodb
ln -s /usr/share/phpmyadmin/ /var/www/trader/public/
Create a key for root:
ssh-keygen -t rsa
cat /root/.ssh/id_rsa.pub
git config --global user.email "[email protected]"
git config --global user.name "Mohammad Khavari"
git clone [email protected]:asrenet/deployer.git /var/www/deployer
Ignore file mode:
git config core.fileMode false
Upload file:
scp -rp index.php ssh [email protected]:/var/www/html/
scp -rp *.png ssh [email protected]:/var/www/html/img
Upload directory:
scp -rp upload/ ssh [email protected]:/var/www/html/
unzip /var/www/html/file.zip -d /var/www/
unzip file.zip
Install git-auto-deploy:
add-apt-repository ppa:olipo186/git-auto-deploy
apt install git-auto-deploy
Start the service:
/etc/init.d/git-auto-deploy start
This service listens on 8001 port number by default. Use telnet to check if it’s started correctly and is listening on this port.
telnet localhost 8001
Config git-auto-deploy repositories:
nano /etc/git-auto-deploy.conf.json
"https-enabled": false,
{
"url": "[email protected]:asrenet/deployer.git",
"branch": "master",
"remote": "origin",
"path": "/var/www/deployer",
"prepull": "",
"postpull": "",
"deploy": ""
},
Restart the service:
service git-auto-deploy restart
Copy generated ssh keys to git-auto-deploy home directory:
cp /root/.ssh/id_rsa /etc/git-auto-deploy/.ssh/
cp /root/.ssh/id_rsa.pub /etc/git-auto-deploy/.ssh/
chown -R git-auto-deploy:git-auto-deploy /etc/git-auto-deploy
Add ssh keys for authentication without password to localhost with git-auto-deploy:
cat /etc/git-auto-deploy/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
chmod og-wx /root/.ssh/authorized_keys
Add git-auto-deploy to the www-data group:
usermod -a -G www-data git-auto-deploy
Fix owners:
chown -R git-auto-deploy:www-data /var/
watch the service log:
tail -f /var/log/git-auto-deploy.log
Install nodejs v10.x and npm v6.x:
cd /tmp
sudo curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
node --version
npm --version
Install webpack 4.x and webpack-cli 3.x:
npm install --global webpack webpack-cli
webpack -v
webpack-cli -v
Database backup: