• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question How to create directory alias

scool

Basic Pleskian
Hello everyone. I am trying to create a directory alias on plesk , so that when someone navigates to example.com/somename , it will be accessed via /var/www/vhosts/domain.com/folder/foldername. this folder is outside of httpdocs.

On Apache & nginx Settings , i have created a rule Alias /foldername/ /var/www/vhosts/domain.com/folder/foldername/

but when you are trying to navigate to this page , it justs downloads the file

has anyone used directory alias?

unfortunatly plesk support is not very responsive , i am waiting 8hours+ for a response
 
Referring to PHP files outside of the document root of the domain is not supported by Plesk. That is expected behavior which is a consequence of virtual host isolation measures.
 
Thank you for your reply Igor,
We have an application that we dont want to be publicly accessible, how would you suggest to implement it with plesk ?
 
Well, by creating an alias in Nginx or Apache to a directory, even if this directory is outside of httpdocs, the contents of the directory would become publicly accessible. I assume this is not what you want.

If you would like your application to access directories and files that are not publicly accessible, then this must be accomplished by the application itself to begin with. There are popular web applications out there that work like this, let's take Moodle as an example. As you may know, the recommended way of installing Moodle is to keep the Moodle's data directory outside of web accessible space, while the core of the application remains accessible.

Under Plesk, one would do this:

- install Moodle and any plugins and themes under httpdocs
- the contents of httpdocs (but not httpdocs itself) can be owned as user and group root, with standard access rights of 755 for subdirectories and 644 for files
- create a new directory outside of httpdocs, e.g. /var/www/vhosts/example.com/moodle_data_dir
- set this moodle_data_dir to be owned as example.com's system user and group psaserv, access rights 750 (so same as httpdocs)
- the contents of the moodle_data_dir should be owned by the example.com's system user and group psacln, with standard access rights of 755 for subdirectories and 644 for files.

In Plesk GUI, under the example.com PHP Settings, set the open_basedir to be:
Code:
{DOCROOT}{/}{:}{TMP}{/}:{WEBSPACEROOT}{/}moodle_data_dir

Note that we prefer to set the open_basedir to DOCROOT (that's httpdocs) ant TMP and only allow additional directories as needed.
 
Well, by creating an alias in Nginx or Apache to a directory, even if this directory is outside of httpdocs, the contents of the directory would become publicly accessible. I assume this is not what you want.

If you would like your application to access directories and files that are not publicly accessible, then this must be accomplished by the application itself to begin with. There are popular web applications out there that work like this, let's take Moodle as an example. As you may know, the recommended way of installing Moodle is to keep the Moodle's data directory outside of web accessible space, while the core of the application remains accessible.

Under Plesk, one would do this:

- install Moodle and any plugins and themes under httpdocs
- the contents of httpdocs (but not httpdocs itself) can be owned as user and group root, with standard access rights of 755 for subdirectories and 644 for files
- create a new directory outside of httpdocs, e.g. /var/www/vhosts/example.com/moodle_data_dir
- set this moodle_data_dir to be owned as example.com's system user and group psaserv, access rights 750 (so same as httpdocs)
- the contents of the moodle_data_dir should be owned by the example.com's system user and group psacln, with standard access rights of 755 for subdirectories and 644 for files.

In Plesk GUI, under the example.com PHP Settings, set the open_basedir to be:
Code:
{DOCROOT}{/}{:}{TMP}{/}:{WEBSPACEROOT}{/}moodle_data_dir

Note that we prefer to set the open_basedir to DOCROOT (that's httpdocs) ant TMP and only allow additional directories as needed.


Had to chime in after countless hours of trying to get a lavarel app (specifically freescout) to work and going back and forth with Plesk support with phone calls and tickets. After trying to modify nginx ROOT directive (which cannot be done unfortunately with plesk even when you create custom nginx hosts), your solution with open base dir was the actual solution. Apps that require outside folders from the web host need to access hidden files with the correct file permissions as you mentioned. Your solution with open base dir option in PHP settings is what makes it work. Youd have to do the following setup below to get it to work. Here is an example with the lavarel app called Freescout:

1. Set domain folder to httpdocs/domain.com/public (public is lavarels generic name for public html) in the domains Host settings in plesk.
2. Copy your lavarel system files to httpdocs/domain.com
3. Copy your lavarel apps public folder files to httpdocs/domain.com/public - Be careful here to make sure to do this after the first step. If you do this before the first step, then plesk will delete ALL files in the public folder, which means you will lose all of your laravel app public files.
4. Modify your open basedir to allow to php to read and write to httpdocs/domain.com (my configuration to do this in openbase dir was:
{WEBSPACEROOT}{/}httpdocs{/}domain.com

Now when you run you lavarel app install, css, scripts and everything else will work as intended. This should work for all other apps that require files and folders outside from web root of your plesk domain. Great job Ales, you should sticky this somehow on the forums and or plesks support questions. I am sure many others have this issue and have probably given up on installing specific software.
 
Back
Top