<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hasbi Hamza</title>
    <description>The latest articles on DEV Community by Hasbi Hamza (@hamzahasbi).</description>
    <link>https://dev.to/hamzahasbi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F57593%2F13181091-c116-4764-bfb2-1b81b2db50fb.jpeg</url>
      <title>DEV Community: Hasbi Hamza</title>
      <link>https://dev.to/hamzahasbi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hamzahasbi"/>
    <language>en</language>
    <item>
      <title>[Series] Drupal Env using docker &amp; nginx - 3!</title>
      <dc:creator>Hasbi Hamza</dc:creator>
      <pubDate>Wed, 06 Jan 2021 14:45:41 +0000</pubDate>
      <link>https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3-3o24</link>
      <guid>https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3-3o24</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-2-24i5"&gt;Previous article&lt;/a&gt; we were able to create our stack based on docker containers, and we discussed how to configure each container as a seperate service.&lt;br&gt;
In this last chapter we need to get our Drupal application up and running.&lt;/p&gt;

&lt;p&gt;First thing we need to understand how we can connect the containers over the network, previously in a the spoiler alert i've mentionned the use of the network key in our docker-composer which defines a bridge network that gives the containers the ability to communicate with each other using predefined IP adress &lt;a href="https://docs.docker.com/network/bridge/"&gt;Bridge NetWork&lt;/a&gt; (i've opted for the use of a bridge network with static IP mapping so we can easily understand how the communication is done) ...So each service will have a well defined IP adress by which we can target its container. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3WpPP4aX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9fezdxn30ci78dwpurtz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3WpPP4aX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9fezdxn30ci78dwpurtz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that being set now let's test our Drupal app :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- For drupal dev we need to set our database configuration in the appropriate settings.php :&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$databases['default']['default'] = array (
  'database' =&amp;gt; 'db_name',
  'username' =&amp;gt; 'root',
  'password' =&amp;gt; 'root_password_defined_in_mariadb_container',
  'prefix' =&amp;gt; '',
  'host' =&amp;gt; 'name_of_the_mariadb_service_OR_IPAdress',
  'port' =&amp;gt; '3306',
  'namespace' =&amp;gt; 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' =&amp;gt; 'mysql',
); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As a result let's visit the admin dashboard to check if  the configuration is working :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--29SK7sml--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9xyupquuhsxena4n8sru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--29SK7sml--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9xyupquuhsxena4n8sru.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Next thing we'll set the cache system to use our Memcache container :&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Memcache
$settings['memcache']['servers'] = ['IPADRESS:11211' =&amp;gt; 'default'];
$settings['memcache']['bins'] = ['default' =&amp;gt; 'default'];
$settings['memcache']['key_prefix'] = 'choose_your_key_prefix';

// Set default cache storage as Memcache and excludes database connection for cache
$settings['cache']['default'] = 'cache.backend.memcache';
$settings['cache']['bins']['render'] = 'cache.backend.memcache';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
// Enables to display total hits and misses
$settings['memcache_storage']['debug'] = TRUE;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now let's check if Memcached service is working and well connected to Drupal .&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H9l1Fk96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6004zrqrwygjbei9amzz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H9l1Fk96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6004zrqrwygjbei9amzz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2NYUAJsA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/71yxfwszrm4zx0vcyzj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2NYUAJsA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/71yxfwszrm4zx0vcyzj6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Now we are all set with our Docker environment !&lt;/em&gt;&lt;/strong&gt; &lt;br&gt;
All the services are up and running i've added a Bonus script to start the stack automatically you just need to have Docker and docker-compose installed and TADAAA!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code can be found &lt;a href="https://github.com/hamzahasbi/docker-nginx"&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>docker</category>
      <category>nginx</category>
      <category>drupal</category>
    </item>
    <item>
      <title>[Series] Drupal Env using docker &amp; nginx - 2!</title>
      <dc:creator>Hasbi Hamza</dc:creator>
      <pubDate>Sat, 28 Nov 2020 13:14:03 +0000</pubDate>
      <link>https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-2-24i5</link>
      <guid>https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-2-24i5</guid>
      <description>&lt;p&gt;So &lt;a href="https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3oen"&gt;previously&lt;/a&gt; we discussed how we can set up a quick web server based on nginx &amp;amp; php-fpm for our drupal stack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z9mXLWu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zbmmqj6jim4kahfvbb37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z9mXLWu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zbmmqj6jim4kahfvbb37.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
