(Easy) Install the Magento archive on your server

Intended audience

The audience for this topic is anyone who downloaded a compressed Magento software archive (.zip or .tar). If you’d rather use Composer, go back and choose another starting point.

Prerequisites

Before you continue, make sure you’ve done all of the following:

Get the Magento software

The following table discusses where to get the Magento software. We provide the following downloads:

  • Magento Open Source or Magento Commerce software only
  • Magento Open Source or Magento Commerce software with sample data (designed to help you learn Magento faster)

These packages are easy to get and install. You don’t need to use Composer, all you need to do is to upload a package to your Magento server or hosted platform, unpack it, and run the web-based Setup Wizard.

Archives are available in the following formats: .zip, .tar.bz2, .tar.gz

Magento edition Install package location
Magento Open Source

www.magento.com/download

Choose either the software or the software and sample data:

  • Magento-CE-<version>.* (without sample data)
  • Magento-CE-<version>+Samples.* (with sample data)
  • <version/> is the three-digit release number (for example, 2.0.7, 2.1.0, and so on.)

Magento Commerce Use the following steps:
  1. Go to www.magento.com
  2. In the top horizontal navigation bar, click My Account.
  3. Log in with your Magento username and password.
  4. In the left navigation bar, click Downloads.
  5. In the right pane, click Magento Enterprise Edition 2.X > Full Release or Magento Enterprise Edition 2.X > Full Release + Sample Data for the software.
  6. Follow the instructions on your screen to complete the Magento Commerce download:
    • Magento-EE-<version>.* (without sample data)
    • Magento-EE-<version>+Samples.* (with sample data)
  7. Transfer the installation package to your development system.

Transfer the Magento archive to your server

To transfer the Magento software archive to your server:

  1. Install and configure a file transfer protocol (FTP) or secure copy protocol (SCP) client to transfer the Magento software from your computer to your server.

    There are many ways to configure FTP and SCP. Following are a few packages you can use. Magento does not recommend particular software.

  2. Create a connection to your Magento server.

    Follow the prompts on your screen or consult the documentation provided with your FTP software for more information.

  3. After you log in to your server, browse to locate the Magento Open Source or Magento Commerce archive on your local system.

    On the remote system, browse to locate the web server docroot directory.

    The following figure shows an example.

  4. Transfer the archive from your local system to the web server docroot directory.

    On some FTP client software, you do this by dragging and dropping.

  5. Wait while the transfer completes.
  6. Log in to your Magento server, or switch to, the Magento file system owner
  7. Change to the web server docroot or the virtual host directory.
  8. Create a subdirectory for the Magento software.

    If you set up a virtual host, the subdirectory name must match the name in your virtual host.

    For example,

    1
    
    mkdir magento2ce
    
    1
    
    mkdir magento2ee
    

    You can also use a generic directory name

    1
    
    mkdir magento2
    
  9. Copy the Magento archive to that directory.

    For example,

    1
    
    cp /var/www/Magento-CE-2.0.0+Samples.tar.bz2 magento2
    
  10. Continue with the next section.

Extract the software on your server

Log in to your Magento server as, or switch to, the Magento file system owner and extract the software package in the web server docroot using one of the following commands:

File format Command to extract
.tar.gz tar zxf <filename>
.zip unzip <filename>
.tar.bz2 tar jxf <filename>

The Magento software extracts to the directory you created. After the file has extracted, either delete the Magento archive or move it to another directory.

Set pre-installation file system ownership and permissions

This topic discusses how to set read-write permissions for the web server group before you install the Magento software. This is necessary so the Setup Wizard or command line can write files to the Magento file system.

The procedure you use is different, depending on whether you use shared hosting and have one user or if you use a private server and have two users.

If you’re using a Magento version earlier than 2.0.6, see Appendix—Magento file system ownership and appendix (legacy) instead.

Set permissions for shared hosting (one user)

This section discusses how to set pre-installation permissions if you log in to the Magento server as the same user that also runs the web server. This type of setup is common in shared hosting environments.

To set ownership and permissions for a one-user system:

