Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
Install Magento 2.4 on Centos 8
- Ubuntu 18.04
- CentOS 7
- Deprecated guides:
- Ubuntu 9.10
- Ubuntu 16.04
- Debian 5
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
This guide explains how to install Magento on CentOS 8. Magento is a popular Open source e-commerce platform from Adobe. Magento uses PHP, Elasticsearch, and either a MySQL or MariaDB database system, along with a web server such as Apache. This guide focuses on how to install the free Magento Open Source Edition. Magento also offers Magento Commerce (with more extensive out of the box features and unlimited scaling), and the paid Magento Commerce (On-Premises) version with even more features and support.
Before You Begin
If you have not already done so, create a Linode account and Compute Instance. It’s recommended to run Magento on at least a 4GB instance. See our Getting Started with Linode and Creating a Compute Instance guides.
Follow our Setting Up and Securing a Compute Instance guide to update your system. You may also wish to set the timezone, configure your hostname, create a limited user account, and harden SSH access. Do not follow the Configure a Firewall section yet. This guide includes firewall rules specifically for an Magento server.
sudo dnf update && sudo dnf upgrade
This guide uses the sample domain name of
example.com
and a Magento root directory of/var/www/html/example.com/public_html
, along with default username and password variables such asmagentouser
andmagentopassword
. Substitute your own values when you encounter these variables throughout the guide.
root
or with the sudo
prefix. For more information on privileges, see our
Users and Groups guide.Advantages/Drawbacks of Magento
Magento is a popular choice for e-commerce platforms due to its large number of features. It includes drag and drop functionality for page development and user experience. Magento scales well, is flexible and customizable, and is useful for both B2B and B2C contexts. Developers can add or develop plug-in modules to extend Magento’s core functionality. Magento also has a large user-base and helpful community.
On the other hand, some users find Magento difficult to set up and configure. Non-technical users may have trouble customising their storefront.
A Summary of the Magento Installation Process
A complete Magento installation consists of the following high-level steps. Each step is described below.
- Verify the Magento system requirements;
- Upgrade and validate the host, including the CentOS platform;
- Install and configure prerequisite components;
- Download and extract the Magento software;
- Set the necessary ownership and permissions for files and directories;
- Run the Magento set-up program to install the software;
- Complete the Magento post installation tasks.
After these steps, you can set up your storefront and put your site into production.
Verify the Magento System Requirements
Memory Requirements
Magento requires as much as 2GB of free memory. If your system does not have enough free memory, you must create a swap file first. We recommend at least a Linode 4GB for the best performance.
If you do not have access to a system with 2GB of memory, you can create a swap file with the following commands. This swap file is temporary and only persists until the next reboot.
Create a directory for the swap file, and add a file within this directory to hold the swap data. The
count
parameter refers to the size of the swap file in megabytes. This must be set to at least 2048, but you can configure it to an even larger amount if you want.sudo mkdir /swapdir/ sudo dd if=/dev/zero of=/swapdir/swapfile bs=1MB count=2048
Set the permissions for the file:
sudo chmod 600 /swapdir/swapfile
Format this file into a functional swap file:
sudo mkswap /swapdir/swapfile sudo swapon /swapdir/swapfile
Browser Requirements
Magento storefronts are designed to run on one of the latest two releases of the following browsers:
- Microsoft Edge
- Firefox (any operating system)
- Chrome (any operating system)
- Safari (Mac operating system only)
- Chrome for mobile (Android 4 or later) for mobile storefronts
Magento can run on iOS 12 or later on the following platforms:
- Safari Mobile for iPad 2, iPad Mini, iPad with Retina Display (desktop storefronts)
- Safari Mobile for iPhone 6 or later (mobile storefronts)
Upgrade and Validate the Host, Including the CentOS Platform
- Ensure your host meets the system requirements.
- Confirm your host is running the latest version of CentOS 8 and update it if necessary.
- Set up and test any load balancing configuration (if applicable).
- Back up your system before proceeding with the installation so you can roll back if necessary.
Install and Configure Prerequisite Components
Several other software components must be present and properly configured before Magento can be installed. The components are:
- The web server, preferably Apache
- SQL database
- PHP 7.4
- Elasticsearch
Follow the instructions in the How to Install a LAMP Stack on CentOS 8 guide to install Apache, SQL, and PHP.
- Enable the repositories by using:
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
- List the available PHP version using:
sudo dnf module list php
- Enable the latest version of PHP using:
sudo dnf module enable php:remi-7.4
Web Server
Magento requires Apache version 2.4. You can verify what version of Apache you have with the following command:
httpd -v
Magento requires the
mod_deflate.c
,mod_expires.c
,mod_headers.c
,mod_rewrite.c
,mod_security.c
,mod_ssl.c
, and themod_version.c
Apache modules. You can generate a list of the installed modules via the commandsudo httpd -M
. Look for the presence of a component nameddeflate_module
to verifymod_deflate.c
is installed.Install any missing modules with the following command, replacing
modname
with the name of the actual module:sudo dnf install mod_modname
Check if the ssl module is installed using
sudo httpd -t -D DUMP_MODULES | grep ssl
command. Ifmod_ssl.c
is not already installed, you should create a Secure Sockets Layer (SSL) certificate when you install it. Use the following command to create your own self-signed key and certificate:openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/httpd.key -x509 -days 365 -out /etc/pki/tls/certs/httpd.crt
After creating the key, edit the
/etc/httpd/conf.d/ssl.conf
file. Set the values ofSSLCertificateFile
andSSLCertificateKeyFile
to reference the key you created:- File: /etc/httpd/conf.d/ssl.conf
1 2
SSLCertificateFile /etc/pki/tls/certs/httpd.crt SSLCertificateKeyFile /etc/pki/tls/private/httpd.key
Note Most payment processors and financial institutions do not recognise or accept self-signed certificates. Before putting your store into production, you must obtain a commercially-signed certificate. More information can be found in the Linode guide about SSL certificates.Configure the virtual host settings for your website on Apache. There are a variety of ways to structure these settings. One straightforward approach is to add them to the
/etc/httpd/conf.d/vhost.conf
file. Add the following contents to the file, replacingexample.com
with your own domain. The directory specified within the virtual host serves as your Magento root directory. Later on, you will install the Magento software from this location.To allow URLs with path separators (for example,
%2F
for “/”), setAllowEncodedSlashes
toNoDecode
in either the global server config or the virtual host configuration. The default value ofoff
causes Apache to refuse this class of URLs and return a 404 error.- File: /etc/httpd/conf.d/vhost.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<Directory /var/www/html/example.com/public_html> Require all granted </Directory> <VirtualHost *:80> ServerName example.com ServerAlias www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html/example.com/public_html ErrorLog /var/www/html/example.com/logs/error.log CustomLog /var/www/html/example.com/logs/access.log combined <Directory /var/www/html/example.com/public_html> Options Indexes FollowSymLinks MultiViews AllowOverride All </Directory> </VirtualHost>
Add an
IncludeOptional
directive toetc/httpd/conf/httpd.conf
to parse this directory:- File: etc/httpd/conf/httpd.conf
1
IncludeOptional conf.d/*.conf
SELinux might prevent Apache from writing to these logs or even from starting up with these settings. If this occurs, navigate to the
var/www/html/example.com
directory and run the following commands:semanage fcontext -a -t httpd_sys_rw_content_t 'logs' sudo semanage fcontext -a -t httpd_sys_rw_content_t 'logs'
If Apache is not already configured to activate at boot, add an entry to
systemctl
to this effect. Then restart the web server:sudo systemctl start httpd.service sudo systemctl enable httpd.service sudo systemctl restart httpd.service
SQL Database
MySQL 8.0 is recommended, although MariaDB version 10.4+ can also be used. All Magento SQL statements are compatible with MariaDB. Execute the following steps to prepare your database for the Magento installation.
Ensure MySQL is installed. Confirm its release version and upgrade it if necessary.
sudo dnf install mysql-server mysql -V
Ensure the MySQL server is running. If not, start your server and verify its status with the following commands:
sudo systemctl start mysqld.service sudo systemctl status mysqld
Run the
mysql_secure_installation
utility to ensure your database is more secure. This utility walks you through your security settings and allows you to set a root password.mysql_secure_installation
Log in to mysql as root:
mysql -u root -p
Create a database and user account for Magento. Replace
dbpassword
with your own strong password (the exclamation point “!” must not be used in an MySQL password). You can also change the user name to something more specific (in this case, ensure you make the same substitution in the GRANT command).CREATE database magento; CREATE user 'magento' IDENTIFIED BY 'dbpassword'; GRANT ALL ON magento.* TO 'magento'; FLUSH PRIVILEGES; EXIT;
Log in to the database as the new user and verify it is accessible:
mysql -u magento -p
Record the name of the database and password you created and store this information in a safe place for later.
If MySQL is not already configured to become active at start-up time, add this entry to
systemctl
:systemctl enable mysqld
PHP
Magento recommends the use of PHP 7.4.0 or higher.
Verify the following PHP modules are already enabled through the use of the
php -m
command:ext-bcmath ext-ctype ext-curl ext-dom ext-gd ext-hash ext-iconv ext-intl ext-mbstring ext-openssl ext-pdo_mysql ext-simplexml ext-soap ext-xsl ext-zip ext-sockets
Install any missing modules. The following example installs
ext-bcmath
,ext-gd
, andext-intl
:sudo dnf install php-bcmath php-gd php-intl
The php.ini
file requires a number of modifications. This file is typically located in the /etc
directory (if not, its location can be found in the phpinfo.php
file).
Set the correct system time zone for your host. You can use the PHP timezone reference to locate the right setting for your time zone.
date.timezone =
Set the PHP memory limit. 1G is recommended for compiling code or deploying assets, while 2G is required for debugging, and 4G for testing.
memory_limit=2G
Increase the cache amounts to the recommended settings. This allows PHP to cache file paths and increases performance.
realpath_cache_size=10M realpath_cache_ttl=7200
Adjust a few other settings, such as
upload_max_filesize
,max_input_time
, andmax_execution_time
. See the settings in the following file snippet for the full list.- File: /etc/php.ini
1 2 3 4 5 6 7 8 9
date.timezone = Europe/London memory_limit= 2G realpath_cache_size=10M realpath_cache_ttl=7200 upload_max_filesize = 256M max_execution_time = 18000 max_input_time = 30 error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR error_log = /var/log/php/error.log
Enable the PHP Opcache for better performance. This setting can be found and modified in opcache.ini
.
Open the
opcache.ini
file. This file is usually found at/etc/php.d/opcache.ini
, but you can find its exact location using thephp --ini
command.Note If you do not find theopcache.ini
file, install it usingsudo dnf install php-opcache
Set the
opcache.save_comments
variable to 1, uncommenting it if necessary:opcache.save_comments = 1
If you have other
opcache.ini
files, modify all of them in the same manner.Create a log directory for PHP and assign ownership to the web server:
sudo mkdir /var/log/php sudo chown apache /var/log/php
Restart the web server:
sudo systemctl restart httpd.service
Elasticsearch
Elasticsearch provides advanced search capabilities for Magento. Magento requires Version 7.6 or higher of Elasticsearch (the current edition is 7.10). Elasticsearch in turn requires Java Development Kit (JDK) version 1.8 or higher. Elasticsearch must be installed before installing Magento. We recommend Elasticsearch and the web server run on the same host for a more trouble-free deployment.
Download an Elasticsearch archive for CentOS on The Elasticsearch download page and follow all instructions.
Enter the directory where Elasticsearch is installed (for example,
elasticsearch-7.10.0
) and start Elasticsearch:./bin/elasticsearch
Run a curl command to confirm Elasticsearch works. A “green” status indicates a successful reply. Use the following command to take an Elasticsearch health check:
curl -XGET 'localhost:9200/_cat/health?v&pretty'
Note Elasticsearch could potentially be in the “yellow” state if back up capabilities or other features are not available. You can still proceed with the installation in this case, but we recommend you correct this before deployment.Confirm the version of the Java JDK and install or upgrade it as necessary. The Java Runtime Environment (JRE) is not required.
java -version yum install java-1.8.0-openjdk
Your firewall might be set up to disallow communication between Elasticsearch and your web server. The CentOS SELinux page is helpful in case you run into any issues. If you are running SELinux in
enforcing
mode, you can use the following command to allow Linux to connect to local upstream components:sudo setsebool -P httpd_can_network_connect=1
Install and enable the mod_proxy component for the Apache server if it is not already installed. Use the command
httpd -M
to see what modules are installed.sudo dnf install mod_proxy
Enable communication between Elasticsearch and the web server. This process sets up an unsecured communication channel between Apache and Elasticsearch because this is easier to set up and verify. To improve the security of this channel later on, consult Magento’s proxy information. Open the file
/etc/httpd/sites-available/000-default.conf
, and add the following information to the top of the file:- File: /etc/httpd/sites-available/000-default.conf
1 2 3 4 5
Listen 8080 <VirtualHost *:8080> ProxyPass "/" "http://localhost:9200/" ProxyPassReverse "/" "http://localhost:9200/" </VirtualHost>
Ensure there is an
IncludeOptional
entry forsites-available/*.conf
in/etc/httpd/conf/httpd.conf
.- File: /etc/httpd/conf/httpd.conf
1
IncludeOptional sites-available/*.conf
Restart Apache:
sudo systemctl restart httpd.service
Use the following command to validate the communication channel between Apache and Elasticsearch. An
HTTP 200 OK
response indicates the components are working together.curl -i http://localhost:8080/_cluster/health
Note Elasticsearch’s default heap size of 1G is not enough for most deployments and could lead to timeouts or other failures. For production environments, set theES_HEAP_SIZE
variable to a higher value with the commandexport ES_HEAP_SIZE=4g
Secure Socket Layer (SSL)
HTTPS requires a valid commerically-signed certificate. Transport Layer Security (TLS) 1.2 or later must be used.
Required System Dependencies
Magento requires the presence of several system tools in order to work correctly. Most hosts already have these tools.
- bash
- gzip
- lsof
- mysqldump
- nice
- sed
- tar
Optional Software Extensions
Magento can be used with the following optional software components:
- Redis: version 5.0 is recommended. You can use Redis to cache pages and for session storage.
- Varnish: version 6.x is recommended.
- RabbitMQ: 3.8.x is required. RabbitMQ provides a facility to publish messages to queues and receive messages asynchronously.
Download and Extract the Software
Magento software is available to download in several compression formats on the Magento downloads page.
Navigate to the Magento downloads page.
Scroll to the “Archive (zip.tar)” section where you can download either a zipped or tarred file. Choose the desired “Build version” (we recommend you install the latest version… as of November 2020, this is version 2.4.1), and the “Format” (zip, tar.gz, or tar.bz2). You can optionally choose to include the sample/test data set. This data set allows you to view a fully-configured storefront after Magento is fully installed. Click Download to begin downloading the file.
Note You must create an account before you can download Magento. There is no cost for either the account or the download.If you have downloaded the software onto a different computer than the host, transfer the Magento files to the host via
scp
,ftp
, or another file transfer method. Replace theuser
andyourhost
values with your user name and host IP address:scp /localpath/magento-ce-2.*.tar.gz user@LinodeIPaddress:~/
On your host, navigate to the Magento root directory. (This is the directory specified within the virtual host entry for your domain.) Copy the Magento archive to this subdirectory.
Extract the files using the appropriate command from the list below (the one corresponding to your archive format). Substitute the name of your actual archive in place of
archive
. After the extraction process is complete, either delete the archive or store it in a secure place elsewhere on your system.tar -zxvf archive.tar.gz unzip archive.zip tar -jxvf archive.tar.bz2
Set the Necessary Ownership and Permissions for Files and Directories
You must configure permissions and ownership for some directories and files before installing Magento. This process differs somewhat depending on whether the Magento and the web server users are different or not. A one-user setup is most typical in a shared hosting situation, but it is not as secure as having two users.
If there is only one user, navigate to your Magento root directory and enter the following commands. This ensures certain directories are writable.
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
If the Magento and web server users are different, create a shared group for both owners so they both have access to the Magento files. This method is considered more secure than having the same owner for both services.
Create a Linux user to serve as the Magento file system owner and provide this user with a password. The user name here is magento, but you can choose another name if you want.
sudo adduser "magento" sudo passwd "magento"
Determine the web server user’s group (this is typically called
apache
):grep -Ei '^user|^group' /etc/httpd/conf/httpd.conf
Add the Magento file system owner to the web server group. Substitute the actual user names for the web server group and the Magento file system owner in the following command:
sudo usermod -a -G "apache" "magento"
Confirm the Magento user is now a member of the webserver group:
groups "magento"
Restart your web server:
sudo systemctl restart httpd.service
Ensure you are still in the Magento root directory and type the following commands, using your specific web server user and Magento user names for the
chown
command.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 magento:apache . sudo chmod u+x bin/magento
SELinux might prevent Apache and PHP from writing to the Magento directory. Replace
magentorootdirectory
with your actual root directory in the following commands to work around this problem:sudo restorecon -R "magentorootdirectory" sudo setsebool -P httpd_unified 1
Restart the web server again:
sudo systemctl restart httpd.service
SELINUX=enforcing
to SELINUX=permissive
in the /etc/selinux/config
file. This setting relaxes security; it only logs potential violations. Ensure you understand all the security implications of this before changing this value on a production system. It is best to leave SELinux in enforcing mode and configure any exceptions on a case-by-case basis.Run the Magento Set-up Program to Install the Software
Navigate to the Magento root directory (the directory specified within the virtual host entry for your domain). You must either install Magento from within this directory or specify the complete directory path to this location in the command.
Run the
install
command. Specify all the mandatory options listed right below along with any optional ones you might require. See the table below this section for a list of all of the optional parameters.sudo bin/magento setup:install --<option>=<value> ... --<option>=<value>
- admin-firstname - This is the Magento administrator user’s first name.
- admin-lastname - This is the Magento administrator user’s last name.
- admin-email - This is the email of the Magento administrator.
- admin-user - This is the user name of the Magento administrator (for logging into the Magento Admin page).
- admin-password - This is the user password for the Magento administrator (enclosed in single quotes). Magento requires you to use a password with at least one letter and one number.
- base-url - This is the URL to access the storefront. For example:
http[s]://<website>/<Magento-install-dir>/
orhttp[s]://<ip>/<Magento-install-dir>/
. The trailing slash is mandatory. TheMagento-install-dir
is the path of the Magento directory root (the website directory in the virtual hosts file) relative to the web server document root. If these two values are the same, leaveMagento-install-dir
blank. To access this on a localhost, usehttp://127.0.0.1/<Magento-install-dir>/
. For a containerised environment, use‘’
. - db-host - This is the address of the database. If the database server resides on the same host as Magento, use localhost. If not, specify the address or name of the server where the database is hosted.
- db-name - This is the name of the database instance where the Magento database tables are installed. We used
magento
earlier. - db-user - This is the user name of the owner of the Magento database instance. The default is root.
- db-password - This is the password for the Magento database user.
Here is an example of a sample installation. Replace
db-password
anddb-user
with the user name and password you created for MySQL earlier. Create a unique and strong password for theadmin-password
. Replaceyour_URL_or_domain
with the properbase-url
as described above. See the table following this section for more information on each option.bin/magento setup:install --admin-firstname="Magento" --admin-lastname="User" --admin-email="user@example.com" --admin-user="Magentouser" --admin-password="password" --db-name="magento" --db-host="localhost" --db-user="magento" --db-password="password" --language=en_US --currency=USD --timezone=Europe/London --cleanup-database --base-url=http://"your_URL_or_domain"
Wait for Magento to complete its installation. This typically takes 5 to 10 minutes. Upon completion, the program displays a “Success” message as well as a
Magento Admin URI
key. The URI provides access to the Magento Admin page. The label begins withadmin_
, followed by a six-digit alphanumerical sequence.For ease of development, you can place your Magento application into development mode while you work on getting it running. See the post-installation section for information on placing your store into production mode.
sudo bin/magento deploy:mode:set developer
Magento Admin URI
, the admin-user
name, and the admin-password
in a safe place. You will require this information to access your Magento Admin page and administer your site. It is important you keep your admin information secure.Optional Magento Parameters
Option | Definition |
---|---|
backend-frontname | This specifies the Uniform Resource Identifier (URI) used to access the Magento Admin page. If you omit this parameter, Magento generates a random URI and displays it at the end of the installation. Magento recommends a random URI for security purposes. The Magento URI must only contain alphanumeric values and the underscore character. |
db-prefix | This prefix identifies the Magento database tables for the installation. Only specify a value if the Magento database already contains Magento tables from another Magento instance. This prefix has a maximum length of five characters, it must begin with a letter, and it may include only letters, numbers, and underscore characters. |
db-ssl-key | This is the path to the client key. |
db-ssl-cert | This is the path to the client certificate. |
db-ssl-ca | This is the path to the server certificate. |
language | This is a code specifying the language to use in the Magento Admin page and storefront. The command magento info:language:list can be used to list all of the language codes. |
currency | This is the default currency to use in the storefront. The command magento info:currency:list can be used to list all of the currency codes. |
timezone | This is the default time zone to use in the Magento Admin page and storefront. The command magento info:timezone:list can be used to list all of the time codes. |
use-rewrites | A setting of 1 configures the web server to use rewrites for any generated links in the storefront and Magento Admin page. A setting of 0 disables these rewrites. |
use-secure | A setting of 1 enables SSL usage in storefront URLs. 0 disables the use of SSL. |
base-url-secure | This sets a secure base URL for accessing the Magento Admin page and storefront. |
use-secure-admin | A setting of 1 mandates the use of SSL to access the Magento Admin page. 0 means SSL is not used. |
admin-use-security-key | The default setting of 1 instructs Magento to generate a random key value to access pages in the Magento Admin page and in forms. This helps prevent cross-site script forgery attacks. 0 disables the key. |
session-save | A setting of db stores session data in the database. This is the recommended setting if you have a clustered database or if your file system access is slow. A setting of files stores session data in the file system. A setting of redis stores session data in Redis. If you intend to use Redis, it must already be installed. |
cleanup-database | Use this parameter without any value to drop all existing database tables before installing the Magento software. If the parameter is not specified, the installation program leaves the Magento database intact. |
db-init-statements | This parameter provides database initialization statements (if any) to run when connecting to the MySQL database. The default is SET NAMES utf8; . |
sales-order-increment-prefix | This specifies a string value to serve as a prefix for sales orders. It guarantees unique numbers for payment processors. |
consumers-wait-for-messages | A setting of 1 indicates consumers must wait for a message from the queue. 0 disables this setting. |
key | You can specify a key to encrypt sensitive data in the Magento database. Otherwise, Magento generates one for you. |
Elasticsearch Options
The following optional configuration items can be used to customise your Elasticsearch setup.
Option | Definition |
---|---|
search-engine | The version of Elasticsearch you are using. The default is elasticsearch7 . |
elasticsearch-host | The host name or IP address where Elasticsearch is running. The default is localhost . |
elasticsearch-port | The port for incoming Elasticsearch HTTP requests. The default is 9200 . |
elasticsearch-index-prefix | This indicates a prefix to identifies the Elasticsearch index. The default is magento2 . |
elasticsearch-timeout | The number of seconds before the system times out. The default is 15 . |
elasticsearch-enable-auth | A setting of true enables authentication on the Elasticsearch server. The default is false . |
elasticsearch-username | The user ID used to authenticate Elasticsearch (this is only required if elasticsearch-enable-auth is set to true). |
elasticsearch-password | The password used to authenticate Elasticsearch (this is only required if elasticsearch-enable-auth is set to true). |
RabbitMQ and Locking Options
Optional configuration parameters are available if you intend to use the RabbitMQ software or customizable locking. See the Magento command line options page for more information on these and all the other options.
Generic Commands and Common Options
The following commands can be run at any time, even before installing the software.
- magento list - Lists all available commands.
- magento help
command
- Provides help for the specified command.
The following options can also be used with any command.
Long | Short | Meaning |
---|---|---|
help | -h | Get help for any command. |
quiet | -q | This runs Magento in “quiet mode” with no output. |
no-interaction | -n | This turns off interactive prompts |
verbose=1,2,3 | -v, -vv, or -vvv | This sets the verbosity level. The most verbose level is --verbose=3 or -vvv , whereas the default is --verbose=1 or -v . |
version | -V | Displays the version of the Magento application. |
ansi | n/a | This forces output into the ANSI format. |
no-ansi | n/a | This disables ANSI formatting. |
You can always rerun the Magento installation program later on to set new options or correct errors (for example, to add an optional component such as RabbitMQ). You can also reconfigure many options on the Magento Admin page. |
Complete the Magento Post-installation Tasks
There are a few post-installation tasks remaining to ensure your application is stable and more secure.
Install the Magento Cron Jobs
Magento relies on several regularly-scheduled tasks in order to run correctly. You should use Magento’s cron utility to create the necessary entries in CentOS’s cron file.
Navigate to the Magento root directory.
Execute the following command:
bin/magento cron:install
Review the crontab entries to ensure the Magento-related cron entries are now present:
crontab -l
Verifying the Installation
Visit your storefront with your chosen web browser. Use the address you configured as the
base-url
during the installation. If you downloaded the sample dataset, you’ll see a storefront mock-up complete with images. Otherwise the page displays a sample template with some generic default messages such as “homepage content goes here”.Confirm you can access the Magento Admin page at
base-url/Magento_Admin_URI
. Use your actualbase-url
and the Magento Admin URI from the installation. When you access this page, Magento prompts you to log in with theadmin-user
name andadmin-password
you provided during installation.A successful login takes you to the Magento Admin page. This page serves as the storefront dashboard.
Note Magento enables two-factor authentication for the Magento Admin page by default. When you first try to access the Magento Admin page, the application sends an email to your
admin-email
address telling you how to set this up. In the interest of efficiency, you can turn this off during development. To disable two-factor authentication, run the following commands from the Magento root directory:sudo bin/magento module:disable Magento_TwoFactorAuth sudo bin/magento cache:flush
We recommend you take another backup checkpoint at this time before proceeding to further Magento configuration.
Lockdown Permissions after Installation
After you have installed Magento and no longer want to make any more basic changes, it is important to restrict certain permissions to keep your site more secure.
Enter the Magento root directory and set the following permissions:
sudo find app/etc -type f -exec chmod g-w {} \; sudo find app/etc -type d -exec chmod g-ws {} \;
When you are ready to place your server into production, navigate to your Magento root directory and place Magento into production mode. Consult the Magento mode info page for a more complete explanation of the various modes.
bin/magento deploy:mode:set production
Remove write access from other sensitive directories:
find app/code lib var generated vendor pub/static pub/media app/etc \( -type d -or -type f \) -exec chmod g+w {} + && chmod o+rwx app/etc/env.php
Setting X-Frame Options
We recommend you disable the ability to display your storefront within a frame to prevent clickjacking attempts. Modify the following setting in the /var/www/html/example.com/public_html/app/etc/env.php
file, replacing example.com in the file path with your own domain:
- File: /var/www/html/example.com/public_html/app/etc/env.php
1
'x-frame-options' => 'DENY',
SSL Certificates
SSL certificates encrypt and verify sensitive financial and sales data. You should use them when setting up your storefront. A self-signed certificate (as discussed earlier) is sufficient to complete the Magento installation. However, your site requires a commercially-signed certificate in order to interact with most payment processors and to avoid warning messages when customers navigate to your site. More information is available in the Linode guides to obtaining a commercially signed SSL certificate and using SSL certificates with Apache.
The SSL and the HTTPS protocols are enabled on the Magento Admin page.
Log in to your Magento Admin page with the URL you used during the verification stage earlier.
Click Stores in the sidebar and then Configuration option under the Settings submenu.
Click on the Web option under the General submenu.
Expand the Base URLs (Secure) selection to display a number of text fields. Modify Secure Base URL from
http://
tohttps://
in order to use the HTTPS protocol.Save your configuration and then reload your storefront. Your browser now displays a lock icon near the URL (provided you are using a commercially-signed certificate).
Finishing Up
You are now ready and able to begin setting up your store and adding product data.
You can optimise your Magento installation through the addition of other third-party components, including Varnish, Redis, and RabbitMQ. Information about these extensions can be found on the Magento development site.
In order to keep your site up-to-date and more secure, consult the Magento site on a regular basis to look for updates and patches.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on