As for now, we'll &lt;strong&gt;dockerize&lt;/strong&gt; the environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;So basic docker knowledge is a must to go further.&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ESUejwCh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gpiy7gmb2u8pm9ek4zd7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ESUejwCh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gpiy7gmb2u8pm9ek4zd7.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
First thing we'll need a &lt;a href="https://docs.docker.com/compose/"&gt;docker-compose&lt;/a&gt; file where we will be grouping or our needed services for our case :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;nginx&lt;/li&gt;
&lt;li&gt;php-fpm&lt;/li&gt;
&lt;li&gt;mariadb&lt;/li&gt;
&lt;li&gt;memcached (optional)&lt;/li&gt;
&lt;li&gt;redis (optional)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In each one of our containers we'll provide the config files needed (same files from the &lt;a href="https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3oen"&gt;first tutorial&lt;/a&gt;), those files will be copied directly into our containers.&lt;/p&gt;

&lt;p&gt;Next thing we will expose &amp;amp; map each service with the port of our choice on the host machine and we'll mount the intended codebase project as a volume in the nginx &amp;amp; php-fpm containers so that we can access it within the container, moreover we need persistent database schemas so we will have to add an external volume where we will store data from Mariadb container.&lt;/p&gt;

&lt;p&gt;Furthermore, we can add dependencies for the mandatory services (webserver - database and php-fpm) by linking those we make sure that the webserver would never start before having an accessible php container &amp;amp; mariadb .&lt;/p&gt;

&lt;p&gt;Now that i covered the configuration files, let's move to the used  docker images .&lt;br&gt;
For &lt;a href="https://hub.docker.com/_/mariadb"&gt;mariadb&lt;/a&gt; i've just used the official image from docker-hub because i don't need any prior on build config ....&lt;br&gt;
As for the php image i've created a custom image with some drupal  tweaks that i find usefull such as adding some packages (gd imagck apcu memcached redis composer) and drush (any drupal dev would find it usefull ).&lt;br&gt;
In addition to that i'm using a slitely custom nginx image mainly for 2 reasons :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Brotli&lt;/em&gt;&lt;/strong&gt; compression support .&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;User setting&lt;/em&gt;&lt;/strong&gt; (for both php &amp;amp; nginx images we need to have a user to own the project root).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note that changing the config files of nginx can be tricky so to play it safe here i've managed to do it on build time in the Dockerfile.&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
So finaly we got the following docker-compose file&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3"
services:
  web:
    build: ./web
    restart: always
    ports:
      - "80:80"
      - "443:443"
    links:
     - php
     - database
    networks:
      vpcbr:
        ipv4_address: 172.28.0.101
    environment:
      - NGINX_PORT=80
    volumes:
      - ../:/var/www/html
  php:
    build: ./php
    restart: always
    container_name: d8_php
    links:
      - database
    ports:
      - "9000:9000"
    volumes:
      - ../:/var/www/html
    networks:
      vpcbr:
        ipv4_address: 172.28.0.102

  database:
    image: mariadb:latest
    restart: always
    hostname: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
    networks:
      vpcbr:
        ipv4_address: 172.28.0.103

    volumes:
      - "./db:/var/lib/mysql"
      - "./database:/etc/mysql/conf.d"
    ports:
      - "3307:3306"
  redis:
    image: redis
    ports:
      - "6379:6379"
    networks:
      vpcbr:
        ipv4_address: 172.28.0.104
  memcached:
    image: memcached
    ports:
      - "11211:11211"
    networks:
      vpcbr:
        ipv4_address: 172.28.0.105
