Fixing VestaCP open_basedir error

So, this. This has been a pain in the ass for EVER. Every time I install VestaCP, I have to fix this before doing anything else with my code.

This issue wasn’t there when I started using VestaCP. Then came an update. Yeah, you get my point. 😡

I know it’s good for security. But still it’s a pain. So here’s how to get stuff working.

Please replace the following things with yours in my commands.

  • User: admin
  • Domain: example.com
  • Text-Editor: nano
  • Folder I want include files from: /home/%user%/web/%domain%/project
  1. Change directory to your VestaCP user’s web config folder
    cd /home/admin/conf/web
    
  2. List files
    ls -la
    

    You should see some files like

    example.com.httpd.conf
    example.com.nginx.conf
    
  3. Open up ‘example.com.httpd.conf‘ in a text editor
    Content will be similar to the follwing

    <VirtualHost ***.***.***.***:****>
    
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin info@example.com
        DocumentRoot /home/admin/web/example.com/public_html
        ScriptAlias /cgi-bin/ /home/admin/web/example.com/cgi-bin/
        Alias /vstats/ /home/admin/web/example.com/stats/
        Alias /error/ /home/admin/web/example.com/document_errors/
        #SuexecUserGroup admin admin
        CustomLog /var/log/httpd/domains/example.com.bytes bytes
        CustomLog /var/log/httpd/domains/example.com.log combined
        ErrorLog /var/log/httpd/domains/example.com.error.log
        <Directory /home/admin/web/example.com/public_html>
            AllowOverride All
            Options +Includes -Indexes +ExecCGI
            php_admin_value open_basedir /home/admin/web/example.com/public_html:/home/admin/tmp
            php_admin_value upload_tmp_dir /home/admin/tmp
            php_admin_value session.save_path /home/admin/tmp
        </Directory>
        <Directory /home/admin/web/example.com/stats>
            AllowOverride All
        </Directory>
    
        <IfModule mod_ruid2.c>
            RMode config
            RUidGid admin admin
            RGroups apache
        </IfModule>
        <IfModule itk.c>
            AssignUserID admin admin
        </IfModule>
    
        IncludeOptional /home/admin/conf/web/httpd.example.com.conf*
    
    </VirtualHost>
    
  4. Append the folder you want to ‘php_admin_value open_basedir‘ like the following example
    php_admin_value open_basedir /home/admin/web/example.com/public_html:/home/admin/tmp:/home/admin/web/example.com/project
    
  5. Save and quit the file
  6. Restart Apache Server
    You could use the VestaCP interface to restart the Apache Server OR use the following command

    service httpd restart
    

Cheers!

Advertisements

3 thoughts on “Fixing VestaCP open_basedir error

    1. Thank you for commenting. I see you have fixed your problem. But I suggest you to manually add the path to open_basedir config rather than turning it off, since that might make your server vulnerable.

      You could fix your problem appending ‘/tmp’ at the end of open_basedir value as shown below

      php_admin_value open_basedir /home/admin/web/example.com/public_html:/home/admin/tmp:/tmp

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s