Score:0

Deploying drupal 9 on a remote server

ng flag

I've built my website on my local PC and I'm ready to go live and move it to the remote server.

I've bought a shared hosting package (so I can't run scripts etc, but I can copy the files over and export and import the database using phpmyadmin).

I couldn't for the life of me find a deployment guide for drupal 9, so to get things going, I tried something similar to what I've done for drupal 7 and have this structure on the remote server...

/public_html
    /config
    /synccomposer
    /vendor
    /web

So I can access the site at: http://mysite.com/web

But how do I set things up so that I can access the site at just http://mysite.com ? I've tried moving the files in the web directory into public_html, and moving the other directories up one level, but that didnt work. What is the best way to do this?

No Sssweat avatar
ua flag
`I've bought a shared hosting package` these usually come with C-Panel. All you gotta do is change the document root to `/public_html/web`, [see this video](https://www.youtube.com/watch?v=YRB3kz87adQ&ab_channel=DomainRacer) for how to.
ng flag
@NoSssweat thanks that worked perfectly
apaderno avatar
us flag
Since the question seems to be *I have a Drupal site that on local I access as `http://localhost/web`. How can I access it as `http://example.com/` when I deploy it on the production server?* it's not a Drupal-related question.
apaderno avatar
us flag
As side note, With Drupal 9 it's possible to have the *vendor* directory outside the server document directory and tell Drupal which directory is the server document directory. That requires changing how the development site is created, though.
ng flag
@apaderno can you point me to a link or something where this is described?
apaderno avatar
us flag
It's described in [Using Composer to Install Drupal and Manage Dependencies](https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies). [To do a modified install](https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies#s-to-do-a-modified-install), in particular, says how the document root directory can be changed.
Score:1
cn flag

You can try doing this through the .htaccess file, which you should have access to via the File Browser. You may have to turn on the "Show hidden files" option tho.

Edit: Pointed out by apaderno, this is an incomplete answer. To use RewriteCond, you do in fact need to combine Cond with RewriteRule. I updated the below with a more complete answer.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?yourwebsite.com$
RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteRule (.*) /web/$1 [L]

apaderno avatar
us flag
`RewriteCond` is used in conjuction with `RewriteRule`; without the latter, the setting isn't complete.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.