networks:
  vpcbr:
    driver: bridge
    ipam:
      config:
        - subnet: 172.28.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next thing we'll discuss the Drupal config and how we can link all the containers together.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code can be found &lt;a href="https://github.com/hamzahasbi/docker-nginx"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Part 1 : &lt;a href="https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3oen"&gt;link&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Part 2 : &lt;a href="https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3-3o24"&gt;link&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uKX4SPS5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3iausbk6a2ewuzkrpf2i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uKX4SPS5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3iausbk6a2ewuzkrpf2i.jpg" alt="Alt Text"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(SPOILER : Notice the use of the network key in the docker compose file :D)&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>php</category>
      <category>docker</category>
      <category>nginx</category>
      <category>drupal</category>
    </item>
    <item>
      <title>[Series] Drupal Env using docker &amp; nginx!</title>
      <dc:creator>Hasbi Hamza</dc:creator>
      <pubDate>Sun, 15 Nov 2020 20:43:43 +0000</pubDate>
      <link>https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3oen</link>
      <guid>https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-3oen</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GHHeWDzh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sm9qejlpv8py4a9asn9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GHHeWDzh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sm9qejlpv8py4a9asn9g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you are using php as a backend technology you will always hear people talking about lamp stack (linux - apache - mysql - php) for the web envirnoment.&lt;/p&gt;

&lt;p&gt;There is a lot of tools that can give you a boostraped version of that stack depending on your OS: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.apachefriends.org/fr/index.html"&gt;XAMPP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.wampserver.com/"&gt;WAMP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mamp.info/en/"&gt;MAMP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.acquia.com/downloads"&gt;Acquia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those tools comes generally preconfigured so that you can start developing on the fly.&lt;br&gt;
Those kind of tools are not meant to be present in your production servers which means that you need to have at least some basic knowledge on how to setup your own stack or at least some&lt;br&gt;
basic configuration tricks.&lt;/p&gt;

&lt;p&gt;When you wanna host a php web app , the server you'll be using is generally a machine (virtual for cloud based services) with either Apache or nginx as a web server.&lt;/p&gt;

&lt;p&gt;In this series of articles I will be covering a basic setup for a drupal 8 stack using nginx - php-fpm - mariadb for docker. &lt;br&gt;
First of all ,we'll need some configuration to give to nginx to let him know that we are using it as web server not proxy server , we use generally *.conf files to do that :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user www-data;
pid /run/nginx.pid;
worker_processes auto;

