My Blog
Google Cloud Server Instructions (free for 1 year) & settings
- October 5, 2019
- -
- Linux Virtual & Dedicated server
- -
- nicolas
As I've mentioned before, today I'm posting the instructions to get your own Google Cloud Server for free for $ 300 to spend, a free gift from Google.
What is a Virtual Private Server or VPS?
Consider that every ad you see on the internet for free or very cheap website hosting (ie your site's files), 90% of all these services have to do with a shared hosting server, that is, the same server (computer) hosts other clients inside (except you).
The reasons why many choose this simple hosting site are: 1. Why it's so easy to use 2. It's all pre-installed (email, ftp, databases etc) 3. It's very cheap compared to a Virtual Private Server But if we want to look at reality from another perspective: 1. You are using the same IP as other 100+ clients, which means you have the following risks: hacking, ddos attacks, blacklist ip, slow operation causing the server to crash every bit, etc. 2. They may all be preinstalled, but how many times have you tried to add a wordpress add-on for example to import 1000+ products into your e-shop and all of a sudden they stuck? This is almost always the case when the add-on asks for more resources, memory, and so on, and often depending on the hosting company you have to ask for and if they want they will usually give it to you. 3. The myth that Shared Hosting is cheap does not apply, because of the limitations you usually have to get a Gold package and that means you will spend at least $ 10- $ 14 a month, that is, $ 120-168 $ a year. For this reason, slowly or quickly, it is time to start looking for the famous VPS. In the past, VPS cost Cuckoo Aidoni, but today we have a lot of options, and not to be outdone, you can see the history of VPS on Google with a look. One of the options for VPS is the Google Cloud Platform (Compute Engine) service where Google offers a $ 300 trial to use wherever you want. I will enrich this post with more and more (easier) corrections in the future, as well as upload a video throughout the process. For the moment I quote that I have missed writing in my spare time and as always feel free to ask?) 01. go to console.cloud.google.com 02. register with your existing gmail and add a debit card according to the address you entered 03. go to console.cloud.google.com > Compute Engine > VM Instances 04. if it ask press Enable (payments profile, something like that) 05. Inside VM Instances press "Create Ιnstance" 06. Put: a) Name: Whatever you want or the same b) Zone: us-central1-c c) Machine Type: 1 vCPU (3.75 GB memory) d) On Boot Disk press "Change" and choose "Ubuntu 17.10 and hdd 50GB" e) The Service account you don't mind it f) The Acess scopes you choose the middle one Allow full access g) On firewall check both (http & https) h) Click on "Management" i) Choose Networking Tab j) In the default Network Interface, right-click the pen to edit its settings k) So in its settings go to IP Forwarding and change it to ON and press DONE l) Finally click Create and wait until it's ready. 07. Once it's ready, prepare a document and start writing in what data you will need for the future for example External IP you will need to have it in a document to connect faster. 08. Click on where SSH says it will open a new window with the server's command console 09. Congratulations, you are connected to your server. 10. To set up the ability to host web pages: (for every write I tell you you will write and press Enter) (if he asks you with YES->y or No->n , press y and if it doesn't move press Enter) (where he asks you for a password, always put the same and save it in the document you made before so you don't forget it) a) Write: sudo su - b) Write: apt-get update && apt-get dist-upgrade && apt-get autoremove c) Write: apt-get install apache2 d) Write: apt-get install mysql-server mysql-client e) Write: apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql f) Write: apt-get install zip unzip g) Write: apt-get install phpmyadmin (will ask you Web server to reconfigure automatically, press Space on the keyboard to check apache2 and then Enter) (for code when asked, put the same one you put in before) h) Write: echo " " > /etc/php/7.0/cli/php.ini i) Write: nano /etc/php/7.0/cli/php.ini go here: https://pastebin.com/03t79MdK and copy that is there and in the console window press CTRL + V to paste at the bottom of the keyboard, press Ctrl + X, then press Y and then press Enter (if you want the full version of php.ini, go here: https://pastebin.com/BjJAZdnv) j) Write: echo " " > /etc/php/7.0/apache2/php.ini k) Write: nano /etc/php/7.0/apache2/php.ini (do exactly the same as the previous one) 11. To link your domain (s): (where it says tositesou.com you change it to your site address) a) Create your site folder, Write: mkdir -p /var/www/html/tositesou.com b) Write: chown -R www-data:www-data /var/www/html/tositesou.com (later when you upload the site files give the following commands again: b1: chown -R www-data:www-data /var/www/html/tositesou.com/* b2: chown -R www-data:www-data /var/www/html/tositesou.com) c) Write: chmod -R 755 /var/www (this command is only for one time, don't repeat it if you upload a second site) d) Write: cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/tositesou.com.conf e) Write: nano /etc/apache2/sites-available/tositesou.com.conf erase everything and paste the following: https://pastebin.com/vSYDNLAW f) at the bottom of the keyboard, press Ctrl + X, then press Y and then press Enter g) Write: a2ensite tositesou.com.conf h) Write: sudo service apache2 restart i) Write: nano /etc/hosts in the last line below put the following: 111.111.111.111 tositesou.com (το 111.111.111.111 , change it with your server's external ip, which I told you at the beginning of the document) j) at the bottom of the keyboard, press Ctrl + X, then press Y and then press Enter k) go to your domain's DNS Settings, which you will find at the provider where you purchased the domain (eg papaki.gr or godaddy.com etc)) and added or changed: Type-> A | Name-> tositesou.com | Value: external ip of your server (see the picture and you will understand: https://drive.google.com/open?id=0B0-xSvKcaUZhNThjSHBZM0Y5VGs) l) On the console Write: sudo service apache2 restart m) Let's see if it's all done right, visit your domain in your browser, tositesou.com, logically Forbidden, of course you don't have any file inside, that's why. 12. To upload your website (IGNORE THE FILE MANAGER INSTALLATION ON THIS STEP, GO TO BOTTOM): a) Write: cd /var/www/html/ b) Write: wget https://old.nicolaslagios.com/downloads/pafm.zip c) Write: unzip pafm.zip d) Write: nano /var/www/html/pafm/pafm.php change "O-KODIKOS-SOU" to a password you want to protect your file manager at the bottom of the keyboard, press Ctrl + X, then press Y and then press Enter f) Write: chown -R www-data:www-data /var/www/html/pafm g) So to upload a website: g1) Visit File Manager at: http://ip.του.server.σου/pafm/pafm.php and upload to the correct folder g2) If you also want a database, visit: http://ip.του.server.σου/phpmyadmin Sign in and on the left click "New" Type a name and click Create (when you later ask WordPress for example database database name: database name, database host: localhost database user: root , database password: your password) h) Because you'll need them, here are some basic console commands here: https://pastebin.com/Fre59wAg 13. To connect email: a) Go to https://app.mailgun.com/app/dashboard , sign up sign in and go to the Domains tab click Add New Domains write mailgun.tositesou.com go to the dns settings of your domain as you did before and do exactly what the mailgun tells you once you do that, after 2 hours go back to the mailgun domains tab and click on the new domain you just put it down, click on the "Check DNS Records Now" button b) Write: sudo su - Write: umask 077 Write: apt-get update && apt-get install postfix libsasl2-modules -y (select Local Only and press Enter, and then press Enter again) Write: nano /etc/postfix/main.cf If available, remove the push-button symbol from the front If not, add them If they exist and don't have a push-button symbol, then do nothing, go to the next step # default_transport = error # relay_transport = error Add the following lines to the same file: relayhost = [smtp.mailgun.org]:2525 smtp_tls_security_level = encrypt smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous Finally press CTRL + X and immediately after Y and Enter to save and close Write: cat > /etc/postfix/sasl_passwd << EOF in the > that will open, write the following: [smtp.mailgun.org]:2525 YOUR_SMTP_USERNAME:YOUR_SMTP_PASSWORD (you will find them by going to: https://app.mailgun.com/app/domains and clicking on the domain of interest) Note!!! Don't worry, whatever email you send through your server you will see the email you send, not the domain from which you get smtp access Write: Press Enter & then Write: EOF and press Enter Write: postmap /etc/postfix/sasl_passwd Write: ls -l /etc/postfix/sasl_passwd* Write: rm /etc/postfix/sasl_passwd Write: chmod 600 /etc/postfix/sasl_passwd.db Write: ls -la /etc/postfix/sasl_passwd.db Write: /etc/init.d/postfix restart 14. To connect via FTP (IGNORE THIS STEP GO TO BOTTOM) a) download the client machine filezilla client: https://filezilla-project.org b) download the tool "puttygen": https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html c) run "puttygen" and press the button "Generate" then press "save private key" and save it somewhere you can remember it with whatever name you want, e.g. putty-key.ppk don't close the program yet d) go to the Google CLoud console: Compute Engine/Metadata in the second tab "SSH KEYS" click edit and then click on the add item and copy all the public key you made on "puttygen" and press save e) open filezilla and go to menu Edit/Settings and from the left panel choose SFTP and press Add Key File add the key file you save on step c and press OK Now to log in: Host: sftp://ip_tou_server_sou , username: από το puttygen put your key comment and click connect As you will see in the / home folder a subfolder has been created with your username go to the console and write the command: sudo chmod 777 / home / username_sou / NOW CAN TRANSFER REGULAR FILES WITH FILEZILLA Latest Update!!! You can just ignore File Manager of step 12 and ignore entirelly step 14 and install wordpress through the command console (download it to /var/www/html with wget command, unzip it with unzip command and final create a database by visit http://IP-OF-YOUR-SERVER-OR-YOUR-DOMAIN/phpmyadmin). After the installation, go to your wordpress admin dashboard and install File Manager form the Apps menu. You are ready to go ;)
This post is also available in: Ελληνικά