-
sudo dnf list | grep nginx //Search
-
sudo dnf update //To Install Latest Update
-
sudo dnf install -y nginx // Install Nginx
-
sudo systemctl start nginx.service //Start Nginx Server
-
sudo systemctl status nginx.service // Check Server Status
-
sudo systemctl enable nginx.service // Enable Auto Server Start on
-
sudo yum update
-
sudo yum install -y nginx
-
sudo systemctl start nginx.service
-
sudo systemctl enable nginx.service // auto-start nginx service
-
nginx -v
-
sudo systemctl status nginx.service
sudo yum install certbot
sudo certbot certonly --standalone -d example1.com -d www.example1.com -d example2.com -d www.example2.com
crontab -e
0 0 * * * certbot renew --quiet
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h
-
sudo wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm
-
sudo ls -lrt
-
sudo dnf install mysql80-community-release-el9-1.noarch.rpm
-
dnf repolist enabled | grep "mysql.-community."
-
sudo dnf install mysql-community-server
-
sudo systemctl start mysqld
-
sudo systemctl enable mysqld
-
sudo mysql -V
-
sudo mysql_secure_installation
sudo grep 'temporary password' /var/log/mysqld.log
mysql -u root -p
//change root password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass1!';
// create new user(sam)
CREATE USER 'sam'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass1!';
GRANT ALL PRIVILEGES ON lotr.* TO 'sam'@'localhost'; // access only lotr database
//if you want to be able to access the database from anywhere else
CREATE USER 'frodo'@'%' IDENTIFIED WITH mysql_native_password BY 'MyNewPass1!';
GRANT ALL PRIVILEGES ON *.* TO 'frodo'@'%';
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash // https://github.com/nvm-sh/nvm/releases
- ~/.nvm/nvm.sh
- nvm install --lts
- node -v
- yarn global add pm2
- pm2 start ecosystem.config.js
ecosystem.config.js
module.exports = {
apps: [
{
name: "myapp",
script: "app.js",
instances: 0,
exec_mode: "cluster",
autorestart: true,
watch: false,
max_memory_restart: "1G",
env: {
NODE_ENV: "production",
PORT: 4000
}
}
]
};
sudo vim /etc/systemd/system/YourAppName.service
[Unit]
Description=My Node.js App
After=network.target
[Service]
ExecStart=/usr/bin/node /path/to/your/app.js
WorkingDirectory=/path/to/your/app_directory
Restart=always
User=your_username
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.targetAnother example
[Unit]
Description=YourAppName
After=multi-user.target
[Service]
ExecStart=/usr/bin/node /home/ec2-user/your_app_dir/server.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=YourAppName
User=ec2-user
EnvironmentFile=/home/ec2-user/your_app_dir/app.env
[Install]
WantedBy=multi-user.target
- Start the service: Run
sudo systemctl start myappto start the service. - Stop the service: Run
sudo systemctl stop myappto stop the service. - Restart the service: Run
sudo systemctl restart myappto restart the service. - Enable the service to start at boot: Run
sudo systemctl enable myappto enable automatic startup at boot time. - Disable the service from starting at boot: Run
sudo systemctl disable myappto disable automatic startup.