Install Magento
Previous step
With your workspace prepared, install Magento on your local to verify custom code, extensions, and more. This section includes the installation prep, options, and post-installation configuration you should complete.
Prepare to install Magento
To customize the Magento software on your local workstation, prepare the following:
- Hostname or IP address of your machine
- Admin username, password, and URL created earlier
- Magento authentication keys for installing Magento
To see the Magento Admin environment variables
You need the ADMIN environment variables for the installation command line.
List the environment variables.
1
magento-cloud variable:get -e <environment-ID>
1
2
3
4
5
6
7
+----------------+---------------+-----------+------+
| ID | Value | Inherited | JSON |
+----------------+---------------+-----------+------+
| ADMIN_PASSWORD | admin_A456 | Yes | No |
| ADMIN_URL | magento_A8v10 | Yes | No |
| ADMIN_USERNAME | admin_A456 | Yes | No |
+----------------+---------------+-----------+------+
Get Magento authentication keys
You need Magento authentication keys to install Magento in your local development environment. These are different than the authentication keys included in the code repository auth.json
file. See Add Magento authentication keys.
To create authentication keys through the Magento Marketplace
-
Log in to the Magento Marketplace. If you do not have an account, click Register.
-
Click your account name in the top-right and select My Profile.
-
Click Access Keys under My Products in the Marketplace tab.
-
Click Create A New Access Key.
-
Enter a specific name for the keys, for example CloudProductOwner or the name of the developer receiving the keys.
-
The keys generate a Public and Private key you can click to copy. Save this information or keep the page open when installing Magento Commerce.
Set the docroot
Set the docroot
to the /magento
directory until you complete all setup. If you change the docroot
to /magento/pub
prior to completion, you will encounter issues running the Web Setup Wizard.
For the Production environment, set the docroot
to /magento/pub
, which helps restrict access to vulnerable areas of the system. The webserver docroot
should be set to /magento/pub
only after Magento is installed (including any upgrades and patches), configured, and static files generated and populated in /magento/pub
. Alternatively, you could create a subdomain (for example, install.domain.com
) and configure your webserver docroot
to the Magento installed root folder.
Set file system permissions and ownership
After you have installed Magento, you need to set the file system permissions and ownership.
-
Log in to your Magento server as, or switch to, the Magento file system owner.
-
Enter the following commands in the order shown:
1
cd <magento_root>
1 2
find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
1
chown -R :<web server group> .
1
chmod u+x bin/magento
To optionally enter all commands on one line, enter the following assuming Magento is installed in /var/www/html/magento2
and the web server group name is apache
:
1
cd /var/www/html/magento2 && find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chown -R :apache . && chmod u+x bin/magento
In the event file system permissions are set improperly and can’t be changed by the Magento file system owner, you can enter the command as a user with root
privileges:
1
cd /var/www/html/magento2 && sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && sudo chown -R :apache . && sudo chmod u+x bin/magento
Install Magento
Prior to installing, you should Update installation dependencies using Composer commands.
Be ready to install Magento using one of the following options:
- Install the Magento software using the command line
- Install the Magento software using the Web Setup Wizard
To install Magento using the command line
-
Switch to the user.
1
sudo su - magento
-
Change directories for the installation.
1
cd /app/bin
-
Enter a CLI command with options for entering the name, email, ADMIN credentials, URL, and additional information. For a list of all options, see Installer help commands.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
php magento setup:install \ --admin-firstname=John \ --admin-lastname=Smith \ --admin-email=jsmith@mail.com \ --admin-user=admin \ --admin-password=password1 \ --base-url=http://magento.local/ \ --db-host=localhost \ --db-name=magento \ --db-user=magento \ --db-password=magento \ --currency=USD \ --timezone=America/Chicago \ --language=en_US \ --use-rewrites=1
Post-install configurations
After installing Magento, run the commands for compile and deploy for the code:
-
Switch to the correct user.
1
sudo su - magento
-
Change to the
app/bin
directory. -
Compile Magento.
1
php magento setup:di:compile
-
Deploy Magento
1
php magento setup:static:deploy
Optionally, if you used Vagrant with the hostmanager plugin, update the hosts file.
-
Access the
localdev
root for the Vagrant box. -
Update the hosts file.
1
vagrant hostmanager
Additional software and services
For development and testing in an environment as close to Integration as possible, you may also want to install additional tools, software, and services. These services are configured using services.yaml
.
- Redis
- ElasticSearch
- RabbitMQ
- Additional software for Magento
Verify your local workspace
To verify the local, access the store using the URL you passed in the install command. For this example, you can access the local Magento store using the following URL formats:
http://magento.local/
http://magento.local/admin
To change the URI for the Admin panel, use this command to locate it:
1
php bin/magento info:adminuri
To verify the Integration master branch environment, log into the Project Web Interface and select your named project. In the list of branches, select the Master. Click Access site to pull up a list of URLs (HTTP and HTTPS) and click the preferred link to open the site. To view the admin, add /admin or other configured Admin URI.
With these steps completed, you should have:
- A Magento Commerce account and initial project setup and master branch
- A local workspace configured with installations of required software, Magento Cloud CLI, and Magento
- SSH keys set up
- The Magento file system owner configured
- Your initial code branch
- Magento authentication keys set up and configured in the project and local
Next steps
For Pro projects, we strongly recommend fully deploying this base Magento template master
branch without any code or configuration changes to Staging and Production. For instructions, see First time deployment.
For Starter projects, you are ready to start developing.