Monday, June 9, 2025

Drupal JavaScripts to hide and show resources

{# 1. Main slider paragraph template #}
{# File: templates/paragraph--slider-with-resources.html.twig #}

<div class="slider-with-resources-wrapper">
  <div class="slider-container" data-slick='{"dots": true, "arrows": true, "infinite": true, "speed": 300, "slidesToShow": 1, "slidesToScroll": 1, "responsive": [{"breakpoint": 768, "settings": {"arrows": false}}]}'>
    {% for item in slider_items %}
      {{ drupal_entity('paragraph', item.id(), 'default') }}
    {% endfor %}
  </div>
</div>

{# 2. Slider item template #}
{# File: templates/paragraph--slider-item.html.twig #}

<div class="slider-item">
  <div class="container-fluid">
    <div class="row">
      <div class="col-lg-6 col-md-12">
        {% if content.field_slide_image %}
          <div class="slide-image">
            {{ content.field_slide_image }}
          </div>
        {% endif %}
      </div>
      <div class="col-lg-6 col-md-12">
        <div class="slide-content">
          {% if content.field_slide_title %}
            <h3 class="slide-title">
              {{ content.field_slide_title }}
            </h3>
          {% endif %}
          
          {% if content.field_slide_description %}
            <div class="slide-description">
              {{ content.field_slide_description }}
            </div>
          {% endif %}
          
          {% if resources %}
            <div class="slide-resources">
              <h4>Resources</h4>
              <ul class="resources-list">
                {% for key, resource in resources %}
                  <li class="resource-item{% if key >= 2 %} hidden-resource{% endif %}">
                    <a href="{{ resource.url }}" class="resource-link">
                      {{ resource.title }}
                    </a>
                  </li>
                {% endfor %}
              </ul>
              {% if resources|length > 2 %}
                <button class="btn btn-outline-primary btn-sm show-more-resources" type="button">
                  <span class="show-text">Show 2 More</span>
                  <span class="hide-text d-none">Show Less</span>
                </button>
              {% endif %}
            </div>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>

/**
 * INSTALLATION INSTRUCTIONS
 * 
 * 1. Install required modules:
 *    - Paragraphs module
 *    - Slick module (composer require drupal/slick)
 *    - Slick Views module (usually comes with Slick)
 * 
 * 2. Create the module structure:
 *    modules/custom/your_module/
 *    ├── your_module.info.yml
 *    ├── your_module.module
 *    ├── your_module.libraries.yml
 *    ├── config/install/
 *    │   ├── paragraphs.paragraphs_type.slider_with_resources.yml
 *    │   ├── paragraphs.paragraphs_type.slider_item.yml
 *    │   ├── field.storage.paragraph.field_slider_items.yml
 *    │   ├── field.field.paragraph.slider_with_resources.field_slider_items.yml
 *    │   ├── field.storage.paragraph.field_slide_image.yml
 *    │   ├── field.field.paragraph.slider_item.field_slide_image.yml
 *    │   ├── field.storage.paragraph.field_slide_title.yml
 *    │   ├── field.field.paragraph.slider_item.field_slide_title.yml
 *    │   ├── field.storage.paragraph.field_slide_description.yml
 *    │   ├── field.field.paragraph.slider_item.field_slide_description.yml
 *    │   ├── field.storage.paragraph.field_slide_resources.yml
 *    │   └── field.field.paragraph.slider_item.field_slide_resources.yml
 *    ├── templates/
 *    │   ├── paragraph--slider-with-resources.html.twig
 *    │   └── paragraph--slider-item.html.twig
 *    ├── css/
 *    │   └── slider-resources.css
 *    └── js/
 *        └── slider-resources.js
 * 
 * 3. Module info file (your_module.info.yml):
 *    name: 'Slider with Resources'
 *    type: module
 *    description: 'Custom paragraph with slick slider and expandable resources'
 *    core_version_requirement: ^9 || ^10
 *    dependencies:
 *      - paragraphs:paragraphs
 *      - slick:slick
 * 
 * 4. Field configurations for slider_item:
 * 
 *    Create these fields through the UI or config files:
 *    - field_slide_image: Image field
 *    - field_slide_title: Plain text field
 *    - field_slide_description: Formatted text field
 *    - field_slide_resources: Entity reference field (to taxonomy terms or content)
 *      * Set cardinality to 4
 *      * Target your resource content type or taxonomy
 * 
 * 5. After installation:
 *    - Clear caches
 *    - Go to Structure > Paragraph Types
 *    - Verify both paragraph types exist
 *    - Add the paragraph to your content type
 *    - Configure display settings as needed
 * 
 * USAGE:
 * 1. Add "Slider with Resources" paragraph to any content
 * 2. Add multiple "Slider Item" paragraphs within it
 * 3. Each slider item can have:
 *    - One image
 *    - A title
 *    - Description text
 *    - Up to 4 resource links
 * 4. The first 2 resources show by default
 * 5. "Show 2 More" button reveals the remaining resources
 * 
 * CUSTOMIZATION:
 * - Modify CSS classes to match your Bootstrap theme
 * - Adjust Slick settings in the data-slick attribute
 * - Customize responsive breakpoints in CSS
 * - Change animation effects in JavaScript
 */

<?php
// 3. Paragraph type configuration (add to your module's config/install)
// File: config/install/paragraphs.paragraphs_type.slider_with_resources.yml

/*
langcode: en
status: true
dependencies: {  }
id: slider_with_resources
label: 'Slider with Resources'
icon_uuid: null
icon_default: null
description: 'A slider paragraph with image, title, description and expandable resources'
behavior_plugins: {  }
*/

// 2. Field configuration for the paragraph type
// File: config/install/field.storage.paragraph.field_slider_items.yml

/*
langcode: en
status: true
dependencies:
  module:
    - paragraphs
id: paragraph.field_slider_items
field_name: field_slider_items
entity_type: paragraph
type: entity_reference_revisions
settings:
  target_type: paragraph
module: entity_reference_revisions
locked: false
cardinality: -1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false
*/

// 3. Field instance configuration
// File: config/install/field.field.paragraph.slider_with_resources.field_slider_items.yml

/*
langcode: en
status: true
dependencies:
  config:
    - field.storage.paragraph.field_slider_items
    - paragraphs.paragraphs_type.slider_item
    - paragraphs.paragraphs_type.slider_with_resources
  module:
    - entity_reference_revisions
id: paragraph.slider_with_resources.field_slider_items
field_name: field_slider_items
entity_type: paragraph
bundle: slider_with_resources
label: 'Slider Items'
description: ''
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  handler: 'default:paragraph'
  handler_settings:
    negate: 0
    target_bundles:
      slider_item: slider_item
    target_bundles_drag_drop:
      slider_item:
        enabled: true
        weight: 2
field_type: entity_reference_revisions
*/

// 4. Slider Item paragraph type fields
// Create these field configs for paragraph type 'slider_item':

/*
Fields needed for slider_item paragraph:
- field_slide_image (image)
- field_slide_title (string)  
- field_slide_description (text_long)
- field_slide_resources (entity_reference to taxonomy or content, cardinality: 4)
*/

// 5. Module file with preprocessing
// File: modules/custom/your_module/your_module.module

/**
 * Implements hook_theme().
 */
function your_module_theme($existing, $type, $theme, $path) {
  return [
    'paragraph__slider_with_resources' => [
      'base hook' => 'paragraph',
    ],
    'paragraph__slider_item' => [
      'base hook' => 'paragraph',
    ],
  ];
}

/**
 * Implements hook_preprocess_paragraph().
 */
function your_module_preprocess_paragraph(&$variables) {
  $paragraph = $variables['paragraph'];
  
  if ($paragraph->bundle() == 'slider_with_resources') {
    // Add Slick library
    $variables['#attached']['library'][] = 'slick/slick';
    $variables['#attached']['library'][] = 'your_module/slider_resources';
    
    // Process slider items
    $slider_items = [];
    if ($paragraph->hasField('field_slider_items') && !$paragraph->get('field_slider_items')->isEmpty()) {
      foreach ($paragraph->get('field_slider_items')->referencedEntities() as $item) {
        $slider_items[] = $item;
      }
    }
    $variables['slider_items'] = $slider_items;
  }
  
  if ($paragraph->bundle() == 'slider_item') {
    // Process resources for show/hide functionality
    $resources = [];
    if ($paragraph->hasField('field_slide_resources') && !$paragraph->get('field_slide_resources')->isEmpty()) {
      foreach ($paragraph->get('field_slide_resources')->referencedEntities() as $resource) {
        $resources[] = [
          'title' => $resource->label(),
          'url' => $resource->toUrl()->toString(),
        ];
      }
    }
    $variables['resources'] = $resources;
  }
}

// 6. Library definition
// File: modules/custom/your_module/your_module.libraries.yml

/*
slider_resources:
  version: 1.x
  js:
    js/slider-resources.js: {}
  css:
    theme:
      css/slider-resources.css: {}
  dependencies:
    - core/jquery
    - core/drupal
    - slick/slick
*/

/* CSS File: css/slider-resources.css */

.slider-with-resources-wrapper {
  margin: 2rem 0;
}

.slider-container {
  position: relative;
}

.slider-item {
  padding: 2rem 0;
  min-height: 400px;
}

.slide-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.slide-content {
  padding: 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.slide-title {
  color: #333;
  margin-bottom: 1rem;
  font-weight: 600;
}

.slide-description {
  margin-bottom: 1.5rem;
  color: #666;
  line-height: 1.6;
}

.slide-resources h4 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.resources-list {
  list-style: none;
  padding: 0;
  margin-bottom: 1rem;
}

.resource-item {
  margin-bottom: 0.5rem;
  transition: all 0.3s ease;
}

.resource-item.hidden-resource {
  display: none;
}

.resource-item.show {
  display: block;
  animation: fadeInUp 0.3s ease;
}

.resource-link {
  display: inline-block;
  color: #007bff;
  text-decoration: none;
  padding: 0.5rem 0;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.resource-link:hover {
  color: #0056b3;
  text-decoration: none;
  border-bottom-color: #0056b3;
}

.show-more-resources {
  transition: all 0.2s ease;
}

.show-more-resources:hover {
  transform: translateY(-1px);
}

/* Slick slider customizations */
.slick-dots {
  bottom: -50px;
}

.slick-dots li button:before {
  color: #007bff;
  font-size: 12px;
}

.slick-dots li.slick-active button:before {
  color: #0056b3;
}

.slick-prev, .slick-next {
  z-index: 2;
}

.slick-prev:before, .slick-next:before {
  color: #007bff;
  font-size: 20px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .slider-item {
    text-align: center;
  }
  
  .slide-content {
    margin-top: 1rem;
  }
  
  .slick-dots {
    bottom: -30px;
  }
}

// JavaScript File: js/slider-resources.js

(function ($, Drupal) {
  'use strict';

  Drupal.behaviors.sliderResources = {
    attach: function (context, settings) {
      // Initialize Slick slider
      $('.slider-container', context).each(function() {
        var $slider = $(this);
        
        // Initialize slick if not already initialized
        if (!$slider.hasClass('slick-initialized') && !$slider.data('slick-processed')) {
          $slider.slick();
          $slider.data('slick-processed', true);
        }
      });

      // Handle show more/less resources functionality
      $('.show-more-resources', context).each(function() {
        var $button = $(this);
        
        // Check if already processed to avoid duplicate event handlers
        if (!$button.data('show-more-processed')) {
          $button.data('show-more-processed', true);
          
          $button.on('click', function(e) {
            e.preventDefault();
            
            var $resourcesList = $button.siblings('.resources-list');
            var $hiddenResources = $resourcesList.find('.hidden-resource');
            var $showText = $button.find('.show-text');
            var $hideText = $button.find('.hide-text');
            
            if ($hiddenResources.first().hasClass('show')) {
              // Hide resources
              $hiddenResources.removeClass('show').fadeOut(300, function() {
                $(this).hide();
              });
              $showText.removeClass('d-none');
              $hideText.addClass('d-none');
              $button.blur();
            } else {
              // Show resources
              $hiddenResources.addClass('show').fadeIn(300);
              $showText.addClass('d-none');
              $hideText.removeClass('d-none');
              $button.blur();
            }
          });
        }
      });
    }
  };

})(jQuery, Drupal);

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resources</title>
<style>
.hidden-resource {
display: none;
}
.hide-more-resources {
display: none;
cursor: pointer;
color: blue;
}
.show-more-resources {
cursor: pointer;
color: blue;
}
.card {
border: 1px solid #ccc;
padding: 16px;
margin-bottom: 16px;
width: fit-content;
}
</style>
</head>
<body>

<div class="card">
<div class="resource-list">
<div class="resource-item">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
<div class="resource-item">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
<div class="resource-item hidden-resource">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
<div class="resource-item hidden-resource">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
</div>
<div class="show-more-resources">2 more</div>
<div class="hide-more-resources">Show less</div>
</div>
<div class="card">
<div class="resource-list">
<div class="resource-item">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
<div class="resource-item">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
<div class="resource-item hidden-resource">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
<div class="resource-item hidden-resource">
<div class="resource-item__content">
<h3 class="resource-item__title">This is title</h3>
<p class="resource-item__description"> This is description This is description This is description This is description This is description </p>
</div>
</div>
</div>
<div class="show-more-resources">2 more</div>
<div class="hide-more-resources">Show less</div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
const cards = document.querySelectorAll('.card');

cards.forEach(card => {
const showMoreBtn = card.querySelector('.show-more-resources');
const hideMoreBtn = card.querySelector('.hide-more-resources');
const hiddenResources = card.querySelectorAll('.hidden-resource');

showMoreBtn.addEventListener('click', () => {
hiddenResources.forEach(resource => {
resource.style.display = 'block';
});
showMoreBtn.style.display = 'none';
hideMoreBtn.style.display = 'block';
});

hideMoreBtn.addEventListener('click', () => {
hiddenResources.forEach(resource => {
resource.style.display = 'none';
});
showMoreBtn.style.display = 'block';
hideMoreBtn.style.display = 'none';
});
});
});
</script>

unction YOURTHEME_preprocess_field(&$variables) { if ($variables['element']['#field_name'] === 'field_tab_items') { foreach ($variables['items'] as $delta => $item) { if (isset($item['#paragraph'])) { $paragraph = $item['#paragraph']; $view_mode = $item['#view_mode'] ?? 'default'; $variables['items'][$delta]['#paragraph_view_mode'] = $view_mode; } } } }

{% for item in items %} <div class="tab-item"> {# View mode is custom passed — fallback to default #} {% set view_mode = item['#paragraph_view_mode']|default('default') %} <div class="mode-{{ view_mode }}"> {{ item.content }} </div> </div> {% endfor %}

</body>
</html>

Saturday, March 30, 2024

Cloudflare Settings for Marketing Websites

Cloudflare is a widely-used content delivery network (CDN) and cybersecurity company that offers a suite of performance and security solutions for websites. This documentation provides guidelines and best practices for configuring Cloudflare settings specifically tailored to marketing websites. By leveraging Cloudflare's features effectively, marketing teams can enhance website performance, reliability, and security while optimizing user experience.


Features and Configurations:

Content Delivery Network (CDN) Configuration:

Enable Cloudflare's CDN to accelerate website loading times by caching static content and serving it from Cloudflare's edge servers located worldwide.

Configure caching settings to cache static assets such as images, CSS, and JavaScript files, ensuring faster page load times for visitors.

SSL/TLS Encryption:

Enable SSL/TLS encryption to secure data transmission between visitors and the website's server.

Configure Cloudflare's SSL/TLS settings to enforce HTTPS protocol, ensuring all traffic is encrypted and secure.

Automatic Minification:

Utilize Cloudflare's automatic minification feature to reduce the size of CSS, JavaScript, and HTML files, optimizing website performance.

Enable minification settings for CSS, JavaScript, and HTML to remove unnecessary whitespace, comments, and formatting.

Image Optimization:

Enable Cloudflare's image optimization features to automatically optimize and resize images based on visitor device characteristics and screen sizes.

Configure image optimization settings to deliver optimized images in WebP or other formats for faster loading times and improved user experience.

Web Application Firewall (WAF):

Activate Cloudflare's WAF to protect the website against common web application attacks, such as SQL injection, cross-site scripting (XSS), and malicious bot traffic.

Customize WAF rulesets and security levels to balance security and usability, ensuring legitimate traffic is not blocked while mitigating security threats.

Bot Management:

Utilize Cloudflare's bot management features to identify and mitigate malicious bot traffic, such as scrapers, spammers, and DDoS attacks.

Configure bot management settings to allow legitimate search engine crawlers while blocking or challenging suspicious bot activity.

Implementation and Configuration:

Sign Up for Cloudflare:

Register for a Cloudflare account and add the marketing website to your Cloudflare dashboard.

DNS Configuration:

Update the website's DNS records to point to Cloudflare's nameservers for traffic routing through Cloudflare's network.

SSL/TLS Configuration:

Configure SSL/TLS settings in Cloudflare to enable encryption and select the appropriate SSL/TLS encryption mode (e.g., Full, Full (strict)).

Performance Optimization:

Enable caching, minification, and image optimization settings in Cloudflare to improve website performance.

Security Configuration:

Configure WAF, bot management, and other security settings in Cloudflare to protect the website from threats and attacks.

Testing and Monitoring:

Test the website's performance and security after configuring Cloudflare settings.

Monitor Cloudflare analytics and security logs to track website performance, traffic patterns, and security events.

Support and Resources:

For assistance with Cloudflare setup and configuration, refer to Cloudflare's official documentation, knowledge base, and support resources.

Engage with the Cloudflare community forums, user groups, and online communities to share experiences, seek advice, and troubleshoot issues.

Conclusion:

Configuring Cloudflare settings for marketing websites can significantly improve website performance, reliability, and security while enhancing the overall user experience. By following the guidelines and best practices outlined in this documentation, marketing teams can leverage Cloudflare's powerful features to optimize website delivery, protect against threats, and achieve their marketing objectives effectively. 

Drupal module Security Kit

Drupal Security Kit (Seckit) is a module designed to enhance the security of Drupal websites by providing various security features and configurations. It aims to mitigate common security risks and vulnerabilities associated with Drupal websites, ensuring a more robust and secure online presence.


Features:

Content Security Policy (CSP) Integration:

Seckit integrates with Content Security Policy (CSP), allowing administrators to define and enforce policies to mitigate the risks of Cross-Site Scripting (XSS) attacks.

Administrators can configure CSP directives to specify trusted sources for various types of content, such as scripts, stylesheets, images, fonts, and more.

HTTP Strict Transport Security (HSTS) Support:

The module facilitates the implementation of HTTP Strict Transport Security (HSTS) headers, ensuring that web browsers enforce secure connections over HTTPS.

Administrators can configure HSTS parameters, including the max-age directive and the inclusion of subdomains.

X-Content-Type-Options Header Configuration:

Seckit enables administrators to set the X-Content-Type-Options header, which prevents MIME type sniffing attacks by instructing browsers to adhere strictly to declared content types.

X-Frame-Options Header Settings:

Administrators can configure the X-Frame-Options header to mitigate Clickjacking attacks by restricting the embedding of Drupal pages in frames on other websites.

X-XSS-Protection Header Control:

The module provides options to enable or disable the X-XSS-Protection header, which instructs browsers to activate built-in XSS protection features.

Referrer Policy Configuration:

Seckit allows administrators to define the referrer policy for outgoing requests, controlling the information sent in the HTTP Referer header to enhance privacy and security.

Installation and Configuration:

Installation:

Download and install the Drupal Security Kit module from the official Drupal.org repository or using Composer.

Configuration:

Once installed, navigate to the administration interface of your Drupal site.

Access the Configuration page and locate the "Security Kit" settings.

Configure each security feature according to your site's requirements and security policies.

Save the settings to apply the configured security measures to your Drupal website.

Usage:

After configuring the security settings within the module, Drupal Security Kit automatically applies the specified security headers and policies to incoming requests, bolstering the security posture of your Drupal website.

Compatibility:

Drupal Security Kit is compatible with Drupal 7 and Drupal 8/9, ensuring that websites built on different Drupal versions can benefit from its security features.

Support and Community:

For additional assistance, documentation, or community support, refer to the official Drupal Security Kit documentation on Drupal.org.

Engage with the Drupal community forums, issue queues, and user groups to share experiences, seek advice, and contribute to the improvement of the module.

Conclusion:

Drupal Security Kit (Seckit) offers a comprehensive suite of security features and configurations to fortify Drupal websites against common security threats and vulnerabilities. By leveraging this module, Drupal site administrators can enhance the security posture of their websites and safeguard sensitive data and user information effectively. 

Wednesday, July 13, 2022

Blank page on NextJs project even every code was right - culprit was browser extension

 I was working on some Nextjs projects where I have to show the Ads services content, so I created a file called ads-services.js under the pages folder of the NextJs project.

Then, I added the code something like the below:


 






Built it and run it in the browser and everything is blank, cannot see anything.

Found solution after 1/2 hour, either I have to disable the Adblocker extension used in the browser or need to change the ads-service.js file name to something live management-services.js 

Rare headache which makes you bald.


Monday, December 27, 2021

API endpoints collections for the creation of Cryptocurrencies payment modules

https://docs.metamask.io/guide/getting-started.html#basic-considerations

 https://infura.io/docs/eth2

https://marketinsg.zendesk.com/hc/en-us/articles/360045156711-Crypto-com-Pay

http://trufflesuite.com/index.html

https://rarible.com/create/erc-721

Tuesday, December 8, 2020

Fixed: Opencart installation error linux: warning: fopen(system/storage) failed to open stream: Permission denied

Warning: fopen(/var/www/html/webocreation.com/system/storage/session/....): failed to open stream: Permission denied in /var/www/html/webocreation.com/system/library/session/file.php on line 29 Warning: flock() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 31 Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 33 Warning: fflush() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 35 Warning: flock() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 37 Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 39 


 These errors occurs because of the file permissions. In most of the forum, I found that they suggested to give full permission 0777 for the storage folder, this can be dangerous as per the security reason.
I have added the opencart upload folders and files at /var/www/html/webocreation
Following are the commands that I run:
cd /var/www/html/webocreation
Now I am in the folder, then I list the details of the files and folder:
ls -la


Change the ownership of the files and folders to the apache:apache 
sudo chown apache:apache -R . 
Let's make the all files secure by giving permissions of 0644 
find . -type f -exec chmod 0644 {} \; 
 Likewise, let's make the directory accessible for the apache 
find . -type d -exec chmod 0755 {} \;
 Now, let give access to read all files for the httpd server 
sudo chcon -t httpd_sys_content_t . -R 
 Allow write only to specific dirs 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/cache -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/download -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/logs -R
sudo chcon -t httpd_sys_rw_content_t ./system/storage/modification -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/session -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/upload -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/vendor -R
Once these commands are run then you are ready to install.


Then, open the browser and run the URL and you may get warning saying config.php file need to be writable, then for that run following two commands:
sudo chcon -t httpd_sys_rw_content_t ./config.php -R 
sudo chcon -t httpd_sys_rw_content_t ./admin/config.php -R

Friday, November 6, 2020

AWS ssh error: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

 I was ssh-ing to AWS EC2 instance and got the error Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

-----------------

sh-3.2# chmod 400 ec2-keypair.pem
sh-3.2# ssh ec2-suer@54.89.86.26 -i ec2-keypair.pem
The authenticity of host '54.89.86.26 (54.89.86.26)' can't be established.
ECDSA key fingerprint is SHA256:LoSxZtmn3jyNZikgW6U50z3owgBM/Gm/pnK0aJNmScQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '54.89.86.26' (ECDSA) to the list of known hosts.
ec2-suer@54.89.86.26: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
sh-3.2# ssh ec2-user@54.89.86.26 -i ./ec2-keypair.pem
       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|
https://aws.amazon.com/amazon-linux-2/
25 package(s) needed for security, out of 39 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-10-0-1-24 ~]$
-----------------

Solution: The solution is just adding the right path, for the key pair that you downloaded. I was in the right folder and I gave the path by just adding "./"

ssh ec2-user@54.89.86.26 -i ./ec2-keypair.pem