I’m trying to install Magento Open Source on my shared hosting server and want the store to display when I visit my domain. I used the following command:
bin/magento setup:install \
--base-url=https://mydomain.com/ \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento_password \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1
Unfortunately, I still see the default page of my web hosting service. The public_html directory only contains the default welcome.html file, while all Magento files have been installed in the user directory (parent of public_html).
How can I correctly install Magento so that it displays on my root domain? Also, how can I remove the incorrectly installed files from the user directory?
Thanks for your help
3 Answers 3
You need to create a subdirectory under public_html and install the instance in that directory. After that, either point the domain to the subdirectory (https://www.inmotionhosting.com/support/domain-names/how-to-redirect-your-primary-domain-to-a-subdirectory/) or access the Magento instance with the subfolder name. e.g. if the instance is magento247, you can access https://mydomain.com/magento247/
-
Thank you for your answer. If I understand correctly, when the customer types the address of the mydomain.com website into the browser, he'll be redirected to the mydomain/subdomain sub-directory where Magento has been installed and the Magento store will be displayed. It's this second url that will appear in the address bar. However, I'd like the Magento store not to be a subdirectory accessed via a url redirect, but directly in the mydomain.com domain. In other words, I would like the address that appears in the client's address bar to be mydomain.com and stay like that.Donkey the Noble Steed– Donkey the Noble Steed2024年07月24日 13:34:07 +00:00Commented Jul 24, 2024 at 13:34
-
Hi @DonkeytheNobleSteed, yes. You understood correctly. According to your requirement of direct map to the mydomain.com, please follow the steps mentioned here - serverfault.com/a/258996Magento TridhyaTech– Magento TridhyaTech2024年07月25日 04:02:07 +00:00Commented Jul 25, 2024 at 4:02
To correctly install Magento so it displays on your root domain, you'll need to make sure that Magento's files are placed in the public_html directory and the server's document root points to the correct location.
So, you need remove and extract all the files to the "public_html" directory if it's located outside the public_html or in the user directory.
Make sure you are running the command in the correct directory where you want to install the Magento and also specify the folder in the command.
One solution is to change the directory structure and point to the subdomain like mydomain.com/subdomain, but obviously, directly accessing could be feasible.
To remove the original files from the user directory. Use below command:
mv /path/to/user_directory/* /path/to/public_html/
mv /path/to/user_directory/.* /path/to/public_html/
After these changes, it's good practice to secure your Magento installation by setting appropriate file permissions and ensuring your env.php file contains the correct database and URL configurations.
You need to follow this steps.
From CLI first go to inside public_html of your domain.
Then you need to run the Magento Installation Command as you show on your Question.
Then run the following command from CLI.
php bin/magento cache:clean php bin/magento cache:flush php bin/magento indexer:reindex php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f sudo chmod -R 777 var/ generated/ pub/