How to configure PHP to use memcached unix socket?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm in the process of upgrading from Ubuntu Server 16.04 to 18.04 and at the same time upgrading from PHP 5.6 to PHP 7.3.



In /etc/memcached.conf I added:



-s /tmp/memcached.sock
-a 666


When I restart the service, I see:



srw-rw-rw- 1 memcache memcache 0 Nov 13 03:44 /tmp/systemd-private-7fc3b73707084a93bcc6abd22001eb7e-memcached.service-oIF206/tmp/memcached.sock=


How can I configure PHP to know where the unix socket is?










share|improve this question























  • You have made tests right? Most of the sites written for php 5 breaks in php 7
    – Rui F Ribeiro
    20 hours ago











  • @RuiFRibeiro The sites on my server all use popular packages such as WordPress and MediaWiki. I haven't put any of them on the new server until I can verify everything is working, but I haven't even gotten that far as I discovered this issue with unix sockets for memcached.
    – Paul
    12 hours ago














up vote
0
down vote

favorite












I'm in the process of upgrading from Ubuntu Server 16.04 to 18.04 and at the same time upgrading from PHP 5.6 to PHP 7.3.



In /etc/memcached.conf I added:



-s /tmp/memcached.sock
-a 666


When I restart the service, I see:



srw-rw-rw- 1 memcache memcache 0 Nov 13 03:44 /tmp/systemd-private-7fc3b73707084a93bcc6abd22001eb7e-memcached.service-oIF206/tmp/memcached.sock=


How can I configure PHP to know where the unix socket is?










share|improve this question























  • You have made tests right? Most of the sites written for php 5 breaks in php 7
    – Rui F Ribeiro
    20 hours ago











  • @RuiFRibeiro The sites on my server all use popular packages such as WordPress and MediaWiki. I haven't put any of them on the new server until I can verify everything is working, but I haven't even gotten that far as I discovered this issue with unix sockets for memcached.
    – Paul
    12 hours ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm in the process of upgrading from Ubuntu Server 16.04 to 18.04 and at the same time upgrading from PHP 5.6 to PHP 7.3.



In /etc/memcached.conf I added:



-s /tmp/memcached.sock
-a 666


When I restart the service, I see:



srw-rw-rw- 1 memcache memcache 0 Nov 13 03:44 /tmp/systemd-private-7fc3b73707084a93bcc6abd22001eb7e-memcached.service-oIF206/tmp/memcached.sock=


How can I configure PHP to know where the unix socket is?










share|improve this question















I'm in the process of upgrading from Ubuntu Server 16.04 to 18.04 and at the same time upgrading from PHP 5.6 to PHP 7.3.



In /etc/memcached.conf I added:



-s /tmp/memcached.sock
-a 666


When I restart the service, I see:



srw-rw-rw- 1 memcache memcache 0 Nov 13 03:44 /tmp/systemd-private-7fc3b73707084a93bcc6abd22001eb7e-memcached.service-oIF206/tmp/memcached.sock=


How can I configure PHP to know where the unix socket is?







ubuntu systemd unix-sockets memcached






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 11 hours ago

























asked 22 hours ago









Paul

1138




1138











  • You have made tests right? Most of the sites written for php 5 breaks in php 7
    – Rui F Ribeiro
    20 hours ago











  • @RuiFRibeiro The sites on my server all use popular packages such as WordPress and MediaWiki. I haven't put any of them on the new server until I can verify everything is working, but I haven't even gotten that far as I discovered this issue with unix sockets for memcached.
    – Paul
    12 hours ago
















  • You have made tests right? Most of the sites written for php 5 breaks in php 7
    – Rui F Ribeiro
    20 hours ago











  • @RuiFRibeiro The sites on my server all use popular packages such as WordPress and MediaWiki. I haven't put any of them on the new server until I can verify everything is working, but I haven't even gotten that far as I discovered this issue with unix sockets for memcached.
    – Paul
    12 hours ago















You have made tests right? Most of the sites written for php 5 breaks in php 7
– Rui F Ribeiro
20 hours ago





You have made tests right? Most of the sites written for php 5 breaks in php 7
– Rui F Ribeiro
20 hours ago













@RuiFRibeiro The sites on my server all use popular packages such as WordPress and MediaWiki. I haven't put any of them on the new server until I can verify everything is working, but I haven't even gotten that far as I discovered this issue with unix sockets for memcached.
– Paul
12 hours ago




@RuiFRibeiro The sites on my server all use popular packages such as WordPress and MediaWiki. I haven't put any of them on the new server until I can verify everything is working, but I haven't even gotten that far as I discovered this issue with unix sockets for memcached.
– Paul
12 hours ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote













systemd has PrivateTmp=true for memcached.service



One way would be to override PrivateTmp, specifically for the memcached.service, i.e.



mkdir -p /etc/systemd/system/memcached.service.d
echo "[Service]" > /etc/systemd/system/memcached.service.d/override.conf
echo "PrivateTmp=false" >> /etc/systemd/system/memcached.service.d/override.conf
systemctl daemon-reload
systemctl restart memcached


That would change the memcached.service back to using /tmp, rather than /tmp/systemd-private-...



Assuming you want to use memcached for session handling; Once you've verified that /tmp/memcahced.sock exists with the correct permissions, in /etc/php.ini or /etc/php/conf.d/memcached.ini change session support.



