Totally lost? Need a helping hand? Try our installation quick reference (tutorial) or installation roadmap (reference).
Contents
- Intended audience
- First steps
- Composer and Magento
- Install Composer
- Get the Magento CE metapackage
- Get the Magento EE metapackage
- Set file system ownership and permissions
Intended audience
The audience for this topic is anyone who downloads the Magento metapackage using composer create-project
. If that isn鈥檛 you, go back and choose another starting point.
First steps
As an integrator, you want to manage each of your Magento core components and third-party components using the Component Manager and System Upgrade.
To do so, you start by creating a Composer project from our metapackage. The metapackage installs each component so it can be centrally managed after installation.
Composer and Magento
We now use Composer for dependency management. Composer enables us to manage the Magento components and their dependencies.
Everyone who uses the Magento software must install Composer to update components and Magento. If you install Magento using an archive, you don't need Composer to install Magento, but you do need Composer for updates.
Composer provides you with the following advantages:
- Enables you to reuse third-party libraries without bundling them with source code
- Component-based architecture with robust dependency management
- Manages dependencies to reduce extension conflicts and compatibility issues
- Versioned dependencies
- Semantic versioning
- Supports the PHP Framework Interoperability standard
Install Composer
First, check if Composer is already installed:
In a command prompt, enter any of the following commands:
composer --help
composer list --help
If command help displays, Composer is already installed; in that case, you can skip the next steps and continue with Clone the Magento repository.
If an error displays, use the following steps to install Composer.
To install Composer:
-
Change to or create an empty directory on your Magento server.
-
Enter the following commands:
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
For additional installation options, see the Composer installation documentation.
Get the Magento CE metapackage
To get started:
- If you haven鈥檛 done so already, get your authentication keys.
- Log in to your Magento server as, or switch to, the Magento file system owner.
- Change to the web server docroot directory, or to a directory you鈥檝e configured as a virtual host docroot.
-
Enter the following command:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>
When prompted, enter your authentication keys. Your public key is your username; your private key is your password.
This command creates the project and downloads dependencies for it. The project is in a directory named
<installation directory name>
if you provided the parameter orproject-community-edition
if you did not.If the following error displays, see troubleshooting:
file_get_contents(app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directory
- Continue with Set file system ownership and permissions.
Get the Magento EE metapackage
To get started:
-
Make sure you know your support portal user name and password.
If you don鈥檛 remember it, contact Magento Support before you continue.
- Log in to your Magento server as, or switch to, the Magento file system owner.
- Change to the web server docroot directory, or to a directory you鈥檝e configured as a virtual host docroot.
-
Enter the following command:
composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition <installation directory name>
When prompted, enter your authentication keys. Your public key is your username; your private key is your password.
The following error indicates your tokens are incorrect:
Could not find package magento/project-enterprise-edition with version 2.0.0
This command creates the project and downloads dependencies for it. The project is in a directory named
<installation directory name>
if you provided the parameter orproject-enterprise-edition
if you did not.If the following error displays, see troubleshooting:
file_get_contents(app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directory
- Continue with the next section.
Set file system ownership and permissions
The following sections discuss how to set file system ownership and permissions:
Why we recommend you set file system permissions
Malicious exploits are an unfortunate reality in the internet age. To help prevent exploits that take advantage of the file system, we recommend you set Magento file system ownership and permissions in a particular way. For more information, see Overview of ownership and permissions.
This topic covers permissions for a development environment. In production, the web server user should have limited write privileges. To help manage you production and developer modes, we provide the magento deploy:mode:set
command.
The important things:
- The owner of the Magento file system:
- Must have full control (read/write/execute) of all files and directories.
- Must not be the web server user; it should be a different user.
- The web server user must have write access to the following files and directories:
var
app/etc
pub
In addition, the web server's group must own the Magento file system so that the Magento user (who is in the group) can share access to files with the web server user. (This includes files created by the Magento Admin or other web-based utilities.)
We recommend setting the permissions as follows:
- All directories have 770 permissions.
770 permissions give full control (that is, read/write/execute) to the owner and to the group and no permissions to anyone else. - All files have 660 permissions.
660 permissions mean the owner and the group can read and write but other users have no permissions.
File system permissions and ownership
Use the following steps:
- If you haven鈥檛 already done so, log in to your Magento server as, or switch to, the Magento file system owner.
-
Change to the Magento installation directory:
cd <web server docroot>/<magento2 base dir>
The base directory is typically a subdirectory named
magento2
under your web server鈥檚 docroot. Need help locating the docroot? Click here.Examples:
- Ubuntu:
/var/www/magento2
- CentOS:
/var/www/html/magento2
- Ubuntu:
-
Set ownership:
chown -R :<your web server group name> .
Typical examples:
- CentOS:
chown -R :apache .
- Ubuntu:
chown -R :www-data .
- CentOS:
-
Set permissions:
find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \; && chmod u+x bin/magento
If you must enter the commands as
sudo
, use:sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento
Next step
Install the Magento software:
Find us on