-1

I have an Ubuntu distribution with a localhost setup in /var/www/html/mysite working properly. The problem I have is, when I edit files in this folder, I must do as root or www-data which is not completely ok, as I have to run every mkdir with sudo -u or use chown all the time, plus, my text editor (Sublime text) doesn't integrate properly with my Unity desktop.

I tried to setup localhost in my home dir but I found some problems and I don't like the idea so much.

As a better alternative I tried to have mysite in my home directory, owned by me and with permissions drwxr-xr-x, and create a symbolic link /var/www/html/mysite owned by www-data, but I get an error:

403 - You don't have permission to access / on this server.

Any ideas? How have you resolved this question?

PS: My user does belong to www-data group

user761076
  • 199
  • 1
  • 1
  • 10

1 Answers1

0

The probably cleanest, but also most complicated solution is to have your site in git. Then, have an external repository that supports webhooks (gitlab, github, bitbucket). Write a CGI script that pulls the correct branch from the repository, copies it into the www folder, and changes the permissions accordingly. Then configure a webhook that calls this script whenever a commit takes place. Although this takes some time to set up, it has some advantages:

  • you always have the newest production version on your production server
  • your developers do not need to log in to the server to deploy anymore
  • if you use version control already, it integrates neatly and automates the deployment
  • if you don't use version control, it forces you to do so
mzhaase
  • 3,778
  • 2
  • 19
  • 32
  • I use git, but this doesn't solve my problem, I still need to edit files as www-data, otherwise I would need a commit and push for every single change, not very dynamic. Plus, not all files are inside de repository, vendors, external libraries, etc, are not needed to control source and would consume large broadband. – user761076 Sep 15 '16 at 14:39