- Linux and Web server setup under GCE
- MySQL
- Elasticsearch
- Magento installation
- Magento extension module installation
- CLI - Command line interface
- Reference
2vCPU
with8GB
memoryUbuntu 20.04 LTS
with200 GB
capacity
apt-get update
dpkg-reconfigure tzdata
apt-get install ntp
apt-get install unzip
apt-get -y install nginx
Uncomment the partial commands of the PHP section in /etc/nginx/sites-available/default
.
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
apt-get update
apt-get -y install php7.4-fpm php7.4-cli
apt-get install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap php7.4-bcmath
systemctl restart php7.4-fpm.service
systemctl restart nginx.service
- we have tested on
PHP v7.4.1/v7.4.3
. - /var/www/html/phpinfo.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
- open
http://${HOST}/phpinfo.php
with a browser
- MySQL
v8.0
- Character set
utf8mb4
- Collation
utf8mb4_0900_ai_ci
apt-get install mysql-client-core-8.0
mysql -h {mysql_server_host} -u ${username} -p --ssl-mode=DISABLED
--ssl-mode=DISABLED
stands for an unencrypted connection especially for the legacy versions..
create database magento;
create user 'magento'@'<remote web node server ip address> or %' IDENTIFIED BY 'magento';
GRANT ALL ON magento.* TO 'magento'@'<remote web node server ip address> or %';
flush privileges;
sudo apt-get update
sudo apt-get install openjdk-8-jdk
adduser elk
sudo su -l elk
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
tar -xvf elasticsearch-7.6.2-linux-x86_64.tar.gz
- Virtual memory
- elasticsearch.yaml
network.host: 0.0.0.0 discovery.seed_hosts: [] cluster.initial_master_nodes: []
Stores > Settings > Configuration > Catalog > Catalog > Catalog Search
Elasticsearch Server Hostname
Elasticsearch Server Port
Elasticsearch Index Prefix
sudo su -l elk
jps
// You should see the message below
${PID} Elasticsearch
Start ES demon if you haven't seen the process via the JPS command
sudo su -l elk
cd elasticsearch-7.6.2/
./bin/elasticsearch -d
# check ES alive
curl localhost:9200/_state
-
Add an user as magento file system owner
sudo adduser <magento_user> sudo mkdir -p /var/www/html/magento2 sudo chown -R <magento_user>:<magento_user> magento2
-
Get the Magento package
-
Build versions of compressed archive, under Archive (zip/tar) section.
- Extract the software on your server
sudo cp <src path>/magento-ce-2.4.3-p1-2021-09-23-07-56-34.zip /var/www/html/magento2/ sudo su -l <web server docroot> cd /var/www/html/magento2 unzip magento-ce-2.4.3-p1-2021-09-23-07-56-34.zip
- Extract the software on your server
-
or Composer
-
Create a new Composer project (get the Magento software metapackage)
sudo su -l <web server docroot> cd /var/www/html/magento2 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.3-p1 .
-
Deprecated, Install Composer v1.x
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer composer self-update 1.10.16 # downgrade it back to version 1.x due to a recent incompatibility issue with one of the packages.
-
-
sudo usermod -a -G www-data <magento_user> su -l <magento_user> cd <magento_root> find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + chown -R :www-data . chmod u+x bin/magento
-
Config the Server Block of Nginx
-
/etc/nginx/sites-available/magento
upstream fastcgi_backend { server unix:/run/php/php7.4-fpm.sock; } server { listen 80; # server_name www.magento-dev.com; set $MAGE_ROOT /var/www/html/magento2; include /var/www/html/magento2/nginx.conf.sample; }
-
ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled
-
rm /etc/nginx/sites-enabled/default
-
./bin/magento setup:install --base-url=http://${m2_host}/ --db-host=${db_host} --db-name=${db_name} --db-user=${db_user} --db-password=${dp_pass} --admin-firstname=Magento --admin-lastname=User [email protected] --admin-user=${admin_name} --admin-password=${admin_pass} --language=zh_Hant_TW --currency=TWD --timezone=Asia/Taipei --use-rewrites=1
magento info:language:list
magento info:currency:list
magento info:timezone:list
rm -rf ${magento_root}/pub/static/*
./bin/magento setup:static-content:deploy
-
Deploy Sample Data from Composer Repository
bin/magento sampledata:deploy
-
Upgrade Magento to enable the sample data modules after the deployment
./bin/magento setup:upgrade
-
check redis setting
redis-cli -p REDIS_PORT -h REDIS_HOST info | egrep --color "(role|used_memory_peak|maxmemory|evicted_keys|uptime_in_days)"
-
restart redis
service redis-server restart
-
see Notion
-
- unzip the zip package into
/${M2_ROOT}/app/i18n/Sunflowerbiz/zh_hans_cn/
magento setup:upgrade
- enable in front-end
- backend console
STORES/ Configuration/ GENERAL/ General/ Locale Options/ Locale/ Chinese (Simplified Han, China)
and clickSave Config
- backend console
- enable in backend
- backend console
SYSTEM/ ALL USERS/ click an user/ Interface Locale/ Chinese (Simplified Han, China)
- backend console
- unzip the zip package into
-
The Most Popular SMTP for Magento 2
- installation guide
composer require mageplaza/module-smtp php bin/magento setup:upgrade php bin/magento setup:static-content:deploy
- installation guide
-
Magento 2 Currency Formatter extension
composer require mageplaza/module-currency-formatter php bin/magento setup:upgrade php bin/magento setup:static-content:deploy
-
-
prerequisites
composer require matomo/device-detector magento setup:upgrade
-
download & unzip the package to ${M2_Base}/app/code/MageWorx
-
enable modules
./bin/magento module:enable MageWorx_Info MageWorx_OrdersBase MageWorx_OrderEditor ./bin/magento setup:upgrade
-
-
- prerequisites
- mPDF
composer require mpdf/mpdf
- mPDF
- prerequisites
-
- install guide
- 注意事項: 記得要照安裝手冊中的把 php-business-sdk 裝起來。
-
magento -h
-
magento admin:user:create
, create an new admin user, see Create or edit an administrator
-
magento deploy:mode:show
, see Set the Magento modemagento deploy:mode:set ${mode}
, where ${mode} can be eitherdefault
,developer
, orproduction
.
-
bin/magento setup:config:set --enable-debug-logging=true
, see To enable debug logging -
magento setup:di:compile
, see Code compiler -
magento maintenance:status
, see Enable or disable maintenance modemagento maintenance:disable
-
magento config:show
, see Display the value of configuration settingsmagento config:show | grep 'base_url'
-
magento setup:store-config:set
, see Configure the store.magento setup:store-config:set --base-url="http://${Host-IP}/"
magento setup:store-config:set --base-url-secure="https://${Host-IP}/"
magento config:set admin/url/use_custom 0
, revert to the default Admin URL and Admin Path
-
Export the configuration
First, please backupapp/etc/config.php
and app/etc/env.php
; otherwise, the original files will be overwritten.
bin/magento app:config:dump
-
list all enabled/disabled modules
magento module:status
-
Enable or disable modules
magento module:disable Magento_TwoFactorAuth
-
Uninstall a module
bin/magento module:uninstall ${ModuleName}
, where${ModuleName}
specifies the module name in<VendorName>_<ModuleName>
format -
bin/magento cache:status
, see View the cache status
-
bin/magento c:f
, cache:flush see Clean and flush cache types -
./bin/magento indexer:status
, see View indexer status -
./bin/magento indexer:reindex customer_grid
, see Manage the indexers -
bin/magento catalog:image:resize
, see Resize catalog images
composer require magento/composer-root-update-plugin=~1.0 --no-update
TODO ...
- Token-based authentication TODO ...
-
Disable Static content signing
- see ref
-
Pre-generate all necessary resizes
magento catalog:image:resize
- Magento 2 Developer Guide
- How to Create a Module in Magento 2
- Custom Web API for Magento 2
- Layout instructions
- How to use Plugin, Preference to rewrite Block, Model, Controller, Helper in Magento 2
- Plugin - Interceptor
- Virtual Types, Types, Preferences: Magento 2 Design Patterns
- How To Install/Uninstall Magento 2 Extensions (Detailed Examples)
- Facebook Business Extension
- Magezon Page Builder extension, community
- Amasty - Shipping Rules
- payment getway