phpftpphpstorm

Dec 2024 - PhpStorm uploads to server - but outside of public_html directory


For the last 4 days using PhpStorm, Dec 2024 version, I have played with deplyment configuration, trying different (a) root path (b) mapping deployment path ... but sadly nothing works; however, when I log into the remote server I can see that PhpStorm did create a directory outside of the public_html directory, and the files were uploaded there indeed.

Problem is that ...

For example:

However:

I also checked with YouTube but the vids on this subject are over 7-9 years old, and I just recently downloaded PhpStorm some days back. So their screenshots are not the same as mine, sadly.

I never had any issues with FTP software before, but this feature is so important that I do not yet understand why there is no illustrated written examples - or even updated YouTube videos on this.

I tried different deployment configurations. I tried watching youtube videos. I tried googling the answer.

There is really nothing current on this issue anywhere.


Solution

  • The docs are pretty good and clear, and certainly up to date.

    It sounds like you are mixing up server and web paths. Here's the simplest config:

    That's it, you're done.

    You can probably see there are other ways to achieve the same results, by changing how the various paths combine. You can make your server config more flexible, so it can be reused for other projects. Say you create another site next week, and you want to upload it to the same server. Currently you would have to create a new deployemnt server, since the one above will deploy into the welcome/ dir so would overwrite the welcome project.

    To avoid that, on the first Connection page, untick the "Visible only for this project" checkbox, so you can use it for another project.

    Then change the Root path to /home/user/public_html. Switch to the Mappings tab, and change Deployment path to /welcome.

    Now the end result is the same - files in this project still go to the same place. But next week you can reuse this server, and choose a different Deployment path for that project, say /my-next-project, and the files will be uploaded to /home/user/public_html/my-next-project.

    As to what was happening previously: with / as the root, and /welcome as deployment path, it means PHPStorm would try to create the /welcome directory at the root of the whole server filesystem. But unless you are logging in as root, you won't have permissions to write there. Probaly your user does not have permissions to write anywhere outside /home/user/. So my guess is /home/user is where you ended up, and PHPStorm created a welcome/ dir there. The PHPStorm deployment log probably shows you errors or more info about what happened.