Linux CentOS - letronghieu4897/magento GitHub Wiki
- 1.Change user
- 2.Multiple site
- 3.Command support
- 4.Patch Security Upgrade Version
- 5.Multiple PHP version
- 6.Upgrade Magento 1 Version
- 7.Setup Server Staging
- 8.Upgrade php7 for magento 1
- 9.Deploy on server
- 10.Base URL
- 11.Build site on other server (Holteindustri)
- 12.Setup network manual
- 13.Setup Database MYSQL on Local
- 14.Php log
- 15.Searching word all files
- 16.Gulp error
- 17.Deploy Production
- 18.Alias for command line
- 19.Upgrade Magento 2
- 20.Multiple node version
- 21.Move server
- 22.Create file test.php on server
- 23.Set new webstore magento 1 multiple store url
- 24.Setup Magento 1 source project
- 25.Set color for folder and file on command line
- 26.Setup SSL for Nginx
- 27.Setup multiple store view with multiple domain
-
chown -R [username].[groupname] /[path] : chown -R hieunetpower.hieunetpower /var/www/
-
Mode to nginx user : su -s /bin/bash nginx
- create file in : /etc/nginx/sites-enabled/[name].conf
server {
listen 80;
server_name scanholm.local www.scanholm.local;
set $MAGE_ROOT /var/www/scanholm; [path of source]
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE website;
include /var/www/scanholm/nginx.conf.sample;
}
- setup env.php : app/code/etc
Copy from env.php.local
- setup upgrade
- enable cache
- setup config.php : app/code/etc
Copy from config.php.sample
1. Find in folder
$ grep -rn "Word_to_need_find" [Folder]/
. _______________________________________________________________________
├── app
| ├── etc
│ │ ├── local.xml --------------- [Create new file]
│ │ └── local.xml.staging ------- [Copy and Paste to local.xml]
| └── Mage.php --------------------- [Check version patch security]
├── var
| └── cache ------------------------ [Clean cache]
._________________________________________________________________________
1. Download newest version patch security
2. app > etc > local.xml.staging [Copy]
3. [Paste] Create new file local.xml in etc.
4. Check version of Patch Security : Go to file Mage.php
5. Copy file patch downloaded to root of source.
6. Run sh [file].sh
7. Delete folder cache : Clear cache
8. Testing Code : Show diff
9. Testing Page : Order, Payment, Login, ...
Mage.php
PATCH IN HERE : 1901--
public static function getVersionInfo()
{
return array(
'major' => '1',
'minor' => '9',
'revision' => '0',
'patch' => '1',
'stability' => '',
'number' => '',
);
}
1. Download composer.phar : https://getcomposer.org/composer.phar
2. php72 composer.phar install = composer install (In single php version) **[composer = php composer.phar]**
3. Run php
- php72 setup upgrade (On php 7.2) ; php setup:upgrade (On php 7.0)
- php72 setup:di:compile
...
yum install httpd -y
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils -y
yum install php56 -y
yum install php70 -y
yum install php71 -y
yum install php72 -y
yum install php56-php-fpm -y
yum install php70-php-fpm -y
yum install php71-php-fpm -y
yum install php72-php-fpm -y
1. find /etc/ -name "www.conf" // Finding file www.conf of php version
=> /opt/remi/php56/root/etc/php-fpm.d/www.conf
=> /etc/opt/remi/php70/php-fpm.d/www.conf
=> /etc/opt/remi/php71/php-fpm.d/www.conf
=> /etc/opt/remi/php72/php-fpm.d/www.conf
2. Change port of listen for each www.conf
php70 composer.phar install
php71 composer.phar install
php72 composer.phar install
1. Clone file **local.xml** similar Upgrade Patch Security.
2. Go to Admin site saving Theme to load css. : system/configuration/theme
3. Download Magento version that you want to upgrade.
4. Copy all folder downloaded above Paste into Source.
5. Check code.
6. Change email sender on :
- system/configuration/Store email addresses
- system/configuration/general/contact
7. Change email in SMTP pro : [email protected] - webPower2010
8. Go to : system/Configuration/Payment methods/Klarna
- Eid : 3568
- Shared secret : Bg7YmXRmAHkxzd8
- Server : Testdrive
9. Go to system > configuration > google API : Create google API and add key
10. Test on site.
11. If login -> redirect to login page [Duplicate cookie problem]
- System > Configuration -> Cookie -> Cookie Domain : Add subdomain
EXAMPLE : makestyle.no.staging.netpower.cloud
- Clear cookies and Login -> OK
12. If block doesn't exist on page.
- Check permission : system > permission > block
- Check page : CMS > page
EXAMPLE : Bridgestone
1. Create source folder : /var/www/html/bridgestone/public_html
2. cd /var/www/html/bridgestone git clone ... public_html
3. Create Database
* mysql -u netpower -p
* CREATE DATABASE bridgestone;
4. Export database on http://sql.vn-php.netpower.lan to file SQL
5. Use WinSCP to connect to server and copy file SQL to this place
[Or we can use (6. Get file from server to local) in section 8.Upgrade php version]
6. Import sql
* mysql -u netpower -p 'bridgestone' < 'file_database'.sql
7. Go to root folder : php composer.phar install
8. If composer fail : Remove composer.lock and then php composer.phar install
9. vim /etc/nginx/site_enabled/bridgestone.conf
10. php bin/magento module:enable --all
11. php bin/magento setup:upgrade
12. php bin/magento deploy:mode:set developer
13. php bin/magento setup:store-config:set --base-url ='http://bridgestone.staging.netpower.cloud/'
14. change fastcgi_pass : 127.0.0.1:9002 [nginx.conf] on root folder
15. change include in /etc/nginx/site-enabled/bridgestone.conf : nginx.conf.example -> nginx.conf [else don't change]
16. Restart nginx : systemctl restart nginx
17. Copy folder media in /pub/media from local -> to server
bridgestone.conf
server {
listen 80;
server_name <domain>;
access_log /var/www/html/bridgestone/logs/access.log;
error_log /var/www/html/bridgestone/logs/error.log error;
set $MAGE_ROOT /var/www/html/bridgestone/public_html;
include /var/www/html/bridgestone/public_html/nginx.conf;
}
FLOW NGINX : Example for makestyle [1, 2, 3]
1. /etc/nginx/site-enabled/makestyle.conf
2. <MAGE_ROOT>/public_html/nginx.sample.conf
3. /etc/php/7.2/fpm/pool.d/www.conf
SETUP SITE :
4. Connect to server with host, user and password get in LastPast Extention.
5. After connect, We dump Database.
6. Go to local site get file sql dumped from server.
7. Create Database and import file sql above.
8. Go to /app/etc/ cp local.xml.<environment> local.xml
9. Change url in database. Table core_config_table
makestyle.conf
server {
listen 80;
server_name makestyle.no.staging.netpower.cloud;
access_log /var/www/html/makestyle/logs/access.log;
error_log /var/www/html/makestyle/logs/error.log error;
set $MAGE_ROOT /var/www/html/makestyle/public_html;
root /var/www/html/makestyle/public_html;
include /var/www/html/makestyle/public_html/nginx.conf.sample;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/lillemaja.no.staging.netpower.cloud/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/lillemaja.no.staging.netpower.cloud/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
Then, include /var/www/html/makestyle/public_html/nginx.conf.sample;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass 127.0.0.1:9002;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
# fastcgi_param MAGE_RUN_TYPE store;
fastcgi_read_timeout 300;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
nginx.conf.sample : To config nginx variable environment for Magento
...
...
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = /run/php/php7.2-fpm.sock
listen = 127.0.0.1:9002
...
...
TO CHECK PORT LISTEN OF PHP 7.2
1. Go to folder private
2. $ History | grep "mysqldump" : To check history with command dump database
3. Put Name is name_yyyy_mm_dd.sql : $ mysqldump -u makestylepro -p makestylepro > makestylepro_2019_01_04.sql [Get information of database in LastPass extension].
$ scp <your_username>@<removehost.com> : <path/file.sql> <folder container>
$ scp [email protected].....:/var/www/file.sql ./
1. $ mysql -u <username> -p
2. $ SHOW DATABASES;
3. $ CREATE DATABASE <name>;
4. $ mysql -u <username> -p <new_database> < <data-dump>.sql
MAGENTO 1
fix connection information
host
username
password
database
base url
admin = desktop
WAY 1 :
- Use HeidiSQL to change url in core_config_table
WAY 2 :
- Command line
$ mysql -u netpower -p
$ use <database name>;
$ use <table name>;
$ select * from core_config_table where %base_url% limit 5; [NOT EXACTLY]
$ update url.
- Clear Cache : rm -rf var/cache/*
$ php bin/magento maintenance:enable --ip= <server-ip>
$ git pull origin master
$ php bin/magento setup:upgrade
$ php bin/magento setup:di:compile
$ php bin/magento setup:static-content:deploy nb_NO en_US
$ php bin/flushFpm [I haven't use it yet]
$ php bin/magento maintenance:disable
- We can create deploy.sh and add codes above inside it.
- And then run : sh deploy.sh
$ php bin/magento setup:store-config:set --base-url="http://localhost:8080/"
$ php bin/magento setup:store-config:set --base-url-secure="https://localhost:8080/"
$ php bin/magento cache:flush
1. Dump database from staging (or Production)
2. Import database into new server
3. Download media folder (in /pub/media)
4. Import into new server
5.
6.
7.
8.
$ mysqldump -u [user_name_database] -p [database_name] > ProjectName_yyyy_mm_dd.sql
Go to new server
GET file from other server.
$ scp [user_name]@[host_name]:[path/to/file/ProjectName_yyyy_mm_dd.sql] [path/to/folder/you/want/to/save]
OR
use WinSCP to get file and push file.
IN NEW SERVER
$ mysql -u [user_name_database] -p [database_name] < ProjectName_yyyy_mm_dd.sql
Open WinSCP to Connect to Staging (or Production) to
GET media.
- Go to /Project_Name/pub/media : Download this folder
- Copy folder into /pub/media on server
USE TOOL nmtui
=======================================================================================
$ nmtui : Active network
$ sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33 : ONBOOT=yes
$ nmcli d show : To show information network when automation.
$ nmtui : Config the same DNS and Gateway in above information.
=======================================================================================
By handle
=======================================================================================
$ sudo vim sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33
ADD DNS , GATEWAY and IP
EXAMPLE
IPADDR=172.16.112.150
PREFIX=16
GATEWAY=172.16.112.2
DNS1=172.16.112.2
$ sudo vim /etc/resolv.conf
nameserver 172.16.112.2 : DNS server above
====================================================================================================
- $ wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
- $ yum -y localinstall mysql57-community-release-el7-7.noarch.rpm
IF your server is having other mysql community cause conflic.
RUN
$ yum list installed | grep mysql : TO show list <name>, remove all list.
$ sudo yum remove <name>
- $ yum -y install mysql-community-server
- $ service mysqld start
- $ mysql --version
- $ grep 'temporary password' /var/log/mysqld.log : Check password default of Root
- $ mysql -u root -p : Login into mysql by Root password got above.
- mysql> SHOW VARIABLES LIKE 'validate_password%';
- mysql> SET GLOBAL <name column>= <value> : Change value you want apply.
EXAMPLE
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
mysql> SET GLOBAL validate_password_length = 4;
mysql> SET GLOBAL validate_password_special_char_count = 0;
mysql> SET GLOBAL validate_password_policy = 0;
- $ mysql_secure_installation : Change password of Root default.
- $ mysql -u root -p
<password>
- mysql> CREATE USER '<USER>'@'localhost' IDENTIFIED BY 'password';
- mysql> CREATE DATABASE <name>; (Not qoute)
- mysql> GRANT ALL PRIVILEGES ON <database>.<table> TO '<USER>'@'localhost';
GRANT ALL PRIVILEGES ON hieu.* TO '<USER>'@'localhost';
- mysql> exit;
- DUMP DATABASE YOU NEED AND PASTE FILE INTO SERVER.
Go to folder contain file .sql you dumpped
- IF you DUMP on server
- $ mysqldump -u username -p database_name > data-dump.sql
EXAMPLE
$ mysqldump -u hieu -p hieu > Magento_CE_2_Hieu_Training.sql
- AND IMPORT
- $ mysql -u username -p new_database < data-dump.sql
EXAMPLE
$ mysql -u hieu -p hieu < Magento_CE_2_Hieu_Training.sql
DONE
====================================================================================================
1. $ sudo vim /etc/opt/remi/php72/php-fpm.d/www.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CHANGE php_admin_value[error_log] = /var/log/nginx/error.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ grep -rn "class = \"hello\-world\-test\"";
=
finding text : class = "hello-world-test"
$ npm install gulp
$ npm install node-sass
$ git pull
$ rm -rf var/cache
Helseklubben : SSH
Olivier : ServerBolt
1. Add alias bash file into main file
$ vim ~/.bashrc
#### add ####
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
2. reload file :
$ source ~/.bashrc
3. Create bash_aliases file
$ vim ~/.bash_aliases
4. Add alias for bash_aliases file
#### add ####
# MAGENTO PHP72 SETUP UPGRADE
alias setu='php72 bin/magento setup:upgrade'
# MAGENTO PHP72 SETUP DI COMPILE
alias sedi='php72 bin/magento setup:di:compile'
# MAGENTO PHP72 CLEAN CACHE
alias cacl='php72 bin/magento cache:clean'
# MAGENTO PHP72 CLEAN CACHE FULL PAGE LAYOUT
alias cafl='php72 bin/magento cache:clean full_page layout'
# MAGENTO PHP72 REINDEX
alias rein='php72 bin/magento indexer:reindex'
# MAGENTO PHP72 SHOW MODE
alias desh='php72 bin/magento deploy:mode:show'
# MAGENTO PHP72 SET MODE
alias dede='php72 bin/magento deploy:mode:set developer'
# CLEAR
alias c='clear'
5. Reload file : source ~/.bash_aliases
1. Backup store
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2. Turn on maintain mode
$ php bin/magento maintenance:enable
*NOTE : It will create a new file var/.maintenance.flag. If you cannot disable maintenance mode, you can remove this file [Remmember!]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3. Upgrade magento version [Example magento version 2.3.2]
$ composer require magento/product-community-edition 2.3.2 --no-update
$ composer update
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4. Clear cache
$ rm -rf var/cache/*
$ rm -rf var/page_cache/*
$ rm -rf var/generation/*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5. Upgrade, Di compile and Reindex
$ php bin/magento setup:upgrade
$ php bin/magento setup:di:compile
$ php bin/magento indexer:reindex
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6. Disable maintain mode
$ php bin/magento maintenance:disable
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7. Check version
$ php bin/magento --version
$ chmod -R 777 pub var
IF (Cannot access to frontend after upgrading?)
$ find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; && chmod u+x bin/magento
and then clear cache on step [4]
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
~/.nvm directory and adds the following source line to your profile: (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ source ~/.bashrc
$ command -v nvm
nvm
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// nvm ls-remote : Check all version of Node
nvm install v11.14.0 //Install specific node version
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nvm use v11.14.0 // Choose specific node to use
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EXAMPLE : Figgjo Servebolt
1. Backup Database from old server and import for new server (45m)
2. Change Domain (Test)
--- Fix file local.xml (Don't forget add secure and unsecure url)
--- Fix on Database (Table core_config_data) Search Path (%base%url) and update all to new url
--- Compress media folder
If media folder is too large
------ [1] (Remove media/catalog/product/cache/*)
------ [2] remove media/js
------ [3] Backup /media/tmp -> compress tar -xzvf tmp.tar.gz /tmp => Move it to /tmp folder (mv tmp.tar.gz /tmp) and remove /tmp
------ [4] Clone to new server.
ERROR layout : --- go to admin System > Configuration > Developer > JavaScript Setting > Disable Merge JS
3. Set HTTPS (Certificate SSL)
[1].Download Certificate (See path in /etc/apache2/site-enables/figgjo.no.conf)
SSLCertificateFile ...
Include 3 files
___.chain.crt
___.crt
___.key
[2]. Go to serveBolt -> Create new SSL -> Copy all contents of 3 files to input box to create SSL.
[3]. Next step is in ___.chain.crt is having 3 certificate with BEGIN --- END
[2 Input box]
1 -> root (Check order server to watch which is Certificate for root)
2 -> below root
4. Turn on maintenant mode Magento 1 (Note : Only turn on maintenant mode when prepared all data need to start)
[1]. Go to source root
[2]. vim index.php
[3]. Change | Add $maintenanceFile = 'maintenance.flag';
[4]. Add
--- $ip = $_SERVER['REMOTE_ADDR'];
--- $allowed = array('45.122.245.2');
[5]. Change if (file_exists($maintenanceFile)) { => if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
[6]. $ touch maintenance.flag
// Enable Maintenance mode
[7]. Disable : rm maintenance.flag
// Disable Maintenance mode
5. Change Domain Name
[1]. Database table : core_config_data (Search column path : %base%url%) and edit url
[2]. Redirect multi url to one site (Fix file .htaccess)
[3]. Testing site
I. Migrate
Before migration, we should set maintenance mode on both server
1.Move source code
pull from GIT
2. Move database
Backup database
Copy into new server
Restore database
3. Move files
Backup image folder /media (ignore media/catalog/product/cache)
Backup var folder /var (ignore var/log & var/cache)
Move into new server
Extract zip file into correct location
II. Regression Test:
1. Customer function:
register account
login
logout
2. Checkout function:
place order
invoice/ship/cancel
3. Email function:
register account
reset password
place order
Mailgun integration
4. Frontside:
Layout
Color
6. Multiple browser or private mode testing:
Make regression test above step with multiple browser (Firefox / Chrome) and private mode.
5. Outside Netpower should be accessed
6.Other function will be long to project
1. Create test.php in /pub
2. Fix file nginx.conf
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$
add file name in here example for test.php
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check|test)\.php$
EXAMPLE for Byraservice : https://bat.webshop.byraservice.no
1. Create new webstore and get webstore CODE (System > Manage stores)
2. .htaccess
SetEnvIf Host .*bat\.* MAGE_RUN_CODE=bat
SetEnvIf Host .*bat\.* MAGE_RUN_TYPE=website
3. location.nginx.conf
if ($host ~* ^(www.)?bat\.(.*)$) {
set $MAGE_RUN_CODE bat;
set $MAGE_RUN_TYPE website;
}
4. systemctl reload nginx
1. Copy file local.xml.local => local.xml
2. Set vhost for xampp
3. Set host on host file
4. copy .htaccess
5. Restart xampp
$ vim ~/.bashrc
export LS_OPTIONS='--color=auto'
eval "$(dircolors -b)"
alias ls='ls $LS_OPTIONS'
source ~/.bashrc
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/certs/hieu.local.key -out /etc/ssl/certs/hieu.local.crt
sudo vim /etc/nginx/conf.d/hieu.local.conf
server {
listen 80;
listen 443;
server_name www.elby.local elby.local;
set $MAGE_ROOT /usr/share/nginx/html/elby;
include /usr/share/nginx/html/elby/nginx.conf;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_certificate /etc/ssl/certs/hieu.local.crt;
ssl_certificate_key /etc/ssl/certs/hieu.local.key;
}
1. CREATE STORE VIEW ON ADMIN
- Stores > All Stores > Create new storeview
- Set Code for storeview
2. CONFIG DOMAIN FOR STORE VIEW
- Change storeview
- Stores > Configuration > General > Web
- Set Base URL and Base Secure URL
3. CONFIG nginx.conf
# PHP entry point for main application
location ~ (index|get|static|report|404|503|health_check)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# START - Multisite customization
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
# END - Multisite customization
include fastcgi_params;
}
4. CONFIG FILE .conf OF SITE
map $http_host $MAGE_RUN_CODE {
default '';
french.mysite.mg french; #french | german are storeview Code
german.mysite.mg german;
}
server {
listen 80;
server_name mysite.mg french.mysite.mg german.mysite.mg;
set $MAGE_ROOT /var/www/html/magento2;
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE store; #or set $MAGE_RUN_TYPE store;
include /var/www/html/magento2/nginx.conf;
}
5. ADD HOSTS
.htaccess
SetEnvIf Host .*lenspower.dk\.* MAGE_RUN_CODE=danish
SetEnvIf Host .*lenspower.dk\.* MAGE_RUN_TYPE=website
SetEnvIf Host .*lenspower.se\.* MAGE_RUN_CODE=swedish
SetEnvIf Host .*lenspower.se\.* MAGE_RUN_TYPE=website
SetEnvIf Host .*lenspower.fi\.* MAGE_RUN_CODE=finnish
SetEnvIf Host .*lenspower.fi\.* MAGE_RUN_TYPE=website