-2

Now i need install package memcached for PHP 7.3 on Ubuntu 18.4 I have server nginx, Yii2 framework and server block, but it is not work.
How can i do this ?

server {
    listen 80;
    server_name dev.advanced.ru;
    set $base_root /www/dev.advanced.ru;
    root $base_root;

    error_log /var/log/nginx/advanced.local.error.log warn;
    access_log /var/log/nginx/advanced.local.access.log main;
    charset UTF-8;
    index index.php index.html;

   location / {
    root $base_root/frontend/web;

    set $memcached_key "$uri?$args";
    memcached_pass 127.0.0.1:11211;
    error_page     404 502 504 = @fallback;

    try_files $uri $uri/ /frontend/web/index.php$is_args$args;

     location ~ ^/assets/.+\.php(/|$) {
        deny all;
        }
   }
   location /admin {
      alias $base_root/backend/web/;

   location = /admin {
      try_files $uri /backend/web/index.php$is_args$args;
     }
     try_files $uri $uri/ /backend/web/index.php$is_args$args;

     location ~ ^/admin/assets/.+\.php(/|$) {
        deny all;
     }
   }


  location ~ ^/.+\.php(/|$) {
  rewrite (?!^/((frontend|backend)/web|admin))^ /frontend/web$uri break;
  rewrite (?!^/backend/web)^/admin(/.+)$ /backend/web$1 break;

  fastcgi_pass 127.0.0.1:9000; # proxy requests to a TCP socket
  #fastcgi_pass unix:/var/run/php-fpm.sock; 
  fastcgi_split_path_info ^(.+\.php)(.*)$;
  include /etc/nginx/fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        try_files $fastcgi_script_name =404;
    }

    location ~ /\. {
        deny all;
    }

  location @fallback {
      proxy_pass     http://admin;
  }
}
3
  • Try sudo apt install php-memcached ?
    – Liso
    Apr 27, 2019 at 9:06
  • yes memcached instaled on sysytem. I don't understand, how include in php. I set pictures because i don't know how to write correctly. I have yii2 framework and i don't know how connect to memcached. i have server nginx (nginx.org/ru/docs/http/ngx_http_memcached_module.html) but it s no work, кead on the site tecadmin.net/install-memcached-with-php-on-ubuntu where see picture.
    – Sergey
    Apr 27, 2019 at 10:05
  • so you got it installed... that makes this question answered ;) if you need help with memcached and php and setting it up ask another question but it probably is best suited for stackoverflow.com as it will be a q about coding in php.
    – Rinzwind
    Apr 27, 2019 at 10:14

2 Answers 2

1

have you successfully installed PHP Memcached module on your system ? If no:

sudo apt-get install -y php-memcached 

Also, please remember to restart the Apache service once everything if installed/updated

sudo service apache2 restart
0
0
sudo apt-get install php7.1-dev (7.2, 7.3)

Requirements

sudo apt-get update 

sudo apt-get install build-essential pkg-config make git g++ gcc

Setup

sudo apt-get install libmemcached-dev libmsgpack-dev libmsgpackc2
clone and build php-memcached

git clone --depth 1 https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
phpize
./configure
make
sudo mv modules/ /usr/local/memcached/

Enable

echo 'extension=/usr/local/memcached/memcached.so' | \
sudo tee /etc/php/7.1/cli/conf.d/memcached.ini

echo 'extension=/usr/local/memcached/memcached.so' | \
sudo tee /etc/php/7.1/fpm/conf.d/memcached.ini

Verify

php -m | grep "memcached" && php-fpm7.1 -m | grep "memcached"
Restart PHP-FPM

sudo systemctl status php7.1-fpm.service

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .