Tip: Start typing to get instant search results.
Installing a New Magento 2 in the Magento Hosting Environment
Below is a description of how to create a new Magento Open Source installation in our optimized dedicated Magento 2 hosting environment.
In our dedicated Magento hosting, you will find pre-installed and properly configured (with special optimizations) Varnish cache server, Redis server or ValKey server, as well as OpenSearch or Elasticsearch server, depending on the Magento version to be used. In the instructions below, along with the installation steps, we describe how you can enable these features in your Magento.
The commands listed must be executed via SSH.
You will need, in addition to SSH access, credentials from your account on Magento Marketplace, as well as information from the Welcome kit you received with your server.
Where necessary below, replace the values with those that apply to your website.
The following have been tested with Magento version 2.4.8, and apply accordingly to newer and older versions.
Installation Steps
- Navigate to the site directory:
cd ~/public_html
- Create the project files with PHP composer (in this example we’re installing version 2.4.8-p3):
composer create-project --repository-url=https://repo.magento.com/ \ magento/project-community-edition=2.4.8-p3 .
- Enter your Magento keys to continue the installation as shown below:
(To get your Magento keys, log in to Magento Marketplace and navigate to the menu
"My Profile" > "Access Keys" > "Create a New Access Key".
Use your Public Key for username and your Private Key for password)
- Execute the Magento installation using bin/magento:
Note: Replace all<placeholders>with your own data. For the database connection details (db-name, db-user, db-password), consult the Welcome kit we send you upon server delivery.bin/magento setup:install \ --base-url="https://<your-domain>/" \ --db-name="<magento_database_name>" \ --db-user="<magento_database_user>" \ --db-password="<magento_database_password>" \ --backend-frontname="admin" \ --admin-firstname="<AdminFirstName>" \ --admin-lastname="<AdminLastName>" \ --admin-email="<name@example.com>" \ --admin-user="<admin_username>" \ --admin-password="<StrongAdminPassword1>" \ --language="el_GR" \ --currency="EUR" \ --timezone="Europe/Athens" \ --use-rewrites="1" \ --search-engine="<opensearch/elasticsearch>" \ --elasticsearch-host="localhost" \ --elasticsearch-port="9200" opcflush
- To enable Varnish Cache:
bin/magento config:set --scope=default --scope-code=0 system/full_page_cache/caching_application 2 bin/magento setup:config:set --http-cache-hosts=127.0.0.1:80 opcflush
- To configure the use of Redis for storing sessions and frontend cache:
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-db=1 --cache-backend-redis-server=localhost --cache-backend-redis-port=6379 opcflush
bin/magento setup:config:set --session-save=redis --session-save-redis-db=3 --session-save-redis-log-level=3 --cache-backend-redis-server=localhost --cache-backend-redis-port=6372 opcflush
- Also enable the following settings in Magento 2 configuration:
bin/magento config:set web/secure/use_in_adminhtml 1 bin/magento config:set web/secure/use_in_frontend 1 bin/magento config:set dev/js/minify_files 1 bin/magento config:set dev/css/minify_files 1 bin/magento config:set dev/static/sign 1 bin/magento indexer:set-mode schedule opcflush
After Installation
- Enable production mode with the following command:
opcflush bin/magento deploy:mode:set production
- Execute a full deployment following our guide: Magento 2 Deployment
- Execute reindex on all indexes with the following command:
bin/magento indexer:reindex
- Install Magento 2 crons:
bin/magento cron:install
How to Change the Admin Backend URL
A common practice for Magento installation is to change the URL path for logging into the Magento admin (Magento backend) for security reasons.
Below we describe how this can be done.
In the example, we simply change the path to ‘adminmylogin’. The admin URL path in a production installation should be more complex for security reasons.
The change can be made through the Magento backend, but also through the cli. Below we describe how it can be done in two ways via cli (SSH):
1. Via SSH
bin/magento setup:config:set --backend-frontname='adminmylogin' opcflush
2. Through the env.php file
In the public_html/app/etc/env.php file, we change the following section and then run opcflush:
return [
'backend' => [
'frontName' => 'adminmylogin'
],
