Did you know you can install Magento from command line instead of inserting all the values into the installer web interface?

Just extract the Magento source code into the document root of your webserver (or vhost).

You'll find the file install.php. Have a look into the file for a documentation on all available arguments. Basically you can pass all values as an argument that you would insert into the web interface while manually installing your Magento instance:

Arguments

General:
--license_agreement_accepted // required, it will accept 'yes' value only

Locale settings:
--locale                     // required, Locale
--timezone                   // required, Time Zone
--default_currency           // required, Default Currency

Database connection options:
--db_host                    // required, You can specify server port, ex.: localhost:3307
                             // If you are not using default UNIX socket, you can specify it
                             // here instead of host, ex.: /var/run/mysqld/mysqld.sock
--db_model                   // Database type (mysql4 by default)
--db_name                    // required, Database Name
--db_user                    // required, Database User Name
--db_pass                    // required, Database User Password
--db_prefix                  // optional, Database Tables Prefix
                             // No table prefix will be used if not specified

Session options:
--session_save <files|db>    // optional, where to store session data - in db or files. files by default

Web access options:
--admin_frontname <path>     // optional, admin panel path, "admin" by default
--url                        // required, URL the store is supposed to be available at
--skip_url_validation        // optional, skip validating base url during installation or not. No by default
--use_rewrites               // optional, Use Web Server (Apache) Rewrites,
                             // You could enable this option to use web server rewrites functionality for improved SEO
                             // Please make sure that mod_rewrite is enabled in Apache configuration
--use_secure                 // optional, Use Secure URLs (SSL)
                             // Enable this option only if you have SSL available.
--secure_base_url            // optional, Secure Base URL
                             // Provide a complete base URL for SSL connection.
                             // For example: https://www.mydomain.com/magento/
--use_secure_admin           // optional, Run admin interface with SSL

Backend interface options:
--enable_charts              // optional, Enables Charts on the backend's dashboard

Admin user personal information:
--admin_lastname             // required, admin user last name
--admin_firstname            // required, admin user first name
--admin_email                // required, admin user email

Admin user login information:
--admin_username             // required, admin user login
--admin_password             // required, admin user password

Encryption key:
--encryption_key             // optional, will be automatically generated and displayed on success, if not specified

Example

php -f install.php -- \
--license_agreement_accepted yes \
--locale en_US --timezone "America/Los_Angeles" --default_currency USD \
--db_host localhost --db_name magento_database --db_user magento_user --db_pass 123123 \
--db_prefix magento_ \
--url "http://magento.example.com/" --use_rewrites yes \
--use_secure yes --secure_base_url "https://magento.example.com/" --use_secure_admin yes \
--admin_lastname Owner --admin_firstname Store --admin_email "admin@example.com" \
--admin_username admin --admin_password 123123

Other command line tools

Magento also comes with some additional command line tools. One of them is the indexer.php. So simply run

cd shell && php -f indexer.php reindexall

and your Magento instance will be ready to use.

Btw, command line scripts can easily be implemented by inheriting class Mage_Shell_Abstract that can be found in abstract.php (in the same folder). This is great to trigger other tasks from command line. E.g. my Aoe_Scheduler module comes with a command line interface to run or to schedule tasks from command line.

Thanks, Christian!

Thanks, Christian Münch for pointing me to this!

He uses this feature to setup a complete server including a fresh Magento install using Puppet and Vagrant. Check out his demo project on GitHub.

Comments

This website uses disqus for the commenting functionality. In order to protect your privacy comments are disabled by default.

Enable Comments