events {
        worker_connections 768;
        # multi_accept on;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        types_hash_max_size 2048;
        server_tokens off;


    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_connect_timeout 1200s;
    proxy_send_timeout 1200s;
    proxy_read_timeout 1200s;
    proxy_busy_buffers_size 256k;
    gzip on;
    gzip_disable "msie6";

    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    brotli on;
    brotli_static on;
    brotli_buffers 32 8k;
    brotli_comp_level 7;
    brotli_types *;

    include /etc/nginx/conf.d/*.conf;

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;http&lt;/strong&gt; directive is the most important in this config you can always play with the value for buffer size etc ...Note that for this case my webserver is configured to serve gzip and brotli compressed assets you can learn about web server compression here : &lt;em&gt;&lt;a href="https://www.machmetrics.com/speed-blog/gzip-vs-brotli-best-browser-compression/"&gt;Gzip and Brotli compression&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Furthermore we need to add the site's conf ... It's generally where you put domain name and other site's specific conf like browser cache, files access, redirections...etc.&lt;br&gt;
This file will have the project's specific configuration but note that some directives never change :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;upstream fastcgi_backend {
server php:9000;
keepalive 8;
}
server {
listen 80;
server_name domain.dev *.dev;
root /var/www/html/;

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# Very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
    deny all;
}

location ~ \..*/.*\.php$ {
    return 403;
}

location ~ ^/sites/.*/private/ {
    return 403;
}

location / {
    # try_files $uri @rewrite; # For Drupal &amp;lt;= 6
    gzip_static on;
    proxy_cache cache;
    proxy_cache_revalidate on;
    proxy_cache_min_uses 3;
    proxy_cache_valid 200 1s;
    proxy_cache_use_stale updating error timeout;
    proxy_cache_background_update on;
    proxy_cache_lock on;
    try_files $uri /index.php?$query_string; # For Drupal &amp;gt;= 7
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We can easily spot the main difference between nginx and apache as webservers :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_V2-hdZh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t9vvklawykxnzt1q69mo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_V2-hdZh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t9vvklawykxnzt1q69mo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Apache can execute your php scripts by activating modphp which is an apache extension but in nginx's case you are forced to use php-fpm (fast cgi) to run your php scripts and&lt;br&gt;
pass it to the server which will only render the execution results to the browser.&lt;/strong&gt;&lt;br&gt;
How would he do that ? &lt;br&gt;
Following this directive :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location ~ '\.php$|^/update.php' {
    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
    # Security note: If you're running a version of PHP older than the
    # latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
    # See http://serverfault.com/q/627903/94922 for details.
    include fastcgi_params;
    # Block httpoxy attacks. See https://httpoxy.org/.
    fastcgi_param HTTP_PROXY "";
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_intercept_errors on;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 64k;
    fastcgi_send_timeout 1200s;
    fastcgi_read_timeout 1200s;
    # PHP 5 socket location.
    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    # PHP 7 socket location.
    # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

    fastcgi_pass fastcgi_backend;
    fastcgi_keep_conn on;
    # fastcgi_pass fpm:9000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we've covered the nginx configuration with php-fpm , next we will be setting up docker containers to run our stack (nginx - php-fpm - mariadb).&lt;/p&gt;

&lt;p&gt;EDIT : &lt;a href="https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-2-24i5"&gt;Part 2&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>php</category>
      <category>docker</category>
      <category>nginx</category>
      <category>drupal</category>
    </item>
    <item>
      <title>Problem Analysis</title>
      <dc:creator>Hasbi Hamza</dc:creator>
      <pubDate>Wed, 30 Sep 2020 23:35:43 +0000</pubDate>
      <link>https://dev.to/hamzahasbi/problem-analysis-3he3</link>
      <guid>https://dev.to/hamzahasbi/problem-analysis-3he3</guid>
      <description>&lt;h1&gt;
  
  
  BerSU Ball
&lt;/h1&gt;

&lt;p&gt;Statement : &lt;a href="https://codeforces.com/problemset/problem/489/B"&gt;Ball&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Editorial :
&lt;/h3&gt;

&lt;p&gt;Let’s quickly analyze the problem statement ….&lt;br&gt;
we have n boy and m girl and we need to match them following a certain constraint :&lt;br&gt;
. For each boy, we know his dancing skills. Similarly, for each girl we know her dancing skills and we need to find the number of pairs such that each pair must differ by at most one.&lt;br&gt;
there is about 1001 way to solve the problem following several approaches for example :&lt;br&gt;
. &lt;strong&gt;Maximum bipartie matching&lt;/strong&gt;&lt;br&gt;
. &lt;strong&gt;Dynamic Programming&lt;/strong&gt;&lt;br&gt;
. &lt;strong&gt;Greedy algorithm&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;I’ll be covering a greedy approach in this editorial hopefully i’ll get some comments to discuss another solution.&lt;br&gt;
We can assume that the maximal number of pairs is equal to min(n,m) …&lt;br&gt;
First let’s sort the arrays of skills and then we can search for pairs such that the absolute difference between a boy’s skill and a girl’s &amp;lt;=1, to do that we need two for loops and for each skill in the first array we take the minimum possible skill in the second array and then we mark the index of the second array as used and break the loop we repeat this min(n,m) time.&lt;br&gt;
In Brief the time complexity of my solution is O(n*m) per test case .&lt;br&gt;
Problem’s link: &lt;a href="https://codeforces.com/problemset/problem/489/B"&gt;Ball&lt;/a&gt;&lt;br&gt;
Code : &lt;a href="https://github.com/hamzahasbi/Editorials/blob/master/BerSU%20Ball.cpp"&gt;Solution&lt;/a&gt;&lt;br&gt;
Comments and feedback are welcome&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thank you ;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>competitiveprogramming</category>
      <category>greedy</category>
      <category>problemsolving</category>
    </item>
    <item>
      <title>Interactive problems</title>
      <dc:creator>Hasbi Hamza</dc:creator>
      <pubDate>Wed, 30 Sep 2020 23:26:21 +0000</pubDate>
      <link>https://dev.to/hamzahasbi/interactive-problems-4c1e</link>
      <guid>https://dev.to/hamzahasbi/interactive-problems-4c1e</guid>
      <description>&lt;h1&gt;
  
  
  About "Interactive problems"
&lt;/h1&gt;

&lt;p&gt;In this kind of problems, the input given may not be predetermined but is built specifically for your solution.Jury writes a special "Interactor" ,such that its output is redirected to the input of your solution, and the output of your program is sent to interactor's input.&lt;br&gt;
So to sum up interactive problems gives input depending on your solution's output …before handling an exemple you must pay attention to flush the output just to avoid some bugs caused by the buffer.&lt;br&gt;
To flush you can use (just after printing an integer and end-of-line):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fflush(stdout) in C++;
System.out.flush() in Java;
stdout.flush() in Python;
flush(output) in Pascal;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;See the documentation for other languages.&lt;br&gt;
Now let's move forward to the example :&lt;br&gt;
&lt;a href="https://www.codeforces.com/problemset/problem/680/C"&gt;Bear and prime 100&lt;/a&gt;   &lt;/p&gt;

&lt;h3&gt;
  
  
  Editorial
&lt;/h3&gt;

&lt;p&gt;As mentioned in the problem statement we have to ask at most 20 queries to guess if the secret number is composite or prime as we all know a prime number is divisible only by 1 and itself so we can check in each query if we have a yes "which means the hidden number is divisible by the number in the output" we increment a count if our count is equal to 2 we break and we are sure that the hidden number is composite ,but we must pay attention that we don't output 1 (all number are divisible by 1) ….We have just finished a part of the solution we still have some special cases to handle , if we have a perfect square for example 25 is divisible by 1 and 5 as i mentioned we can't output 1 so we will have only the number 5 as a query because we have a maximum of 20 query starting by 2 in this case our count will be equal to 1 and then we will consider 25 as a prime number which is false ….&lt;br&gt;
To avoid this wrong answer we can simply store all the prime numbers &amp;lt; 50 in a vector and also the perfect square numbers so our vector will contain {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,4,9,25,49} (19 number) so we will have at most 19 queries to ask and with that vector we handled all the special cases and of course if the count of divisors is equal to 2 we still have to break ….And that's it , the problem is not that hard and is fun to solve and i hope you enjoyed the topic&lt;br&gt;
Problem's link: &lt;a href="https://www.codeforces.com/problemset/problem/680/C"&gt;Bear and prime 100&lt;/a&gt;&lt;br&gt;
Code : &lt;a href="https://github.com/hamzahasbi/Editorials/blob/master/Bear%20and%20Prime%20100.cpp"&gt;Solution&lt;/a&gt;&lt;br&gt;
Comments and feedback are welcome&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thank you ;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>competitiveprogramming</category>
      <category>problemsolving</category>
    </item>
  </channel>
</rss>
