How to Set Up a Drupal/Recommended-Project Type of Installation on a Hostinger Host
If you're looking to set up a Drupal website on a Hostinger host, you may want to consider using the recommended-project installation method. This method uses Composer to install Drupal and its dependencies, which can make it easier to manage and update your website in the future. In this article, we'll walk you through the steps to set up a Drupal/recommended-project type of installation on a Hostinger host.
Step 1: Create a New Website on Hostinger
The first step is to create a new website on Hostinger. You can do this by logging in to your Hostinger account, selecting "Create New Website" from the dashboard, and following the prompts to set up your website.
Step 2: Install Drupal Using Composer
Once you have created your website, you can install Drupal using Composer. To do this, you will need to connect to your website using an FTP client and upload the files from your Drupal/recommended-project repository to the root directory of your website. This will include a vendor folder, which contains all of the dependencies that Drupal needs to run.
Step 3: Modify Index.php to Load Autoloader from Vendor in the Previous Folder
After uploading the files, you will need to modify the index.php file to load the autoloader from the vendor folder in the previous folder. You can do this by adding the following code at the beginning of the file:
require __DIR__ . '/../vendor/autoload.php';
This will tell Drupal to load the autoloader from the vendor folder in the previous folder, rather than from the current folder.
Step 4: Add .htaccess to Direct Users to /web
Next, you will need to add an .htaccess file to the public_html folder to direct users to the /web folder. You can do this by creating a new file in your text editor and adding the following code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$
RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /web/$1
RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$
RewriteRule ^(/)?$ web/index.php [L]
Make sure to replace "yourdomain.com" with your actual domain name.
Step 5: Test Your Website
Once you have made these modifications, you can test your website to make sure it is working correctly. You should be able to access your website by entering your domain name in your web browser. If everything is set up correctly, you should see your Drupal website with the correct styles and layout.
Conclusion
Setting up a Drupal/recommended-project type of installation on a Hostinger host can be a bit challenging, but it can also be a great way to manage and update your website in the future. By following these steps and modifying the index.php file and adding an .htaccess file to direct users to the /web folder, you should be able to get your Drupal website up and running on Hostinger in no time.