<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ### nginx php-fpm安裝配置 nginx本身不能處理PHP,它只是個web服務器,當接收到請求后,如果是php請求,則發給php解釋器處理,并把結果返回給客戶端。 nginx一般是把請求發fastcgi管理進程處理,fascgi管理進程選擇cgi子進程處理結果并返回被nginx 本文以php-fpm為例介紹如何使nginx支持PHP 一、編譯安裝php-fpm **什么是PHP-FPM** PHP-FPM是一個PHP FastCGI管理器,是只用于PHP的,可以在 http://php-fpm.org/download下載得到. PHP-FPM其實是PHP源代碼的一個補丁,旨在將FastCGI進程管理整合進PHP包中。必須將它patch到你的PHP源代碼中,在編譯安裝PHP后才可以使用。 **新版PHP已經集成php-fpm了,不再是第三方的包了,推薦使用**。PHP-FPM提供了更好的PHP進程管理方式,可以有效控制內存和進程、可以平滑重載PHP配置,比spawn-fcgi具有更多優點,所以被PHP官方收錄了。在./configure的時候帶 –enable-fpm參數即可開啟PHP-FPM,其它參數都是配置php的,具體選項含義可以[查看這里](http://www.php.net/manual/en/configure.about.php)。 安裝前準備 centos下執行 ~~~ yum -y install gcc automake autoconf libtool make yum -y install gcc gcc-c++ glibc yum -y install libmcrypt-devel mhash-devel libxslt-devel \ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \ zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \ ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \ krb5 krb5-devel libidn libidn-devel openssl openssl-devel ~~~ **新版php-fpm安裝(推薦安裝方式)** ~~~ wget http://cn2.php.net/distributions/php-5.4.7.tar.gz tar zvxf php-5.4.7.tar.gz cd php-5.4.7 ./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \ --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \ --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \ --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \ --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \ --with-gd --with-jpeg-dir make all install ~~~ ~~**舊版手動打補丁php-fpm安裝(舊版程序已經沒有了,大家新版的吧,這里做個展示)** wget http://cn2.php.net/get/php-5.2.17.tar.gz wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz tar zvxf php-5.2.17.tar.gz gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1 cd php-5.2.17 ./configure --prefix=/usr/local/php -with-config-file-path=/usr/local/php/etc\ -with-mysql=/usr/local/mysql\ -with-mysqli=/usr/local/mysql/bin/mysql_config -with-openssl -enable-fpm -enable-mbstring\ -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib-dir -with-libxml-dir=/usr -enable-xml\ -with-mhash -with-mcrypt -enable-pcntl -enable-sockets -with-bz2 -with-curl -with-curlwrappers\ -enable-mbregex -with-gd -enable-gd-native-ttf -enable-zip -enable-soap -with-iconv -enable-bcmath\ -enable-shmop -enable-sysvsem -enable-inline-optimization -with-ldap -with-ldap-sasl -enable-pdo\ -with-pdo-mysql make all install~~ 以上兩種方式都可以安裝php-fpm,安裝后內容放在/usr/local/php目錄下 [![](http://www.nginx.cn/wp-content/uploads/2012/09/1-300x41.png "1")](http://www.nginx.cn/wp-content/uploads/2012/09/1.png) 以上就完成了php-fpm的安裝。 下面是對php-fpm運行用戶進行設置 ~~~ cd /usr/local/php cp etc/php-fpm.conf.default etc/php-fpm.conf vi etc/php-fpm.conf ~~~ 修改 ``` user = www-data group = www-data ``` 如果www-data用戶不存在,那么先添加www-data用戶 ``` groupadd www-data useradd -g www-data www-data ``` 二、編譯安裝nginx 然后按照[http://www.nginx.cn/install](http://www.nginx.cn/install) 安裝nginx 三、修改nginx配置文件以支持php-fpm nginx安裝完成后,修改nginx配置文件為,[nginx.conf](http://www.nginx.cn/wp-content/uploads/2012/09/nginx.conf_.txt) 其中server段增加如下配置,注意標紅內容配置,否則會出現No input file specified.錯誤 ``` # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } ``` 四、創建測試php文件 創建php文件 在/usr/local/nginx/html下創建index.php文件,輸入如下內容 ~~~ <?php echo phpinfo(); ?> ~~~ 五、啟動服務 啟動php-fpm和nginx ~~~ /usr/local/php/sbin/php-fpm #手動打補丁的啟動方式/usr/local/php/sbin/php-fpm start sudo /usr/local/nginx/nginx ~~~ php-fpm關閉重啟見文章結尾 六、瀏覽器訪問 訪問http://你的服務器ip/index.php,皆可以見到php信息了。 [![](http://www.nginx.cn/wp-content/uploads/2012/09/2-300x120.png "2")](http://www.nginx.cn/wp-content/uploads/2012/09/2.png) **安裝php-fpm時可能遇到的錯誤:** 1. **php configure時出錯** configure: error: XML configuration could not be found ~~~ apt-get install libxml2 libxml2-dev (ubuntu下) yum -y install libxml2 libxml2-devel(centos下) ~~~ 2. **Please reinstall the BZip2 distribution** ~~~ wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz tar -zxvf bzip2-1.0.5.tar.gz cd bzip2-1.0.5 make make install ~~~ 3. **php的配置文件中有一行--with-mysql=/usr**。 安裝的時候提示: ``` configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore. ``` 這是由于安裝mysql時沒有安裝mysql頭文件,或者是路徑指定不正確,php找不到mysql的頭文件引起的錯誤提示。 解決方法。 (1.) 查看你的系統有沒有安裝mysql header ``` find / -name mysql.h ``` 如果有。請指定--with-mysql=/跟你的正常路徑。 如果沒有。請看下一步。 (2.)redhat安裝 ``` rpm -ivh MySQL-devel-4.1.12-1.i386.rpm ``` (3.)ubuntu安裝 ``` apt-get install libmysqlclient15-dev ``` (4.)最后一步php的配置選項添加--with-mysql=/usr即可! 4.**No input file specified.** ``` location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } ``` 5. **如果php configure時缺庫,可以先安裝庫(ubuntu下)** ``` sudo apt-get install make bison flex gcc patch autoconf subversion locate sudo apt-get install libxml2-dev libbz2-dev libpcre3-dev libssl-dev zlib1g-dev libmcrypt-dev libmhash-dev libmhash2 libcurl4-openssl-dev libpq-dev libpq5 libsyck0-dev ``` 6. **mcrypt.h not found. Please reinstall libmcrypt** ``` apt-get install libmcrypt-dev ``` 或者 ``` cd /usr/local/src wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz tar -zxvf libmcrypt-2.5.8.tar.gz cd /usr/local/src/libmcrypt-2.5.8 ./configure --prefix=/usr/local make make install ``` 7. **php-fpm 5.4.7 如何關閉 重啟?** php 5.4.7 下的php-fpm 不再支持 php-fpm 以前具有的 /usr/local/php/sbin/php-fpm (start|stop|reload)等命令,需要使用信號控制: master進程可以理解以下信號 INT, TERM 立刻終止 QUIT 平滑終止 USR1 重新打開日志文件 USR2 平滑重載所有worker進程并重新載入配置和二進制模塊 示例: php-fpm 關閉: ``` kill -INT `cat /usr/local/php/var/run/php-fpm.pid` ``` php-fpm 重啟: ``` kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` ``` 查看php-fpm進程數: ``` ps aux | grep -c php-fpm ``` 8.命令行下執行php,提示找不到命令 ``` -bash: /usr/bin/php: No such file or directory vi /etc/profile ``` 在文件底部增加一行配置 ``` export PATH=/usr/local/php/bin:$PATH ``` 保存退出 ``` source /etc/profile ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看