A
Alokai8mo ago
Amnesia

Magento2 Domain

Hello guys, I want to change magento's domain from magento.test to my ip so I can reach it through external network. How can I do that?
2 Replies
Amnesia
Amnesia8mo ago
@rohrig @skirianov Already changed the domain but in mobile still can't see images and when i try to access through the external ip page is not fully loaded and the buttons don't work. I've disabled the firewall to test experiencing cors error
rohrig
rohrig8mo ago
Changing Magento's domain to your IP address to make it accessible from an external network involves a few steps: 1. Backup: Before making any changes, always back up your database and Magento files. This ensures you can roll back to a working state in case of errors. 2. Update the Base URLs in the Database: To access Magento via an IP address, you should change the base URL in the Magento database. 1. Log in to your database (usually using phpMyAdmin, or any database client). 2. Navigate to the core_config_data table. 3. Locate the web/unsecure/base_url and web/secure/base_url entries. 4. Change their values from http://magento.test/ to http://your_ip_address/ (replace your_ip_address with your actual IP). 5. Save the changes. 3. Update Virtual Host Configuration: Depending on your web server (Apache, Nginx, etc.), you need to update the server configuration: #### For Apache: 1. Locate the virtual host file for your Magento installation. This could be in /etc/apache2/sites-available/ or a similar directory. 2. Update the ServerName directive to match your IP address. 3. Restart the Apache service: sudo service apache2 restart. #### For Nginx: 1. Locate the server block configuration for your Magento site. This could be in /etc/nginx/sites-available/ or a similar directory. 2. Update the server_name directive to match your IP address. 3. Restart the Nginx service: sudo service nginx restart. 4. Update Magento Cache: To ensure Magento uses the updated URLs: 1. Navigate to the root directory of your Magento installation. 2. Clear the cache: php bin/magento cache:clean && php bin/magento cache:flush. 5. Update Local Hosts (if needed): If you still want to access the website using magento.test on your local machine: 1. Open the hosts file: - On Windows: C:\Windows\System32\drivers\etc\hosts - On MacOS/Linux: /etc/hosts 2. Add an entry: 127.0.0.1 magento.test. 6. Firewall and Port Forwarding: If you're hosting Magento on a local machine and you want to access it from an external network: 1. Ensure the machine's firewall allows incoming connections on port 80 (or whichever port your web server uses). 2. If you're behind a router, set up port forwarding so that external requests to port 80 are forwarded to your machine. Note: Making Magento publicly accessible can expose it to potential threats. Always ensure: - You're using HTTPS (install an SSL certificate). - Your Magento installation, themes, and plugins/modules are up to date. - You have strong, unique passwords for your Magento backend, database, and hosting environment. - You regularly review and apply security best practices. If you only need to allow certain people or networks to access the site, consider setting up a VPN or using firewall rules to limit access to your server.