-1

How can I upload files of my website and access them on google cloud. I have created an instance and installed apache on the virtual machine and when I go to external IP I get the apache default page.I just want to know how can I replace this with my whole website...I tried "fileZilla" to upload files but couldn't upload the file in var/www directory it showed "permission denied error"

Ravi Sharma
  • 83
  • 1
  • 2
  • 11
  • Try to upload the files to your home directory and then ssh the the machine and move the file using sudo. You can also change the root directory in apache httpd.conf file. – Avinoam Meir Sep 05 '16 at 15:25
  • I'm really new to ssh so, I don't know much about it...can you pls tell me how can I edit/copy/paste files with ssh.. – Ravi Sharma Sep 06 '16 at 05:39
  • after you make ssh connection to the machine see [here](https://cloud.google.com/compute/docs/instances/connecting-to-instance). In the console you type `sudo cp -r /var/www` – Avinoam Meir Sep 06 '16 at 15:43
  • Thanks Avinoam...I'll try that and see if it works. – Ravi Sharma Sep 07 '16 at 05:42

1 Answers1

0

If you aren't familiar with GCP, I'd suggest Firebase Hosting for dynamic (ie: PHP) websites; or, since Cloud Storage comes with an always free tier, this can save a lot of money over time if you are hosting static HTML web pages from Cloud Storage. See this article for details on how its done: https://cloud.google.com/storage/docs/hosting-static-website

FileZilla SFTP: When accessing your GCP instance via SFTP, you won't be able to gain sudo privileges, so copy your websites website folder to your GCP instance home directory instead of /var/www. Then ssh into your instance and move the files to default Apache directory. In Ubuntu 18.04, Apache uses /var/wwww/html/ to serve its default website, so I'd use this command:

sudo mv /home/$USER/{your_uploaded_website_directory}/* /var/www/html

You will also need to change ownership of the moved files to the Apache user and group (that's www-data in Ubuntu).

sudo chown -R www-data:www-data /var/www/