FreeBSD Setup Magento Adobe Commerce With PHP Composer and Apache

Magento is one of the CMS Framework applications designed to launch large-scale and complex e-commerce projects. The main goal is to help online shop owners with hundreds to thousands of products. Its ease in managing thousands of products is very popular with large entrepreneurs.

Magento written in PHP developed by Adobe is an open source e-commerce platform for managing online stores. Magento features provide tools to create and manage online stores and online shopping platforms. Magento delivers a smoother navigation system, better conversions, and better user experience.

Magento is capable of flexible customization, scalability and extensibility for various types of online businesses. The Magento CMS platform also supports a variety of functions, including product management, ordering, payments, shipping, and marketing tools to enhance customer experience. This allows companies to create and maintain effective online stores with a variety of features and capabilities that can help store owners grow their businesses.

Magento also known as Adobe Commerce, is an ecommerce solution for large online merchants, designed with developers in mind to design online stores independently. Magento provides easy product inventory and sales management for better organization of your ecommerce store. This e-commerce also provides a page builder, so you can easily create and design web pages exactly the way you want.




According to the official release issued by Adobe, the company by absorbing Magento will be able to create a comprehensive system for developing digital advertising, online stores and other technologies for online customers.

In this post, we will learn the process of installing and configuring Adobe Magento, so you can display the Magento Platform on your Google Chrome screen.


1. System Specifications

OS: FreeBSD 13.3
Hostname: ns3
IP FreeBSD: 192.168.5.2
Database server: MySQL8
Web server: Apache24
PHP: PHP82, PHP Composer
PHP FPM
Elasticsearch: elasticsearch8
Dependencies:
php82-opcache php82-session php82-pecl-APCu php82-bcmath php82-bz2 php82-ctype php82-curl php82-dom php82-exif php82-fileinfo php82-filter php82-gd php82-gmp php82-iconv php82-intl php82-ldap php82-mbstring php82-pecl-msgpack php82-mysqli php82-pcntl php82-pdo php82-phar php82-posix php82-simplexml php82-sodium php82-sysvsem php82-tokenizer php82-xml php82-xmlwriter php82-zip php82-zlib php82-pecl-memcache php82-pecl-memcached php82-pdo_mysql php82-xmlreader php82-xsl php82-soap


2. Install Dependencies

Adobe Magento has a lot of PHP dependencies. You must install dependencies the first time you configure MAgento. Because if you don't install dependencies, don't dream that you can run Magento well. All dependencies are written in PHP, which is very useful for Magento to connect its website to databases and web servers such as Apache.

To make it easier, you can install Magento dependencies using the FreeBSD PKG package. Below is how to install Magento dependencies with PKG.

Install dependencies
root@ns3:/usr/local/www # pkg install php82-opcache php82-session php82-pecl-APCu php82-bcmath php82-bz2 php82-ctype php82-curl php82-dom php82-exif php82-fileinfo php82-filter php82-gd php82-gmp php82-iconv php82-intl php82-ldap php82-mbstring php82-pecl-msgpack php82-mysqli php82-pcntl php82-pdo php82-phar php82-posix php82-simplexml php82-sodium php82-sysvsem php82-tokenizer php82-xml php82-xmlwriter php82-zip php82-zlib php82-pecl-memcache php82-pecl-memcached php82-pdo_mysql php82-xmlreader php82-xsl php82-soap


3. Create Database Adobe Magento

In this article we assume that all the System Specifications above have been installed on the FreeBSD server. So we will not discuss the application above. Let's go straight to the main discussion of this article.

Database creation is an important part of Magento configuration. All your data such as product names and customer data will be stored in the database. In this article we will use the MySQL server to create a Magento database.

The commands below will guide you to create a Maento database with MySQL server.

Create database
root@ns3:~ # mysql -u root -p
root@localhost [(none)]> CREATE DATABASE magento CHARACTER SET utf8;
root@localhost [(none)]> CREATE USER 'usermagento'@'localhost' IDENTIFIED BY 'router12345';
root@localhost [(none)]> GRANT ALL PRIVILEGES ON magento.* TO 'usermagento'@'localhost';
root@localhost [(none)]> FLUSH PRIVILEGES;
root@localhost [(none)]> exit;
root@ns3:~ #


4. Create Adobe Magento Public and Private Keys

Before starting the Magento installation process, you must create a Magento public and private key. This key is used to authenticate accessing the repo.magento.com repository. Because every time you access repo.magento.com, public and private keys are needed. This key is used to fill in:
Username = public key
Password = private key

The way to get or generate the key is by accessing the Magento market site.

  1. First login https://marketplace.magento.com/
  2. If you don't have a Magento account, create a new account at https://account.magento.com/applications/customer/login/
  3. If you already have a Magento account, log in with your Magento credentials.
  4. After you have successfully logged in, open the "My Profile" menu.
  5. Click “Access Key”
  6. Select the "Magento2" menu.
  7. To create a new key, you click the "Create A New Access Key" menu

5. Install Adobe Magento

On FreeBSD systems, Magento repositories are not available in PKG or ports. While installing Magento and modules Magento, Composer module is actively used. So, before you install Magento, Composer must be installed first. Another important detail when using Composer is that the memory_limit (PHP) variable must be set to 4 GB. At the 2 GB limit, Composer can crash PHP with a fatal error during the installation process.

The first step is to create a working directory for Magento, we will place this directory in the Apache server block, namely /usr/local/www.

Create directory
root@ns3:~ # mkdir -p /usr/local/www/magento
After that, create a Magento project with Composer

Create project "Magento"
root@ns3:~ # cd /usr/local/www
root@ns3:/usr/local/www # composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento
When you run the command above, Composer will ask for Username and password. Use the password and user you created above. After that, you install Magento with the command below.

Install Magento
root@ns3:/usr/local/www # cd magento
root@ns3:/usr/local/www/magento # composer install --ignore-platform-req=ext-sockets
Also install socket for PHP.

Install socket PHP
root@ns3:/usr/local/www/magento # pkg install php82-sockets
Also run the command below to continue the Magento installation

Install Magento
root@ns3:/usr/local/www/magento/bin # ./magento setup:install --base-url=http://192.168.5.2/magento --db-host=localhost --db-name=magento --db-user=usermagento --db-password=router12345 --admin-firstname=john --admin-lastname=doe --admin-email=datainchi@gmail.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/New_York --use-rewrites=1 --search-engine=elasticsearch8 --elasticsearch-host=http://192.168.5.2 --elasticsearch-port=9200
What you need to pay attention to during the Magento installation process on FreeBSD is the Elasticsearch application. You must have installed this application before you install Magento. You can read the Elasticsearch article in our previous article.


You open the elasticsearch.yml file and edit the script as in the example below.

/usr/local/etc/elasticsearch
root@ns3:~ # ee /usr/local/etc/elasticsearch/elasticsearch.yml
cluster.name: magento
node.name: node-1
path.data: /var/db/elasticsearch
path.logs: /var/run/elasticsearch
bootstrap.memory_lock: true
network.host: 192.168.5.2
http.port: 9200
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
discovery.type: single-node
xpack.ml.enabled: false
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
Starting with Magento 2.2 version, a crontab file was added to manage log files. On FreeBSD you can manage the crontab file in /etc/crontab. Run the command below to install the crontab file.

Install Crontab
root@ns3:~ # cd /usr/local/www/magento/bin
root@ns3:/usr/local/www/magento/bin # ./magento cron:install --force
Crontab has been generated and saved
Then in the /etc/crontab file, you add the script below.

Add Script Crontab
root@ns3:/usr/local/www/magento/bin # ee /etc/crontab
* * * * * /usr/local/bin/php /usr/local/www/magento/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /usr/local/www/magento/var/log/magento.cron.log
Next, you run the commands below to update the database, deploy the static display files and disable the two-factor authentication.

Update database
root@ns3:/usr/local/www/magento/bin # ./magento indexer:reindex && ./magento se:up && ./magento se:s:d -f && ./magento c:f && ./magento module:disable Magento_TwoFactorAuth
Then you add access rights and ownership to Magento files and folders.

Ownership & permissions
root@ns3:~ # chown -R www:www /usr/local/www/magento/
root@ns3:~ # chmod -R 775 /usr/local/www/magento


6. Create Apache Vhost

As a Magento frontend we will use Apache24 as a web server. With the help of Apache, Magento can be displayed or configured via Google Chrome. To connect Magento with Apache, you need to activate the Apache virtual host file. In the httpd.conf file, activate the vhost file by removing the "#" sign, see the example below.

/usr/local/etc/apache24
root@ns3:~ # cd /usr/local/etc/apache24
root@ns3:/usr/local/etc/apache24 # ee httpd.conf
#Include etc/apache24/extra/httpd-vhosts.conf
Include etc/apache24/extra/httpd-vhosts.conf
After that you delete all the /usr/local/etc/apache24/extra/vhost.conf scripts, and replace them with the scripts below (adjust to your FreeBSD server system).

/usr/local/etc/apache24/extra
root@ns3:/usr/local/etc/apache24 # cd extra
root@ns3:/usr/local/etc/apache24/extra # ee httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin datainchi@gmail.com
    DocumentRoot "/usr/local/www/magento/pub"
    ServerName datainchi.com
    ServerAlias www.datainchi.com
SetEnv MAGE_RUN_CODE "base"
    SetEnv MAGE_RUN_TYPE "website"

  <Directory /usr/local/www/magento/pub>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require all granted
  </Directory>

    ErrorLog "/var/log/dummy-host.example.com-error_log"
    CustomLog "/var/log/dummy-host.example.com-access_log" common
</VirtualHost>
The next step, you restart Apache24.

Restart apache
root@ns3:~ # service apache24 restart
The final step is to test by opening Google Chrome and typing "http://192.168.5.2/magento/setup/" or "http://192.168.5.2/magento/pub/". Look at the results in Google Chrome, if your configuration is correct then the Magento configuration menu will appear.

When you want to use Magento to open an online store, a complete and clear installation and configuration guide will make the process easier. This tutorial shows how to manually setup Magento on a FreeBSD server. However, the existing script can be used on Linux servers such as Ubuntu. We present the entire contents of this article in full and can help those of you who want to create an online shop with Magento.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post