├── .DS_Store ├── Commands.txt └── nginx-server-block.conf /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glennraya/server-setup/7163580f051ee2c7205c2b7052eb57c6c3b34388/.DS_Store -------------------------------------------------------------------------------- /Commands.txt: -------------------------------------------------------------------------------- 1 | # Configure SSH Access 2 | sudo -u your-username mkdir -p /home/your-username/.ssh 3 | sudo -u your-username chmod 700 /home/your-username/.ssh 4 | 5 | sudo chown -R your-username:your-username /home/your-username/.ssh 6 | 7 | sudo -u your-username touch /home/your-username/.ssh/authorized_keys 8 | sudo -u your-username chmod 600 /home/your-username/.ssh/authorized_keys 9 | 10 | sudo chmod 755 /home/your-username 11 | sudo chown your-username:your-username /home/your-username 12 | 13 | // Create SUDO User 14 | adduser username 15 | 16 | usermod -aG sudo username 17 | 18 | // Generate SSH Key Pair 19 | ssh-keygen -t ecdsa -b 521 20 | 21 | // Install PHP and Extensions 22 | sudo apt update 23 | sudo add-apt-repository ppa:ondrej/php 24 | sudo apt install php8.3-cli 25 | sudo apt install php8.3-common php8.3-bcmath php8.3-mbstring php8.3-xml php8.3-curl php8.3-gd php8.3-zip php8.3-mysql 26 | 27 | // Check PHP installed modules 28 | php8.3 -m 29 | 30 | // Install Composer 31 | sudo apt install composer 32 | 33 | // Install MySQL/Secure Installation 34 | sudo apt install mysql-server 35 | sudo mysql_secure_installation 36 | 37 | // Setup Database and User 38 | CREATE DATABASE yourdatabase; 39 | CREATE USER 'your-username'@'localhost' IDENTIFIED BY 'your-password'; 40 | GRANT ALL PRIVILEGES ON yourdatabase.* TO 'your-username'@'localhost'; 41 | FLUSH PRIVILEGES; 42 | EXIT; 43 | 44 | // Install NVM/NodeJS 45 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash 46 | 47 | export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" 48 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" 49 | 50 | nvm --version 51 | 52 | nvm install --lts 53 | 54 | // Taking directory ownership 55 | sudo chown -R username /directory-name 56 | 57 | // Taking file ownership 58 | sudo chown username filename 59 | 60 | // Proper Directory Permissions (Navigate to your project root directory) 61 | sudo chown -R $USER:www-data . 62 | 63 | sudo find . -type f -exec chmod 664 {} \; 64 | 65 | sudo find . -type d -exec chmod 775 {} \; 66 | 67 | sudo chgrp -R www-data storage bootstrap/cache 68 | 69 | sudo chmod -R ug+rwx storage bootstrap/cache 70 | 71 | // Install Nginx Server and Configure Virtual Host aka Server Blocks: 72 | sudo apt install nginx 73 | 74 | // Configure Server Blocks for your website in Nginx. 75 | // Navigate to the directory /etc/nginx/sites-available to create a server block file. 76 | cd /etc/nginx/sites-available 77 | sudo vim example.com # Replace the example.com with your website or web app domain. 78 | 79 | // Go to laravel.com, search for nginx site configuration, scroll down, copy the server configuration code, and paste it into the vim server block file. 80 | // Replace the server_name which is example.com with your site domain 81 | // Replace the root path /srv/example.com/public with your site Laravel public directory path. 82 | 83 | # note: Scroll down in the same vim file and look for php-fpm which should match the PHP version installed on your server where the app is deployed. 84 | //Save the file and exit it from vim. 85 | // Now create a symbolic link for the server block that we just created. 86 | cd /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled # Replace the example.com with the domain name for which we just created a server block. 87 | 88 | // Test the nginx server for any issues or errors. 89 | sudo nginx -t 90 | 91 | // Restart the nginx server and then access your website or web app 92 | sudo systemctl restart nginx 93 | 94 | // Install Certbot 95 | sudo apt install certbot python3-certbot-nginx 96 | 97 | // Issue SSL Cert 98 | sudo certbot --nginx -d glennraya.com 99 | 100 | // SSH Config file (keep ssh-agent active) 101 | User git 102 | Hostname github.com 103 | IdentityFile ~/.ssh/id_github 104 | TCPKeepAlive yes 105 | IdentitiesOnly yes 106 | ServerAliveInterval 60 107 | -------------------------------------------------------------------------------- /nginx-server-block.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | listen [::]:80; 4 | server_name example.com; 5 | root /var/www/html/laravel/public; 6 | 7 | add_header X-Frame-Options "SAMEORIGIN"; 8 | add_header X-Content-Type-Options "nosniff"; 9 | 10 | index index.php; 11 | 12 | charset utf-8; 13 | 14 | location / { 15 | try_files $uri $uri/ /index.php?$query_string; 16 | } 17 | 18 | location = /favicon.ico { access_log off; log_not_found off; } 19 | location = /robots.txt { access_log off; log_not_found off; } 20 | 21 | error_page 404 /index.php; 22 | 23 | location ~ \.php$ { 24 | fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; 25 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 26 | include fastcgi_params; 27 | fastcgi_hide_header X-Powered-By; 28 | } 29 | 30 | location ~ /\.(?!well-known).* { 31 | deny all; 32 | } 33 | } 34 | --------------------------------------------------------------------------------