สวัสดีครับ วันนี้ จะมาพูดถึงการ Install Magento 2 (Adobe Commerce) นะครับ
เป็น eCommerce Software ตัวนึง ที่น่าใช้มากๆ มาพร้อมกับ feature ที่ครบครัน ..
รายละเอียดเพิ่มเติม https://business.adobe.com/products/magento/magento-commerce.html
รายละเอียดของ System ประมาณนี้ครับ
- OS: Ubuntu 22.04
- Magento: 2.4.6-p2 (Open Source)
- Apache: 2.4.x
- PHP: 8.1.2
- Composer: 2.2.6
- MySQL: 8.0.34
- Elasticsearch: 7.17.13
มาเริ่มกันเลย ..
Step 1: Update Operating System
# apt update && apt upgrade -y
Step 2: Install Apache Web Server
# apt install apache2
Step 3: Install PHP and PHP extensions
# apt install php php-common libapache2-mod-php php-cli php-fpm php-mysql php-json php-opcache php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-xml php-zip php-soap php-bcmath php-apcu
Modify php.ini file (/etc/php/8.1/cli/php.ini)
memory_limit = 1GB
upload_max_filesize = 256M
zlib.output_compression = On
max_execution_time = 600
max_input_time = 900
date.timezone = Asia/Bangkok
Step 4: Install the MySQL server
# apt install mysql-server
# mysql_secure_installation
Step 5: Create a Magento Database
# mysql -u root -p
mysql> CREATE DATABASE magento;
mysql> CREATE USER 'magento'@'localhost' IDENTIFIED BY 'Str0ngPa$$w0rd';
mysql> GRANT ALL PRIVILEGES ON magento.* TO 'magento'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Step 6. Install Elasticsearch
# curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
# echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
# apt update && apt install elasticsearch
# systemctl start elasticsearch
# systemctl enable elasticsearch
Verify Elasticsearch
curl -X GET "localhost:9200"
{
"name" : "magento-01",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "-Or5raP6T5uEG3bUG1JYHw",
"version" : {
"number" : "7.17.13",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "2b211dbb8bfdecaf7f5b44d356bdfe54b1050c13",
"build_date" : "2023-08-31T17:33:19.958690787Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Step 7: Install Composer
# apt install composer
Step 8: Install Magento
Goto Magento Marketplace https://marketplace.magento.com/
Get Access Keys
My profile > Marketplace > My products > Access Keys
# composer global config http-basic.repo.magento.com Your-Public-Key Your-Private-Key
# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.6-p2 /var/www/magento
# cd /var/www/magento
# bin/magento setup:install \
--base-url=http://your-domain.com \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=Str0ngPa$$w0rd \
--admin-firstname=Admin \
--admin-lastname=User \
--admin-email=admin@your-domain.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=Asia/Bangkok \
--use-rewrites=1
# chown -R www-data: /var/www/magento
Step 9: Setup Cron jobs
# sudo -u www-data bin/magento cron:install
Step 10: Configure Apache for Magento
Create /etc/apache2/sites-available/magento.conf
<VirtualHost *:80>
ServerAdmin admin@your_domain.com
DocumentRoot /var/www/magento/pub
ServerName your_domain.com
ServerAlias www.your_domain.com
<Directory /var/www/magento>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# a2ensite magento.conf
# a2enmod rewrite
# systemctl restart apache2
Step 11: Access your Magento installation
Store Front: http://your_domain.com
Admin Dashboard: http://your_domain.com/admin_xxxxxx
Step 12: Diasable 2FA
# bin/magento mod:dis Magento_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth
# bin/magento setup:di:compile
Options: Tuning Magento
https://experienceleague.adobe.com/docs/commerce-operations/performance-best-practices/software.html