To set permissions before you install the Magento software:

  1. Log in to your Magento server.
  2. Use a file manager application provided by your shared hosting provider to verify write permissions are set on the following directories:

    • vendor (Composer or compressed archive installation)
    • app/etc
    • pub/static
    • var
    • generated
    • Any other static resources
  3. If you have command-line access, enter the following commands in the order shown:

    1
    
    cd <magento_root>
    
    1
    
    find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} +
    
    1
    
    find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} +
    
    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:

1
cd /var/www/html/magento2 && find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} + && chmod u+x bin/magento
  1. If you haven’t done so already, get the Magento software in one of the following ways:

  2. After you have set file system ownership and permissions, continue with any of the following:

To further restrict permissions after installing the Magento software, you configure a Magento umask.

Set ownership and permissions for two users

This section discusses how to set ownership and permissions for your own server or a private hosting setup. In this type of setup, you typically cannot log in as, or switch to, the web server user. You typically log in as one user and run the web server as a different user.

To set ownership and permissions for a two-user system:

Complete the following tasks in the order shown:

About the shared group

To enable the web server to write files and directories in the Magento file system but to also maintain ownership by the Magento file system owner, both users must be in the same group. This is necessary so both users can share access to Magento files (including files created using the Magento Admin or other web-based utilities).

This section discusses how to create a new Magento file system owner and put that user in the web server’s group. You can use an existing user account if you wish; we recommend the user have a strong password for security reasons.

Skip to step 2 if you plan on using an existing user account.

Step 1: Create the Magento file system owner and give the user a strong password

This section discusses how to create the Magento file system owner. (Magento file system owner is another term for the command-line user.)

To create a user on CentOS or Ubuntu, enter the following command as a user with root privileges:

1
adduser <username>

To give the user a password, enter the following command as a user with root privileges:

1
passwd <username>

Follow the prompts on your screen to create a password for the user.

If you don’t have root privileges on your Magento server, you can use another local user account. Make sure the user has a strong password and continue with Put the Magento file system owner in the web server group.

For example, to create a user named magento_user and give the user a password, enter:

1
sudo adduser magento_user
1
sudo passwd magento_user

Because the point of creating this user is to provide added security, make sure you create a strong password.

Step 2: Find the web server user’s group

To find the web server user’s group:

  • CentOS:
1
grep -E -i '^user|^group' /etc/httpd/conf/httpd.conf
1
or
1
grep -Ei '^user|^group' /etc/httpd/conf/httpd.conf

Typically, the user and group name are both apache.

  • Ubuntu: ps aux | grep apache to find the apache user, then groups <apache user> to find the group.

Typically, the username and the group name are both www-data.

Step 3: Put the Magento file system owner in the web server’s group

To put the Magento file system owner in the web server’s primary group (assuming the typical Apache group name for CentOS and Ubuntu), enter the following command as a user with root privileges:

  • CentOS: usermod -a -G apache <username>
  • Ubuntu: usermod -a -G www-data <username>

The -a -G options are important because they add apache or www-data as a secondary group to the user account, which preserves the user’s primary group. Adding a secondary group to a user account helps restrict file ownership and permissions to ensure members of a shared group only have access to certain files.

For example, to add the user magento_user to the apache primary group on CentOS:

1
sudo usermod -a -G apache magento_user

To confirm your Magento user is a member of the web server group, enter the following command:

1
groups magento_user

The following sample result shows the user’s primary (magento) and secondary (apache) groups.

1
magento_user : magento_user apache

Typically, the username and primary group name are the same.

To complete the task, restart the web server:

  • Ubuntu: service apache2 restart
  • CentOS: service httpd restart

Step 4: Get the Magento software

If you haven’t done so already, get the Magento software in one of the following ways:

Step 5: Set ownership and permissions for the shared group

To set ownership and permissions before you install the Magento software:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
  2. Enter the following commands in the order shown:
1
cd <magento_root>
1
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
1
find var generated 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 generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated 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 generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && sudo chown -R :apache . && sudo chmod u+x bin/magento

Next step

After you have set file system ownership and permissions, continue with any of the following:

Switch to the Magento file system owner

After you’ve performed the other tasks in this topic, enter one of the following commands to switch to that user:

  • Ubuntu: su <username>
  • CentOS: su - <username>

For example,

1
su magento_user

Related topics

Install the Magento software: