Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Local webserver files on home partition instead of root

  1. #1

    Default Local webserver files on home partition instead of root

    I've setup a LAMP environment to test and develop locally with wordpress.

    With the default settings, the main webserver folder is located at /srv/www/htdocs/, that contains in example, phpMyAdmin and wordpress main folders.

    I find it a bit unhandy, for a couple of reasons: the first one is of permissions (whenever I want to manually change something, I must get admin privileges), the second is that my home folder has a different backup schedule of the root (these folders are better classified as "user content" instead of "system files").

    I only use this to work locally, mainly for testing; nobody else is supposed to access all of this externally.

    My questions are:

    Is it possible (and advisable) to move these folders somewhere inside my home partition? Are there any drawbacks or generally some things that I should consider when doing this?
    And how can I correctly change this setup?

  2. #2
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,666
    Blog Entries
    14

    Default Re: Local webserver files on home partition instead of root

    Advisable? Depends on what you as a developer prefer, matter of taste.

    Can it be done? Yes, use Yast's http module and enable mod_userdir. Make sure the configs for vhosts are changed accordingly.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,893

    Default Re: Local webserver files on home partition instead of root

    Best thing is of course to use a different user for your web adninistration. That is different from root (so no need to use root for managing in /srv, etc.) and different from "normal end-users" that use their userid for banking, listening music, reading writing e-mail, etc.

    Make that user's primary group www, that is the same group that your Apache server uses at run time. /srv, etc. should all be owned by that user and group www.

    User and group ownership of prcosesses and files and file permissions should be understood and used as they were invented for to your advantage. And not seen as things that hamper your system/website/user data managing.
    Henk van Velden

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,893

    Default Re: Local webserver files on home partition instead of root

    Not realy connected to my advice above.

    In your apache configuration there is something like
    Code:
    DocumentRoot "/srv/www/htdocs"
    You can change that to whatever path on your system you like. But:
    a) it must exist (and even better when it contains web pages);
    b) it's permissions (and those of all the directories in the path leading to it) must enable the apache server processes (that run by deafult under wwwrun:www) to at least read the files in it.

    Also, you can add other document pathes to your apache config. I have e.g.
    Code:
    Alias /milweb/ "/home/henk/milweb/"
    
    <Directory "/home/henk/milweb">
     Options Indexes
     AllowOverride None
     Order deny,allow
     Deny from all
    </Directory>
    which serves web-files in /home/henk/milweb (you guess it: in "my" home directory) to the clients when they access domainname.hostname/milweb/....

    Hope this helps to trigger your fantasy.
    Henk van Velden

  5. #5

    Default Re: Local webserver files on home partition instead of root

    I've tried to add this alias

    Code:
    Alias /Web/ "/home/stefano/Web/"
    
    <Directory "/home/stefano/Web">
     Options Indexes
     AllowOverride None
     Order deny,allow
     Deny from all
    </Directory>
    and ./Web has the folliwing attributes:
    Code:
    $ ls -l | grep Web
    drwxrwxr-x  3 stefano www   4096 22 lug 19.37 Web
    but it doesn't work; when I try to start the webserver, I get this error
    Code:
    Job for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xn" for details.

  6. #6
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,893

    Default Re: Local webserver files on home partition instead of root

    Quote Originally Posted by sekhemty View Post
    Code:
    Job for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xn" for details.
    And? What does that tell you (and maybe us when you post it)?
    Henk van Velden

  7. #7
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,954
    Blog Entries
    2

    Default Re: Local webserver files on home partition instead of root

    Something for your consideration....

    You're not alone feeling Apache is a matter of overkill when you're just trying to deploy a personal Development server for your personal use.

    Most people I know (besides myself) typically look for Apache alternatives when developing. Apache can be slow to load, requires an enormous amount of overhead (possibly related to reserved resources for database connections) and may be difficult to modify default structures.

    I'd recommend for instance nodejs as an "instant on and minimal resources required" alternative which is one way of deploying a website "anywhere" including in a /home directory or partition (really. No restrictions where which makes something like this ideal for Development).

    For an introduction and how to install nodejs on openSUSE I created a Wiki page
    https://en.opensuse.org/User:Tsu2/nodejs

    Once nodejs is installed,
    You simply place a webserver configuration file in your website root and call it from a console.
    An example is this config file which I often use for static websites, just follow the comments in the file to invoke.
    https://github.com/putztzu/public_sc...s_webserver.js

    Now, wordpress is vastly more complicated to set up than a static website, but it seems that just late this past year there seems to have been a big effort to port Wordpress to nodejs (You can Google "nodejs wordpress" to read the blogs).
    Inspecting the nodejs repo, it looks like there are hundreds of Wordpress nodejs packages.
    Probably the place to start is to look for a package which will automatically retrieve all necessary Wordpress dependencies and install the basic Wordpress framework. I'd expect that after that is installed, you should then be able to import your existing website.
    Searching the nodejs as follows returns several hits, there might be blogs with full instruction also. Place higher consideration on packages which mention something like Gulp or Grunt which are well known javascript task and workflow managers (useful for scripting the install and setup).
    Code:
    npm search wordpress deploy
    This is one package which might get you started
    https://www.npmjs.com/package/grunt-wordpress-deploy

    This is so new,
    I of course haven't actually tried this but if you decide to go down this path you should be able to deploy a Wordpress(or most any other) website anywhere on your system. I assume that you have no current experience with nodejs which would likely mean an additional learning curve, but you might find that this is really beneficial for the long term if you develop web content regularly.

    HTH,
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  8. #8

    Default Re: Local webserver files on home partition instead of root

    I've managed to solve this.

    Apache is already configured to serve a particular directory in every user's home.

    Any file put in /home/<username>/public_html/ is accessible from http://localhost/~<username>/

    Of course all the ownerships and permissions should be correctly set.

    Source: https://wiki.archlinux.org/index.php...er_directories

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,893

    Default Re: Local webserver files on home partition instead of root

    Yes, but that feature is known to be unsecure.

    My ISP offered it on their system to all subscibers. They moved the subscribers (thus also my) web-sites to a different path for security reasons.
    Henk van Velden

  10. #10

    Default Re: Local webserver files on home partition instead of root

    Can you explain to me how it is insecure? What are the risks?

    I've only installed wordpress on my laptop for personal testing purposes, and those sites are only available to me (they aren't residing on an external server). Are there security risks even this way?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •