Installing Elgg With Plesk Control Panel And Fixing Open_basedir restrictions and errors

Ok here is my 1st attempt at writing some documentation for the installation of Elgg! 

If your control panel is Plesk and you are trying to install Elgg you will need to do the following for it to work correctly.

DO NOT EDIT YOUR HTTPD.CONF File. You may think your changes are saved but within a few hours plesk will automatically overwrite this file with its own. To remove any Open_basedir problems and restrictions you will need to do this per domain. 

To define the needed parameters for each domain youw ill need to create or edit your vhost file.

Plesk automatically updates httpd.include for each domain, making changes to this file only temporary. You don’t want to use this file if you need to make changes toApache’s config on the fly, such as php’s open_basedir values per domain.

Instead you will want to use a vhost.conf file. This file will be placed inside your domain’s conf directory, usually found at/var/www/vhosts/mysite.com/conf.
Create a file called vhost.conf in whatever editor you prefer.

Note: If you have a site that has an SSL and you need to have access to directories outside the httpsdocs directory you will need to do the same thing but instead of “vhost.conf” it’s “vhost_ssl.conf

You can now put in any Apache configuration options like you would into httpd.include.

Now if you’ve been using Plesk for a bit you know that sites are generally kept under the httpdocs directory.
But let’s say you’re installing some online software…like Sugar CRMJoomla orELGG.

These packages need access to directories outside of the httpdocs directory.

To solve this issue properly in Plesk - you’re supposed to create a vhost.conf file in the conf directory under your site.

Let’s say you did this:

cd /var/www/vhosts/mysite.com
mkdir data
chown myuser
:psaserv data 

In the site directory you could add the following:

<Directory /var/www/vhosts/mysite.com/httpdocs/>
php_admin_value open_basedir "/var/www/vhosts/mysite.com/httpdocs:/tmp:/var/www/vhosts/mysite.com/data"
</Directory

Then you would need to force an update in Plesk for this domain using the following command:

/usr/local/psa/admin/sbin/websrvmng ---vhost-name=mysite.com 

After running that there is no need to restart Apache or any other service. Your changes should have taken effect already.

To get mine working correctly I used this in my vhost.conf file

Directory /var/www/vhosts/yourdomain.com/yourdatadirectory/&nbsp;
php_admin_value open_basedir \ /var/www/vhosts/yoursite.com/httpdocs:/tmp:/var/www/vhosts/yoursite.com/data\&nbsp;
/Directory 

On some setups you may want to use this

Directory /var/www/vhosts/yourdomain.com 
php_admin_flag engine on
php_admin_value open_basedir none
/Directory 

 

Hope that this helps anyone that may run into this with Plesk Control Panel

  • Here is in short my attempt since I am experimenting with elgg on a freebsd with plesk. Three major notes here:
    1. ownership of data directory - which must be verified in advance to match with httpdocs
    2. paths should be changed to whatever your setup is if replicating
    3. in my examples the domain name is elgg.ahr since my test server runs on a local network and has its own local DNS.

    verify the owner of the public zone (httpdocs) with:
    ls -l /usr/local/www/vhosts/elgg.ahr

    drwxr-x---   5 elgg  psaserv   512 Apr  5 10:59 anon_ftp
    drwxr-xr-x   2 root  psaserv   512 Apr  5 10:59 bin
    drwxr-x---   3 elgg  psaserv   512 Apr  5 10:59 cgi-bin
    drwxr-x---   2 root  psaserv   512 Apr  5 11:00 conf
    drwxr-xr-x   2 root  psaserv   512 Apr  5 10:59 error_docs
    drwxr-x---  21 elgg  psaserv  1024 Apr  5 12:15 httpdocs
    drwxr-x---   3 elgg  psaserv   512 Apr  5 11:16 httpsdocs
    drwxr-x---   2 root  psaserv   512 Apr  5 11:00 pd
    drwx------   2 elgg  wheel     512 Apr  5 10:59 private
    dr-xr-x---   7 root  psaserv   512 Apr  5 10:59 statistics
    drwxr-xr-x   2 root  psaserv   512 Apr  5 10:59 subdomains
    drwxr-xr-x   2 root  psaserv   512 Apr  5 10:59 web_users

    note that "elgg" is the right user/owner for httpdocs


    RECAP: (make sure the server pats are in sync with your setup if replicating)

    mkdir /usr/local/www/vhosts/elgg.ahr/data

    chmod 0777 /usr/local/www/vhosts/elgg.ahr/data

    chown elgg /usr/local/www/vhosts/elgg.ahr/data

    create/modify file:
    ee /usr/local/www/vhosts/elgg.ahr/conf/vhost.conf

    append with following text:

    <Directory /usr/local/www/vhosts/elgg.ahr/httpdocs&gt;
            php_admin_value open_basedir "/usr/local/www/vhosts/elgg.ahr/httpdocs:/usr/local/www/vhosts/elgg.ahr/data:/tmp"
    </Directory>

  • bash code that will do the same thing - cut and paste with a text editor, modify lines 4-12 to match your server settings, login your server with ssh, go to your home directory and create a file.sh, cut and paste from your modified code, chmod 0755 file.sh , run with ./file.sh

    #!/bin/sh

    wk_site="elgg.ahr"
    wk_path="/usr/local/www/vhosts/"${wk_site}
    wk_data="/data"
    wk_ownr="elgg"
    wk_fulp=${wk_path}${wk_data}

    wk_cnfd=${wk_path}"/conf"
    wk_cfle="vhost.conf"

    wk_docr="httpdocs"

    if [ -d ${wk_fulp} ] ; then
       rm -R ${wk_fulp}
    fi

    cd / && \
       mkdir ${wk_fulp} && \
       chmod 0777 ${wk_fulp} && \
       chown ${wk_ownr} ${wk_fulp} && \
       ls -l ${wk_path}

    echo ""
    echo ""

    if [ -f ${wk_cnfd}/${wk_cfle} ] ; then
       rm -R ${wk_cnfd}/${wk_cfle}
    fi

    touch ${wk_cnfd}/${wk_cfle}

    echo "<Directory $wk_path/$wk_docr>" > ${wk_cnfd}/${wk_cfle}
    echo "        php_admin_value open_basedir \"$wk_path/$wk_docr:$wk_fulp:/tmp\"" >> ${wk_cnfd}/${wk_cfle}
    echo "</Directory>" >> ${wk_cnfd}/${wk_cfle}

    # show file
    echo ""
    cat ${wk_cnfd}/${wk_cfle}
    echo ""
    echo ""

    # restart psa so new configs could take effect
    echo "Restart PSA vhost"
    /usr/local/psa/admin/sbin/websrvmng -u --vhost-name=${wk_site}
    echo ""
    echo ""

    # optional restart httpd (with whatever fits your os settings)
    echo "Restart HTTPD"
    /usr/local/sbin/httpd -k restart
    echo ""
    echo "------------------DONE------------------"
    echo ""

  • check your error_log for the particular domain
    if you still have open_basedir restriction in effect. File(/X/tmp)...

    you need to change:
    php_admin_value open_basedir "/server/path/domain/public:/server/path/domain/data:/tmp"

    with:
    php_admin_value open_basedir "/server/path/domain/public:/server/path/domain/data:/X/tmp"

    Note: the error_log will show the correct path of your /tmp directory



    Added a new variable and modified the vhost.conf content

    #!/bin/sh

    wk_site="elgg.ahr"
    wk_path="/usr/local/www/vhosts/"${wk_site}
    wk_data="/data"
    wk_ownr="elgg_ahr"
    wk_fulp=${wk_path}${wk_data}

    wk_cnfd=${wk_path}"/conf"
    wk_cfle="vhost.conf"

    wk_docr="httpdocs"
    wk_obpt="/tmp"

    if [ -d ${wk_fulp} ] ; then
       rm -R ${wk_fulp}
    fi

    cd / && \
       mkdir ${wk_fulp} && \
       chmod 0777 ${wk_fulp} && \
       chown ${wk_ownr} ${wk_fulp} && \
       ls -l ${wk_path}

    echo ""
    echo ""

    if [ -f ${wk_cnfd}/${wk_cfle} ] ; then
       rm -R ${wk_cnfd}/${wk_cfle}
    fi

    touch ${wk_cnfd}/${wk_cfle}

    echo "<Directory $wk_path/$wk_docr>" > ${wk_cnfd}/${wk_cfle}
    echo "        <IfModule sapi_apache2.c>" >> ${wk_cnfd}/${wk_cfle}
    echo "                php_admin_flag engine on" >> ${wk_cnfd}/${wk_cfle}
    echo "                php_admin_flag safe_mode on" >> ${wk_cnfd}/${wk_cfle}
    echo "                php_admin_value open_basedir \"$wk_path/$wk_docr:$wk_fulp:$wk_obpt\"" >> ${wk_cnfd}/${wk_cfle}
    echo "        </IfModule>" >> ${wk_cnfd}/${wk_cfle}
    echo "        <IfModule mod_php5.c>" >> ${wk_cnfd}/${wk_cfle}
    echo "                php_admin_flag engine on" >> ${wk_cnfd}/${wk_cfle}
    echo "                php_admin_flag safe_mode on" >> ${wk_cnfd}/${wk_cfle}
    echo "                php_admin_value open_basedir \"$wk_path/$wk_docr:$wk_fulp:$wk_obpt\"" >> ${wk_cnfd}/${wk_cfle}
    echo "        </IfModule>" >> ${wk_cnfd}/${wk_cfle}
    echo "</Directory>" >> ${wk_cnfd}/${wk_cfle}

    # show file
    echo ""
    echo ""
    cat ${wk_cnfd}/${wk_cfle}
    echo ""
    echo ""

    # restart psa so new configs could take effect
    echo "Restart PSA vhost"
    /usr/local/psa/admin/sbin/websrvmng -u --vhost-name=${wk_site}
    echo ""
    echo ""

    # optional restart httpd (with whatever fits your os settings)
    echo "Restart HTTPD"
    /usr/local/sbin/httpd -k restart
    echo ""
    echo "------------------DONE------------------"
    echo ""

  • Can someone explain this a little bit simple.

    So i can do it on my vhost with plesk.

  • still dont get 2 parts.

    what do i add in the vhost.conf file?

    and where do i add this code:

    <Directory /var/www/vhosts/mysite.com/httpdocs/&gt;
    php_admin_value open_basedir "/var/www/vhosts/mysite.com/httpdocs:/tmp:/var/www/vhosts/mysite.com/data"
    </Directory>

  • i dont know what to tell you, the link works for me. you can type it directly into your browser.

     

  • so what i understand from ur guideline.

    I need to put this :

    <Directory /var/www/vhosts/omg-recordz.com/httpdocs/&gt;
    php_admin_value open_basedir "/var/www/vhosts/omg-recordz.com/httpdocs:/tmp:/var/www/vhosts/omg-recordz.com/data"
    </Directory>

    in my vhost.conf

    It is just a copy and paste and then create a map in my domain called data and  that should do teh job.

    Are am i still wrong

  • @clinton

    yes that looks like a correct vhost.conf file. the only other thing you have to make sure is that your data directory has its permissions set at 777.

     

  • how do i do this last command?

    /usr/local/psa/admin/bin/websrvmng -a

  • i did

    run /usr/local/psa/admin/bin/websrvmng -a

    but it is not a bash command ?? strange

  • I use a program called putty for interaction with my vps. I am not sure what you are using as a hosting solution. so its hard for me to even begin stating what to do at that point.

  • but basically putty is a command line interface for my vps, i just sign in at the root level and would type in that command to make the changes take effect

  • but what happens if u run that command ?

    What do is see ??

  • you don't really see anything. but the effect is, you can install ELGG and have a data folder outside the root directory.

  • I did everything and still get this error :(

    Your data directory /srv/www/vhosts/omg-recordz.com/data/ is not writable.

  • drwxr-x---  5 ruffsense psaserv 4096 aug  6 21:13 anon_ftp/
    drwxr-xr-x  2 root      psaserv 4096 aug  6 21:13 bin/
    drwxr-x---  3 ruffsense psaserv 4096 aug  6 21:13 cgi-bin/
    drwxr-x---  2 root      psaserv 4096 aug  6 21:41 conf/
    drwxrwxrwx  2 ruffsense psaserv 4096 aug  6 21:19 data/
    drwxr-xr-x  2 root      psaserv 4096 aug  6 21:13 error_docs/
    drwxr-x--- 19 ruffsense psaserv 4096 aug  6 21:44 httpdocs/
    drwxr-x---  7 ruffsense psaserv 4096 aug  6 21:13 httpsdocs/
    drwxr-x---  2 root      psaserv 4096 aug  6 21:13 pd/
    drwx------  2 ruffsense root    4096 aug  6 21:13 private/
    dr-xr-x---  7 root      psaserv 4096 aug  6 21:13 statistics/
    drwxr-xr-x  2 root      psaserv 4096 aug  6 21:13 subdomains/
    drwxr-xr-x  2 root      psaserv 4096 aug  6 21:13 web_users/

  • chmod 777 -R /srv/www/vhosts/omg-recordz.com/data

    then

    /usr/local/psa/admin/bin/websrvmng -a

    then try install

  • @ Zakary

    Nope still same problem and this is my problem for along time.

    I dont want to give up on elgg i love it. it looks nice :)

    Your data directory /srv/www/vhosts/omg-recordz.com/data/ is not writable.

    But i need it in my root folder. Other then that the picture upload wont work :(

  • what is your hosting set up? are you on a shared host? VPS? who is your service provider?