0

Magento Installation and Network Setup:

Magento 2.4.6-ps2 (server) with elasticsearch 5.8 (docker) on NGINX server is successfully installed and running on an Oracle Cloud network environment, consisting of the following components:

Server 1: Nginx Server; Nginx Proxy Manager

  • Public subnet of the network
  • IP: 150.xxx.xx.xx4

Server 2:

  • Nginx Server
  • Magento 2.4.6-ps2 (server)
  • Elasticsearch (running in Docker)
  • IP: 1x.x.x.xx4 (Private IP)

MySQL DB System:

  • Connectivity to the MySQL database is verified and working correctly.

DNS and Network Configuration:

Cloudflare:

A
server1
150.xxx.xx.xx4

Proxied

CNAME
kiqlik.com
server1.kiqlik.com

The same settings apply to www.kiqlik.com.

The DNS is tested, kibana has worked, magento should also do.

NPM UI Configuration:

Inside Server 2 (Magento Server):

Step 1: Composer Configuration:

composer global config http-basic.repo.magento.com <public-key> <private-key>
# Make sure to replace <public-key> and <private-key> with your actual keys.
# This step is complete with the correct keys.

Hosts File Configuration:

# /etc/hosts
127.0.0.1       localhost
::1             ip6-localhost   ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
ff02::3         ip6-allhosts
127.0.1.1       webserver-magento-poc   webserver-magento-poc
127.0.0.1       kiqliq.com www.kiqlik.com
# Your Cloudflare DNS records
1xx.xxx.xxx.xx4 kiqliq.com www.kiqlik.com 

Nginx Configuration (Magento Site):

# /etc/nginx/sites-available/magento

upstream fastcgi_backend {
    server unix:/run/php/php8.1-fpm.sock; # Use the correct socket path
}

server {
    listen 8000;
    server_name kiqlik.com www.kiqlik.com;

    set $MAGE_ROOT /var/www/html/magento;
    set $MAGE_MODE developer; # or production

    # Logging - adjust paths as necessary
    access_log /var/log/nginx/magento_access.log;
    error_log /var/log/nginx/magento_error.log;

    # PHP-FPM configuration
    location ~ \.php$ {
        fastcgi_pass fastcgi_backend; # Use the upstream defined above
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # You can also add other optimizations or configurations here as needed.
}

Also tried new installation with these:

server {
    listen 8000;  # Listen on port 80 (HTTP). You can use a different port if needed.
    server_name kiqlik.com;  # Replace with your domain name.

    # Define the document root where your Magento files are located.
    root /var/www/html/2.4.6-p2;

    # Magento requires these settings for PHP processing.
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;  # Adjust the PHP-FPM socket path.
    }

    # Other Nginx configuration directives as needed.
    # You can add SSL configuration for HTTPS support here if you have an SSL certificate.
}

and

upstream fastcgi_backend {
  server  unix:/run/php/php8.1-fpm.sock;
}

server {

  listen 8000;
  server_name www.kiqlik.com kiqlik.com;
  set $MAGE_ROOT /var/www/html/2.4.6-p2;
  include /var/www/html/2.4.6-p2/nginx.conf.sample;
}

After configuring Nginx, the following commands were executed:

sudo ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

PHP-FPM Socket Verification:

ls /run/php
# Output:
# php-fpm.sock  php8.1-fpm.pid  php8.1-fpm.sock

Here's the env.php file with sensitive information redacted:

<?php
return [
    'backend' => [
        'frontName' => 'admin_1e6oxw'
    ],
    'cache' => [
        'graphql' => [
            'id_salt' => 'aa1Ng1yTtlw7oP7uYkKlB3A0PLJxjgg4'
        ],
        'frontend' => [
            'default' => [
                'id_prefix' => 'd19_'
            ],
            'page_cache' => [
                'id_prefix' => 'd19_'
            ]
        ],
        'allow_parallel_generation' => false
    ],
    'remote_storage' => [
        'driver' => 'file'
    ],
    'queue' => [
        'consumers_wait_for_messages' => 1
    ],
    'crypt' => [
        'key' => '6ede5f69c070f0c1469e5a3a23bcdd98'
    ],
    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'REDACTED', // Replace with your actual host
                'dbname' => 'REDACTED', // Replace with your actual database name
                'username' => 'REDACTED', // Replace with your actual username
                'password' => 'REDACTED', // Replace with your actual password
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1014 => false
                ]
            ]
        ]
    ],
    'resource' => [
        'default_setup' => [
            'connection' => 'default'
        ]
    ],
    'x-frame-options' => 'SAMEORIGIN',
    'MAGE_MODE' => 'default',
    'session' => [
        'save' => 'files'
    ],
    'lock' => [
        'provider' => 'db'
    ],
    'directories' => [
        'document_root_is_pub' => true
    ],
    'cache_types' => [
        'config' => 1,
        'layout' => 1,
        'block_html' => 1,
        'collections' => 1,
        'reflection' => 1,
        'db_ddl' => 1,
        'compiled_config' => 1,
        'eav' => 1,
        'customer_notification' => 1,
        'config_integration' => 1,
        'config_integration_api' => 1,
        'full_page' => 1,
        'config_webservice' => 1,
        'translate' => 1
    ],
    'downloadable_domains' => [
        'kiqlik.com'
    ],
    'elasticsearch' => [
        'server_hostname' => 'localhost',
        'server_port' => '9200',
        'enable_auth' => '0',
        'username' => 'REDACTED', // Replace with your actual Elasticsearch username
        'password' => 'REDACTED', // Replace with your actual Elasticsearch password
        'index_prefix' => 'magento2',
        'timeout' => '15',
        'verify_host' => '1'
    ],
    'install' => [
        'date' => 'Thu, 05 Oct 2023 03:53:58 +0000'
    ],
];

deborah@webserver-magento-poc:~$ cat /etc/hosts
127.0.0.1       localhost
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost   ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
127.0.1.1       webserver-magento-poc   webserver-magento-poc
127.0.0.1       kiqliq.com www.kiqlik.com
# The proxy host on npm
150.{vvv}4 www.kiqlik.com kiqlik.com
ubuntu@webserver-magento-poc:~$ curl -Ik https://kiqlik.com/admin_n5lu4r --insecure
HTTP/2 502 
server: openresty
date: Tue, 10 Oct 2023 21:35:24 GMT
content-type: text/html
content-length: 154

dns

npm

This is the milion'th time I install this and now that I finally got elasticsearch no alive nodes out the way, I get the proxy host file problem.

Last move was to re-install magento, use the default env.php with no elasticsearch lines, it is good, no errors, and it is installed.

I also did not create any set apart host file on sites-availabe, having only the etc/host with the proxy IP for npm.

502 Bad Gateway.

If I set the sites-availabe Nginx takes the 8000.

Thanks a lot!

0

1 Answer 1

0

Try this solution.

modifying this file

/etc/nginx/nginx.conf

add this line of codes inside http{}

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.