Setup Ubuntu Server
Sudo apt update
Sudo apt install apache2
Sudo systemctl status apache2
Managing Apache Process
Sudo systemctl stop process
Sudo systemctl start apache 2
Sudo systemctl restart apache 2
Sudo systemctl reload apache 2
Sudo systemctl disable apache 2
Sudo systemctl enable apache 2
Setting Virtual Hosts
Sudo mkdir/var/www/your-domain
Sudo nano/etc/apache2/sites-available/your-domain.conf
Sudo a2ensite your-domain.conf
Sudo apache2ctl configtest
Sudo systemctl restart apache2
Install PHP and supportive Package
Sudo apt install php php-mcrypt php-gd php-curl
Sudo apt install mysql-server
Sudo systemctl status mysql
Install mysql server
Sudo apt install mysql-server mysql-client php-mysql php-pdo
Change root user password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'the-new-password';
sudo killall -u mysql
sudo systemctl restart mysql.service
sudo systemctl restart mysql
mysql -u root -p (enter then password type)
Database Update user
create user ’username’@localhost identified by 'password'
grant all privileges on databasename.* to username@localhost
flush privileges;
Server Connection command
Ssh username@Host/IP
Then paste password
If sever key avialable
Ssh -i pem file name username@Host/IP
find . -type f -newermt "1 day ago" → Modified Filename
find . -type f -newermt "1 day ago" | gerp ".php" → Modified file name with php only
sudo tar -czf filename.tar.gz abc.php → Compress file in tar zip
tar -xf archive.tar → Extract tar file
Mkdir folder_name → To create folder
Touch file_name → To create file
Git Command
Sudo apt install git
git status → To check file status
git add . → To add all changes into git
git add file1 file2 → To add specific files
git commit -m “commit message”
git push origin <branch>
Git clone command
git clone <git url>
Git pull command
git pull origin <branch>
To give file or folder permission
sudo chmod 0777 file/foldername
Import database command
mysql -u username -p new_database < data-dump.sql
Export database command
mysqldump -u username -p database_name > data-dump.sql
Upload file from local to server
scp file.txt remote_username@10.10.0.2:/remote/directory
Install certbot to ssl
sudo apt install snapd
snap find
snap info package_nam
sudo snap install core;
sudo snap refresh core
sudo snap install --classic certbot;
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache
sudo systemctl restart apache2
Related Stories
March 21, 2022
March 14, 2022
March 1, 2022