sábado, 14 de mayo de 2016

How To Configure public_html folder in home dirctory same as /var/www in Apache2?


https://priyankacool10.wordpress.com/2012/07/21/how-to-configure-public_html-folder-in-home-dirctory-same-as-varwww-in-apache2/

How To Configure public_html folder in home dirctory same as /var/www in Apache2?

If you want to set up Apache2 so that users have personal websites in their home directories, with /home/user/website linking to http://www.blah.com/~user or localhost/~user  . You can do this using the userdir module of Apache.
Follow the following steps:
1. Create public_html folder in home. Remember don’t use sudo with it.
$mkdir public_html
2. Now open you apache server config file and edit to enable public_html for that uncomment UserDir public_html and comment UserDir disabled and also uncomments the lines below from where Directory start to ends.
$ sudo vi /etc/apache2/httpd.conf
Here is the /etc/apache2/httpd.conf file after editing:
#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#

<IfModule mod_userdir.c>
    # Note that the name of the user directory ("public_html") cannot easily be
    # changed here, since it is a compile time setting. The apache package
    # would have to be rebuilt. You could work around by deleting
    # /usr/sbin/suexec, but then all scripts from the directories would be
    # executed with the UID of the webserver.
    #
    # To rebuild apache with another setting you need to change the
    # %userdir define in the spec file.

    # not every user's directory should be visible:
    UserDir disabled root

    # to enable UserDir only for a certain set of users, use this instead:
    #UserDir disabled
    #UserDir enabled user1 user2

 # the UserDir directive is actually used inside the virtual hosts, to
    # have more control
    UserDir public_html

    <Directory /home/*/public_html>

        AllowOverride FileInfo AuthConfig Limit Indexes
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

        <Limit GET POST OPTIONS PROPFIND>
            Order allow,deny
            Allow from all
        </Limit>

        <LimitExcept GET POST OPTIONS PROPFIND>
            Order deny,allow
            Deny from all
        </LimitExcept>

    </Directory>

</IfModule>

3. Next, we will need to make sure the permissions are set correctly. Your /home directory needs to have permissions 711, the same goes for your users home directory. The public_html on the other hand needs to be 755, and it’s content world readable (minimum 604, or o+r):
$ chmod 711 /home
$ chmod 711 /home/priyanka
$ chmod 755 /home/priyanka/public_html
$ chmod o+r /home/priyanka/public_html/index.html

4.  There are only two commands you need to enter to activate the User Directory feature, and then one command to reload the configuration files. The last command includes an absolute path, so it doesn’t matter where you execute it from. The first two “ln” commands assume you are in the directory /etc/apache2/mods-enabled. What you need to do is create two symbolic links (soft links, symlinks) in the stated directory pointing to the corresponding module in /etc/apache2/mods-available. So, if “$” is your prompt,
$ cd /etc/apache2/mods-enabled
$ sudo ln -s ../mods-available/userdir.conf userdir.conf
$ sudo ln -s ../mods-available/userdir.load userdir.load
$ sudo /etc/init.d/apache2 restart 

Now open in browser http://localhost/~priyanka It will show indexof priyanka and you are

No hay comentarios:

Publicar un comentario