Magento를 설치 하는 방법 2 with Varnish, Apache and Pound as SSL Termination

 

 

이 문서에서는, we will show you how to install Magento 2 에 우분투 16.04 VPS with MariaDB, Varnish as a full page cache, Apache and Pound as SSL termination. 이 가이드는 다른에서 작동 한다 Linux VPS systems as well but was tested and written for an Ubuntu 16.04 VPS.

우리가 시작 하기 전에, you may want a different setup for your Magento. 당신은 따를 수 있다 이 자습서 to install Magento 2 우분투에서 16.04 MariaDB와 VPS, PHP FPM 7.0, Varnish as a full page cache, Nginx as SSL termination and Redis for session storage and page caching.

Or you can check out 이 자습서 to install Magento 2 에 우분투 16.04 VPS with MariaDB, Varnish as a full page cache, Apache and Memcache for session storage.

If you have any different requirements, 그냥 get a Linux VPS from us and we’ll set everything up for you, 무료.

1. Login and update your server

우선, you need to login to your Ubuntu 16.04 VPS via SSH 사용자 루트:

ssh [이메일 보호]_IP_address

It is also recommended to start a screen session by executing the following command

screen -U -S magento

업데이트 시스템 and install necessary packages with:

-업데이트 && apt-get -y upgrade
apt-get -y install curl nano git

It is crucial that you always keep your server up to date. You can even 자동 업데이트를 사용 하도록 설정 in order to achieve this.

2. Install and configure MariaDB

Install the latest MariaDB 10.0 server from the official Ubuntu repositories:

apt-get은-y mariadb-서버 설치

다음, we need to create a database for our Magento installation.

mysql-u 루트-p
MariaDB [(없음)]> CREATE DATABASE magento;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON magento.* TO 'magento'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> q

Do not forget to replace ‘strong_password’ with an actual strong password. You can even generate a strong password from the command line.

3. Install Apache2 web server

apt-get은 설치 apache2

4. PHP와 필요한 PHP 모듈 설치

PHP 버전의 최신 안정 버전을 설치 하려면 7 그리고 모든 필요한 모듈, 실행:

apt-get install php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xsl php-imagick php7.0-gd php7.0-cli php-pear php7.0-intl

Change few default PHP settings:

sed -i "s/memory_limit = .*/memory_limit = 256M/" /etc/php/7.0/cli/php.ini
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 128M/" /etc/php/7.0/cli/php.ini
sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/7.0/cli/php.ini
sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/7.0/cli/php.ini

Enable the Apache2 rewrite module if it is not already done:

a2enmod 재작성

In order to activate the new configuration, restart the Apache web server using the following command:

apache2 서비스를 다시 시작

5. 작곡가 설치

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

6. Magento 설치 2 Github에서

Clone the Magento repository to the ~/myMagentoSite.com directory using the following command:

git clone https://github.com/magento/magento2.git /var/www/myMagentoSite.com

Get the latest Magento 2 stable release:

cd /var/www/myMagentoSite.com
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))

Run composer to install all Magento dependencies:

작곡가 설치

To continue with the installation you can either use the installation wizard or the command line, in this guide we will use the latter.

bin/magento setup:install 
--base-url=http://myMagentoSite.com/ 
--db-host=localhost 
--db-name=magento 
--db-user=magento 
--db-password=strong_password 
--admin-firstname=First  
--admin-lastname=Last 
[이메일 보호] 
--admin-user=admin 
--admin-password=strong_password123 
--language=en_US 
--currency=USD 
--timezone=America/Chicago 
--use-rewrites=1

If the installation is successful you will see something like below:

[성공]: Magento 설치 완료.
[SUCCESS]: Magento Admin URI: /admin_1m0ezr

실행은 crontab command to create a cronjob

crontab-u www-데이터-e

and add the following line:

* * * * * /usr/bin/php /var/www/myMagentoSite.com/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/myMagentoSite.com/var/log/magento.cron.log

마지막으로, set the correct permissions:

chown -R www-data: /var/www/myMagentoSite.com

7. 아파치 구성

아파치에 새로운 가상 호스트 지시문을 만듭니다. 예를 들어, you can create a new Apache configuration file named ‘magento.conf’ on your server:

touch /etc/apache2/sites-available/magento.conf
ln -s /etc/apache2/sites-available/magento.conf /etc/apache2/sites-enabled/magento.conf
nano /etc/apache2/sites-available/magento.conf

다음, 다음 줄을 추가:

<VirtualHost *: 80>
ServerAdmin [이메일 보호]
DocumentRoot /var/www/myMagentoSite.com/
ServerName myMagentoSite.com
ServerAlias www.myMagentoSite.com
<Directory /var/www/myMagentoSite.com/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</디렉터리>
ErrorLog /var/log/apache2/myMagentoSite.com-error_log
CustomLog /var/log/apache2/myMagentoSite.com-access_log common
</VirtualHost>

적용 하는 변경에 대 한 아파치 웹 서버를 다시 시작:

apache2 서비스를 다시 시작

You should be now able to login to your Magento back-end by going to http://myMagentoSite.com/admin_1m0ezr using the information you set when running the bin/magento setup:install.

8. Install and configure Varnish

To install Varnish, simply run the following command:

apt-get install varnish

From you Magento Admin dashboard click on the STORES link (left sidebar) -> 구성-> ADVANCED -> 시스템-> Full Page Cache

Uncheck “Use system value” and from the Caching Application list, select Varnish Cache (Recommended), save the configuration, click on the Varnish Configuration link and click on the Export VCL for Varnish 4 버튼. 는 varnish.vcl file which we will use will be exported in the /var/www/myMagentoSite.com/var/ 디렉터리.

Flush the Magento cache with:

php bin/magento cache:flush

Delete the /etc/varnish/default.vcl and symlink it to the exported varnish configuration.

rm -f /etc/varnish/default.vcl
ln -sf /var/www/myMagentoSite.com/var/varnish.vcl /etc/varnish/default.vcl

To change varnish port from 6081 받는 사람 80, we need to edit the systemd service configuration.

새 만들기 customexec.conf 파일

mkdir -p /etc/systemd/system/varnish.service.d
nano /etc/systemd/system/varnish.service.d/customexec.conf

다음 붙여 넣습니다.

[Service]
ExecStart=
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m

and reload systemd units

systemctl 데몬-다시 로드

Now we need to change Apache listening port from 80 받는 사람 8080. 그렇게 하려면, open the Apache ports configuration file and change it as follows:

nano /etc/apache2/ports.conf

Listen 80 -> 들어 봐 8080
nano /etc/apache2/sites-available/magento.conf

<VirtualHost *: 80> -> <VirtualHost *: 8080>

If everything is setup correctly now you should be able to login to your Magento back-end by going to https://myMagentoSite.com/admin_1m0ezr.

어딘가에 붙어? VPS를 얻을 우리와 우리가 당신을 위해이 모든 것을 할 거 야, free of charge!

9. Install and configure Pound as SSL termination

Varnish doesn’t support SSL traffic, so you will need to install a proxy or load balancer like Pound to handle the SSL traffic. 이렇게 하려면, we will configure Pound to only listen on port 443 and pass the traffic to Varnish on port 80.

첫 번째, let’s install Pound with:

apt-get install pound

Open the Pound configuration file:

nano /etc/pound/pound.cfg

그리고 다음 설정:

ListenHTTPS
    Address 1.2.3.4 ## this should be your server public IP address
    Port 443
    Cert "/etc/apache2/ssl/myMagentoSite.com.pem" ## path to your SSL certificate
    HeadRemove "X-Forwarded-Proto"
    AddHeader "X-Forwarded-Proto: https"
    Service
        BackEnd
            Address 127.0.0.1
            포트 80
        End
    End
End

After you are done, restart your Apache and Varnish, and Pound:

service apache2 restart
service varnish restart
service pound restart

10. Further Optimizations

To further optimize your Magento installation from your Magento admin dashboard:

1. Go to STORES -> 구성-> CATALOG -> Catalog -> Use Flat Catalog Category, select Yes and click Save Config.
2. Go to STORES -> 구성-> ADVANCED -> Developer -> JavaScript Settings and set both Merge JavaScript Files and Minify JavaScript Files to Yes and click Save Config..
3. Go to STORES -> 구성-> ADVANCED -> Developer -> CSS Settings and set both Merge CSS Files and Minify CSS Files to Yes and click Save Config.
4. Consider using a CDN – Content Delivery Network

Do not forget to flush the cache again:

php bin/magento cache:flush

You can also follow our guide on how to speed up Magento.

그거에요. You have successfully installed Magento 2 with Memcache as a session storage and page caching, Varnish as a full page caching and Apache on your Ubuntu 16.04 VPS and you have set up Pound as SSL termination. For more information about how to manage your Magento installation, 관리를 참조 하십시오 Magento 설명서.

소스

답을 남겨주세요