Installed:
Ubuntu 22.04
PHP 8.2.4
Apache/2.4.56
Mysql 8.0.32
Composer 2.5.4

Same as closed issue: https://www.drupal.org/project/drupal/issues/3155818

When trying "composer create-project drupal/recommended-project /var/wwww/html" (or any other other folder)
I get next error :
"In ProjectInstaller.php line 69: mkdir(): Permission denied"  
The only way to force is using sudo, but then I get the warning: "Do not run Composer as root/super user! ..."

I tried out all possible chown and chmod settings in vaine                              
last settings are next
drwxr-xr-x  2 jan  www-data 471040 mrt 16 14:09 html
drwxr-xr-x  2 jan  www-data   4096 mrt 16 15:55 test1
drwxr-sr-x  2 jan  www-data   4096 mrt 16 15:59 test2

Should I force with sudo, or install manualy and use composer just for handling themes and modules?

Comments

jaypan’s picture

It appears you're trying to create the Drupal directory inside a directory that your user does not have permission to create directories in. I would either change that directory's permissions to allow your user to be able to write to it, or create your Drupal directory in another directory where your user does have permissions.

Contact me to contract me for D7 -> D10 migrations.

jjgw’s picture

user jan has full read/write/execute access to folder html
see command sniplet where a text file and folder were created and deleted
 

//$ echo "$USER"
jan
/$ cd var/www
/var/www $ls -la
...
drwxr-xr-x  2 jan  www-data 471040 mrt 17 19:26 html
...
/var/www$ cd html
/var/www/html$ ls -la blabla*
ls: cannot access 'blabla*': No such file or directory
/var/www/html$ mkdir blabla
/var/www/html$ nano blabla.txt
/var/www/html$ ls -la blabla*
-rw-rw-r-- 1 jan jan    7 mrt 17 19:40 blabla.txt

blabla:
total 468
drwxrwxr-x 2 jan jan        4096 mrt 17 19:48 .
drwxr-xr-x 3 jan www-data 471040 mrt 17 19:48 ..
-rw-rw-r-- 1 jan jan    7 mrt 17 19:40 blabla.txt
/var/www/html$ rm blabla.txt
/var/www/html$ rmdir blabla
/var/www/html$ ls -la blabla*
ls: cannot access 'blabla*': No such file or directory
jaypan’s picture

I notice you have one to many W's here:

When trying "composer create-project drupal/recommended-project /var/wwww/html"

I would navigate to /var/www/html, then run the command.

Contact me to contract me for D7 -> D10 migrations.

jjgw’s picture

Sorry, writing error. /var/wwww/html does not exist. Composer was launched from /var/www/html.

jaypan’s picture

If you were already in that directory, then the command was incorrect. It should be this:

composer create-project drupal/recommended-project drupal

This will create Drupal at /var/www/html/drupal.

Contact me to contract me for D7 -> D10 migrations.

jjgw’s picture

I used this command, but misunderstood the instruction 'composer create-project drupal/recommended-project my_site_name_dir' from
https://www.drupal.org/docs/develop/using-composer/manage-dependencies
My command was '/var/www/html$ composer create-project drupal/recommended-project /var/wwww/html/drupal'
So adding the dir name was producing the access error. Without it worked like a charm
Thanks for helping me.

allexim’s picture

Hi there,

i have recently added the step-by-step guide on how to allocate new drupal 10 website using composer.

But there is still some issue that persists:

 - having been installed through the composer, website has some intermediate path:

        the root, where main composer.json resides, is followed by an additional directory /web

Thus, server-side configuration for website must be applied:

(Apache server)

<Directory /var/www/drupal.website>

</Directory>

<VirtualHost *:80>

        RewriteCond %{REQUEST_URI} !^/web/

        RewriteRule   ^/(.*)$ /web/$1  [L]

</VirtualHost>

After enabling the rewrite rule, an error appears:

Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it.

Hope, somebody could suggest how to solve...

unfortunately, no idea what to add there (/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php):

 /**
   * A list of trusted URLs, which are safe to redirect to.
   *
   * @var string[]
   */
  protected $trustedUrls = [];

UPD:

https://www.drupal.org/project/drupal/issues/2612160#comment-13623886

this method is correct

if (isset($GLOBALS['request']) && '/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}
Niyas’s picture

Hi,

I suggest checking out this thread, it may be helpful

https://www.drupal.org/project/drupal/issues/3276209