Sie sind auf Seite 1von 7

Install Magento 2 on Linode VPS

Install LAMP environment and configure them.


1. Install Apache 2 on Ubuntu LTS 16.04
- Before installing Apache 2, we need to check for and install all system updates with this command :
sudo apt-get update && sudo apt-get upgrade

- After that we will install Apache 2 with this command: sudo apt-get install apache2

- Edit the main Apache configuration file, apache2.conf, to adjust the KeepAlive setting: file:
/etc/apache2/apache2.conf
KeepAlive Off

- The default multi-processing module (MPM) for Apache is the event module but by default PHP uses
the prefork module.

Open the mpm_prefork.conf file located in /etc/apache2/mods-available and edit the configuration.

Below are the suggested values for a 2GB Linode: file: /etc/apache2/mods-
available/mpm_prefork.conf
<IfModule mpm_prefork_module>

StartServers 4

MinSpareServers 20

MaxSpareServers 40

MaxRequestWorkers 200

MaxConnectionsPerChild 4500

</IfModule>

- Disable the event module and enable prefork, rewrite:


sudo a2dismod mpm_event

sudo a2enmod mpm_prefork

sudo a2enmod rewrite

- Restart Apache:
sudo systemctl restart apache2

2. Configure Virtual Hosts


- Create a copy of the default Apache configuration file for your site (We will create marumagento.dev
file):
sudo cp /etc/apache2/sites-available/000-default.conf/etc/apache2/sites-
available/marumagento.dev.conf

- Edit the new marumagento.dev.conf configuration file by uncommenting ServerName and replacing
example.com with your sites IP or Fully Qualified Domain Name (FQDN).

Enter the document root path and log directories as shown below, and add a Directory block before
</VirtualHost>: File /etc/apache2/sites-available/marumagento.dev.conf
<Directory /var/www/html/marumagento.dev/public_html>

Options Indexes FollowSymLinks MultiViews

AllowOverride <value from Apache site>

Order allow,deny

Allow from all

</Directory>

<VirtualHost *:80>

ServerName example.com

ServerAlias www.marumagento.dev

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html/marumagento.dev/public_html

ErrorLog /var/www/html/marumagento.dev/logs/error.log

CustomLog /var/www/html/marumagento.dev/logs/access.log combined

</VirtualHost>

- Create the directories referenced above:


sudo mkdir -p /var/www/html/marumagento.dev/{public_html,logs}

- Link your virtual host file from the sites-available directory to the sites-enabled directory:
sudo a2ensite marumagento.com.conf

- Disable the default virtual host to minimize security risks:


sudo a2dissite 000-default.conf

- Reload Apache:
sudo systemctl reload apache2
3. Install MySQL
- Install the mysql-server package and choose a secure password when prompted:
sudo apt-get install mysql-server

- Create a MySQL database:

Log into MySQL: mysql -u root -p . Enter MySQL's root password, and you'll be presented with a
MySQL prompt.

If no password was entered in the previous section, or if you want to change the root password, enter
the following command.

Replace password with a new root password:


ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY
'password';

Create a database and a user with permissions for it. In this example, the database is called
marumagento, the user webuser, and password password:
CREATE DATABASE marumagento;

GRANT ALL ON marumagento.* TO 'webuser' IDENTIFIED BY 'password';

Exit MySQL: quit

4. Install PHP 7.0


- Install PHP, the PHP Extension and Application Repository, Apache support, and MySQL support:
sudo apt-get install php7.0 php-pear git libapache2-mod-php7.0 php7.0-
mysql php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-intl php7.0-zip

- Optionally, install additional cURL, JSON, and CGI support:


sudo apt-get install php7.0-curl php7.0-json php7.0-cgi

- Once PHP7.0 is installed, edit the configuration file located in /etc/php/7.0/apache2/php.ini to


enable more descriptive errors, logging, and better performance.

The following modifications provide a good starting point:

File excerpt: /etc/php/7.0/apache2/php.ini


max_input_time = 30

error_reporting = E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR |


E_CORE_ERROR

error_log = /var/log/php/error.log

- Create the log directory for PHP and give ownership to the Apache system user:
sudo mkdir /var/log/php
sudo chown www-data /var/log/php

- Restart Apache:
sudo systemctl restart apache2

Install Magento 2
1. Install composer
- At first, we need to download composer, we will run these command:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('SHA384', 'composer-setup.php') ===


'61069fe8c6436a4468d0371454cf38a812e451a14ab1691543f25a9627b97ff96d8753d92a00
654c21e2212a5ae1ff36') { echo 'Installer verified'; } else { echo 'Installer
corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

- Install composer globally:


sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

- Test composer with command: composer

2. Download Magento 2 with composer


- Get the Magento software
cd <web server docroot directory>

composer create-project --repository-url=https://repo.magento.com/


magento/project-community-edition magento2

- Youre required to authenticate; see http://devdocs.magento.com/guides/v2.0/install-


gde/prereq/connect-auth.html.

This downloads Magento code only; it doesnt install the software for you.

3. Set pre-installation file system ownership and permissions


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.

In this case, we will set ownership and permissions for two users

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

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

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

passwd <username>

Step 2: Find the web server users group

To find the web server users group:

CentOS: egrep -i '^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 user name and the group name are both www-data

Step 3: Put the Magento file system owner in the web servers group

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

CentOS: usermod -g apache <username>


Ubuntu: usermod -g www-data <username>

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

usermod -g apache magento_user

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

groups <user name>

A sample result follows:

magento_user : apache

To complete the task, restart the web server:

Ubuntu: service apache2 restart


CentOS: service httpd restart

Step 5: Set ownership and permissions for the shared group

To set ownership and permissions before you install the Magento software:
Log in to your Magento server as, or switch to, the Magento file system owner.

Enter the following commands in the order shown:

cd <your Magento install dir>

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 :<web server group> .

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:

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 cant be changed by the Magento file system
owner, you can enter the command as a user with root privileges:

cd /var/www/html/magento2 && sudo find var vendor pub/static pub/media


app/etc -type f -exec

4. Setup Magento 2 with Magento 2 command line


Switch to the Magento file system owner

After youve 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,
su magento_user

Command line installation

Click to view the command-line installation

The following example shows how to install using the command line with the following options:

The Magento software is installed in the /var/www/html/magento2 directory, which means your
storefront URL is http://192.0.2.5/magento2/
The database server is on the same host as the web server.

The database name is magento, and the user name and password are both magento

Uses server rewrites

The Magento administrator has the following properties:

First and last name are Magento User

User name is admin and the password is admin123

E-mail address is user@example.com

Default language is en_US (U.S. English)

Default currency is U.S. dollars

Default time zone is U.S. Central (America/Chicago)


php /var/www/html/magento2/bin/magento setup:install --base-
url=http://192.0.2.5/magento2/ \

--db-host=localhost --db-name=magento --db-user=magento --db-


password=magento \

--admin-firstname=Magento --admin-lastname=User --admin-


email=user@example.com \

--admin-user=admin --admin-password=admin123 --language=en_US \

--currency=USD --timezone=America/Chicago --use-rewrites=1

Optionally switch to developer mode.


cd <your Magento install dir>/bin

php magento deploy:mode:set developer

You can reference with setup wizard at http://devdocs.magento.com/guides/v2.0/install-gde/install-


quick-ref.html#web-setup-wizard

Das könnte Ihnen auch gefallen