blog details
Ubuntu Linux VPS Setup Commands

Ubuntu Linux VPS Setup Commands
ui install
sudo apt update && sudo apt upgradesudo apt install kde-plasma-desktopsudo apt install xrdpsudo adduser xrdp ssl-cert
apache install
sudo apt-get updatesudo apt install apache2
php install
sudo apt updatesudo apt install -y lsb-release gnupg2 ca-certificates apt-transport-https software-properties-commonsudo add-apt-repository ppa:ondrej/phpsudo apt updatesudo apt install php8.2sudo apt install php8.2-fpmsudo apt install php8.2-{bcmath,fpm,xml,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}sudo apt install apache2 libapache2-mod-php8.2sudo a2enmod php8.2sudo systemctl restart apache2
composer
sudo apt-get updatesudo apt install php-cli unzipcd ~curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.phpHASH=`curl -sS https://composer.github.io/installer.sig`php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composercomposer
node js install with nvm
sudo apt-get updatecurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.shcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bashsource ~/.bashrcnvm list-remotenvm install v20.8.1
git install
sudo apt-get updatesudo apt-get install git-allgit version
mySQL install
sudo apt updatesudo apt install mysql-serversudo systemctl start mysql.service
mySQL setup
sudo mysqlALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'dbMa$%!@#*@95ext965874-+/';exit
remote connection
SELECT host, user FROM mysql.user;CREATE USER 'username'@'%' IDENTIFIED BY 'password';GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address= 0.0.0.0
sudo systemctl restart mysql
CREATE USER 'sammy'@'remote_server_ip' IDENTIFIED BY 'password';
mongo DB install
sudo apt install software-properties-common gnupg apt-transport-https ca-certificates -ycurl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmorecho "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.listdeb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiversesudo apt updatesudo apt install mongodb-org -ymongod --versionsudo systemctl start mongodsudo systemctl enable mongod
mongo status
sudo systemctl status mongod
#run mongo and secure
mongoshuse admindb.createUser( {user: "root",pwd: "m2451238228",roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] })exit
sudo nano /etc/mongod.conf
security:authorization: enabled
sudo systemctl restart mongodsudo systemctl status mongodmongosh
log as auth user
mongosh -u root -p --authenticationDatabase adminm2451238228
show dbs
mongo remote connect
bindIp: 127.0.0.1, vps-mongo-server-ipsudo systemctl restart mongodsudo ufw allow from remote_machine_ip to any port 27017sudo ufw reload
mongo remote shell
sudo apt install netcatnc -zv mongodb_server_ip 27017mongosh "mongodb://username@mongo_server_ip:27017"
mongo error 14
sudo chown -R mongodb:mongodb /var/lib/mongodbsudo chown mongodb:mongodb /tmp/mongodb-27017.socksudo service mongod restartsudo systemctl status mongod
mongodb shell
sudo apt updatewget https://downloads.mongodb.com/compass/mongodb-compass_1.39.0_amd64.debsudo apt install ./mongodb-compass_1.39.0_amd64.debmongodg-compass --no-sandbox
mongo backup and restore
install https://www.mongodb.com/try/download/database-tools
mongodump --uri="uri_link?authSource=admin" --db=blogDB --out=d:/folder_namemongorestore -d meal-management-system D:\db.json\blogDBmongorestore --db it_database --verbose G:/it_database_18_oct_23_12_8p/it_databasemongodump --uri="mongodb+srv://user:pass@cluster0.0fsdqn6.mongodb.net/?authSource=admin" --db=it_database --out=G:/it_databse
restore local to atla
mongorestore --uri mongodb+srv://username:pass@noortahervpstpit.pfgs6qb.mongodb.net -d DBname --verbose ./backup_dir
permission to laravel project diretories
sudo chmod -R 777 /var/DirectoryName
sudo chown -R www-data:www-data
sudo chown -R www-data:www-data /var/www/html/laravel/storagesudo chown -R www-data:www-data /var/www/html/laravel/bootstrap/cache
proxy install
sudo a2enmod proxysudo a2enmod proxy_httpsudo /etc/init.d/apache2 restart
Aftar boot / reboot, restart services
sudo service apache2 start sudo systemctl restart apache2 sudo systemctl start mysql.service sudo systemctl enable mongod sudo systemctl restart mongod
#open servers
cd /var/www/deepseahost.compm2 start 5001_deep_sea_host.js --watch
pm2 start npm --name next.techparkit.org -- run start -- -p 3001
apache server setup
php
<VirtualHost *:80> ServerName domain DocumentRoot /var/www/domain/public <Directory /var/www/domain/public>Options Indexes FollowSymLinksAllowOverride AllRequire all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>
proxy
<VirtualHost *:80> ServerName domain ProxyPreserveHost on ProxyPass / http://localhost:5001/ ProxyPassReverse / http://localhost:5001/</VirtualHost>
check opened ports
netstat --listen --tcp -n
Dominique Roberts II
17 May 2022Prof. Greyson Murray MD
18 April 2020