[Session]
extension=memcached.so
session.save_handler="memcached"
session.save_path="/tmp/memcached.sock"


If it exists, comment out session.save_handler=files.



FWIW, if it's on the Internet, and given it's memcached which has been exploited a lot recently, disabling UDP and binding explicitly to 127.0.0.1 would be worth additional consideration, i.e. add these to your memcached options -U 0 -l 127.0.0.1






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481372%2fhow-to-configure-php-to-use-memcached-unix-socket%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    systemd has PrivateTmp=true for memcached.service



    One way would be to override PrivateTmp, specifically for the memcached.service, i.e.



    mkdir -p /etc/systemd/system/memcached.service.d
    echo "[Service]" > /etc/systemd/system/memcached.service.d/override.conf
    echo "PrivateTmp=false" >> /etc/systemd/system/memcached.service.d/override.conf
    systemctl daemon-reload
    systemctl restart memcached


    That would change the memcached.service back to using /tmp, rather than /tmp/systemd-private-...



    Assuming you want to use memcached for session handling; Once you've verified that /tmp/memcahced.sock exists with the correct permissions, in /etc/php.ini or /etc/php/conf.d/memcached.ini change session support.



    [Session]
    extension=memcached.so
    session.save_handler="memcached"
    session.save_path="/tmp/memcached.sock"


    If it exists, comment out session.save_handler=files.



    FWIW, if it's on the Internet, and given it's memcached which has been exploited a lot recently, disabling UDP and binding explicitly to 127.0.0.1 would be worth additional consideration, i.e. add these to your memcached options -U 0 -l 127.0.0.1






    share|improve this answer


























      up vote
      1
      down vote













      systemd has PrivateTmp=true for memcached.service



      One way would be to override PrivateTmp, specifically for the memcached.service, i.e.



      mkdir -p /etc/systemd/system/memcached.service.d
      echo "[Service]" > /etc/systemd/system/memcached.service.d/override.conf
      echo "PrivateTmp=false" >> /etc/systemd/system/memcached.service.d/override.conf
      systemctl daemon-reload
      systemctl restart memcached


      That would change the memcached.service back to using /tmp, rather than /tmp/systemd-private-...



      Assuming you want to use memcached for session handling; Once you've verified that /tmp/memcahced.sock exists with the correct permissions, in /etc/php.ini or /etc/php/conf.d/memcached.ini change session support.



      [Session]
      extension=memcached.so
      session.save_handler="memcached"
      session.save_path="/tmp/memcached.sock"


      If it exists, comment out session.save_handler=files.



      FWIW, if it's on the Internet, and given it's memcached which has been exploited a lot recently, disabling UDP and binding explicitly to 127.0.0.1 would be worth additional consideration, i.e. add these to your memcached options -U 0 -l 127.0.0.1






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        systemd has PrivateTmp=true for memcached.service



        One way would be to override PrivateTmp, specifically for the memcached.service, i.e.



        mkdir -p /etc/systemd/system/memcached.service.d
        echo "[Service]" > /etc/systemd/system/memcached.service.d/override.conf
        echo "PrivateTmp=false" >> /etc/systemd/system/memcached.service.d/override.conf
        systemctl daemon-reload
        systemctl restart memcached


        That would change the memcached.service back to using /tmp, rather than /tmp/systemd-private-...



        Assuming you want to use memcached for session handling; Once you've verified that /tmp/memcahced.sock exists with the correct permissions, in /etc/php.ini or /etc/php/conf.d/memcached.ini change session support.



        [Session]
        extension=memcached.so
        session.save_handler="memcached"
        session.save_path="/tmp/memcached.sock"


        If it exists, comment out session.save_handler=files.



        FWIW, if it's on the Internet, and given it's memcached which has been exploited a lot recently, disabling UDP and binding explicitly to 127.0.0.1 would be worth additional consideration, i.e. add these to your memcached options -U 0 -l 127.0.0.1






        share|improve this answer














        systemd has PrivateTmp=true for memcached.service



        One way would be to override PrivateTmp, specifically for the memcached.service, i.e.



        mkdir -p /etc/systemd/system/memcached.service.d
        echo "[Service]" > /etc/systemd/system/memcached.service.d/override.conf
        echo "PrivateTmp=false" >> /etc/systemd/system/memcached.service.d/override.conf
        systemctl daemon-reload
        systemctl restart memcached


        That would change the memcached.service back to using /tmp, rather than /tmp/systemd-private-...



        Assuming you want to use memcached for session handling; Once you've verified that /tmp/memcahced.sock exists with the correct permissions, in /etc/php.ini or /etc/php/conf.d/memcached.ini change session support.



        [Session]
        extension=memcached.so
        session.save_handler="memcached"
        session.save_path="/tmp/memcached.sock"


        If it exists, comment out session.save_handler=files.



        FWIW, if it's on the Internet, and given it's memcached which has been exploited a lot recently, disabling UDP and binding explicitly to 127.0.0.1 would be worth additional consideration, i.e. add these to your memcached options -U 0 -l 127.0.0.1







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 6 hours ago

























        answered 11 hours ago









        Joseph Tingiris

        1136




        1136



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481372%2fhow-to-configure-php-to-use-memcached-unix-socket%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?