應用root執行php-fpm

來源:互聯網
上載者:User
使用root執行php-fpm
php-fpm能對php的進程進行平滑重啟和停止、重新載入配置和二進位模組而不丟失請求,這些是我比較喜歡的。實在是厭惡了使用kill -9 來重啟php進程,因為決定裝上php-fpm先測試一下。
整個安裝過程完畢後,發現了兩個不太習慣的地方:
1、php-fpm.conf
2、不能使用root使用者來執行

設定檔還好,大致看看就明白意思了。再就是不能在root下執行,就我自己而言非常的不習慣,討厭使用者切來切去的。那隻能hack一把了
找到檔案 $src_path/sapi/cgi/fpm/fpm_unix.c裡邊有段代碼

#ifndef I_REALLY_WANT_ROOT_PHP
if (wp->set_uid == 0 || wp->set_gid == 0) {
zlog(ZLOG_STUFF, ZLOG_ERROR, "please specify user and group other than root, pool ‘%s’", wp->config->name);
return -1;
}
#endif
}
else { /* not root */
if (wp->config->user && *wp->config->user) {
zlog(ZLOG_STUFF, ZLOG_WARNING, "’user’ directive is ignored, pool ‘%s’", wp->config->name);
}
if (wp->config->group && *wp->config->group) {
zlog(ZLOG_STUFF, ZLOG_WARNING, "’group’ directive is ignored, pool ‘%s’", wp->config->name);
}
if (wp->config->chroot && *wp->config->chroot) {
zlog(ZLOG_STUFF, ZLOG_WARNING, "’chroot’ directive is ignored, pool ‘%s’", wp->config->name);
}

{ /* set up HOME and USER anyway */
struct passwd *pwd;

pwd = getpwuid(getuid());

if (pwd) {
wp->user = strdup(pwd->pw_name);
wp->home = strdup(pwd->pw_dir);
}
}
}

return 0;
}
php-fpm的作者想得很周全,料到有人不用ROOT心裡不爽!比如像我:) 我們要做的就是在此檔案頂部加上:
#define I_REALLY_WANT_ROOT_PHP
之後重新編譯即可~希望大家用的順手!

/data1/qiao.wang/software/php-5.2.14/sapi/cgi/fpm
需要重新編譯
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.