Nginx 1.9+PHP5.6 環境搭建

來源:互聯網
上載者:User

標籤:

1 PHP5.61 下載安裝包#wget http://mirrors.sohu.com/php/php-5.6.2.tar.gz#tar -zxf php-5.6.2?2 安裝php依賴的包??#yum install gcc gcc-c++ libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel3 安裝 (-prefix是安裝目錄,-with-mysql是mysql的安裝目錄,由於我是用yum裝的,所以不需要寫-with-mysql=****哪裡這樣子,其他參數自行百度。)#?./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem  --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysql --with-mysqli --with-pdo-mysql --with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl?#make#make install若上幾步都沒報錯的話就安裝成功,有報錯估計是少了點什麼,用百度查查後yum一下吧。?#cp php.ini-production /usr/local/php/etc/php.ini?當我們使用nginx還要把php-fpm.conf放到/usr/local/php/etc/裡頭cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf接下來我們還可能需要將php-fpm作為server服務?#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm(/usr/local/src/php-5.6.17是PHP安裝資料夾)??設定許可權,並添加服務#chmod +x /etc/init.d/php-fpm#chkconfig --add php-fpm以後可以使用如下命令管理php-fpm了#service php-fpm start#service php-fpm stop#service php-fpm restart#service php-fpm reloadmake: *** [sapi/cli/php] Error 1 解決辦法ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor‘:/usr/local/php/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open‘collect2: ld returned 1 exit statusmake: *** [sapi/cli/php] Error 1# vi Makefile 在安裝 PHP 到系統中時要是發生「undefined reference to libiconv_open‘」之類的錯誤資訊,那表示在「./configure 」沒抓好一些環境變數值。錯誤發生點在建立「-o sapi/cli/php」是出錯,沒給到要 link 的 iconv 函式庫參數。 解決方案1:編輯Makefile 大約77 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最後加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然後重新再次 make 即可。解決方案2:make ZEND_EXTRA_LIBS=‘-liconv‘ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/configure: error: mcrypt.h not found. Please reinstall libmcrypt. 解決辦法wget http://124.205.69.134/files/817400000026D1DF/soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz./configuremakemake installDon‘t know how to define struct flock on this system, set --enable-opcache=no 解決辦法vim /etc/ld.so.conf.d/local.conf     # 編輯庫檔案/usr/local/lib                       # 添加該行:wq                                  # 儲存退出ldconfig -v                          # 使之生效2 Nginx:wget http://nginx.org/download/nginx-1.9.7.tar.gztar -zxvf nginx-1.9.7.tar.gzcd nginx-1.9.7./configure --user=www --group=www --prefix=/usr/local/nginx-1.9.7 --with-http_stub_status_module make;make installcd ..vi /usr/local/nginx/conf/nginx.conf...        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;        }錯誤提示:./configure: error: the HTTP rewrite module requires the PCRE library.安裝pcre-devel解決問題yum -y install pcre-devel錯誤提示:./configure: error: the HTTP cache module requires md5 functionsfrom OpenSSL library.   You can either disable the module by using--without-http-cache option, or install the OpenSSL library into the system,or build the OpenSSL library statically from the source with nginx by using--with-http_ssl_module --with-openssl=<path> options. 解決辦法:yum -y install openssl openssl-devel3 環境變數:方法一:直接運行命令export PATH=$PATH:/usr/local/webserver/php/bin 和 export PATH=$PATH:/usr/local/webserver/mysql/bin使用這種方法,只會對當前會話有效,也就是說每當登出或登出系統以後,PATH 設定就會失效,只是臨時生效。方法二:執行vi ~/.bash_profile修改檔案中PATH一行,將/usr/local/webserver/php/bin 和 /usr/local/webserver/mysql/bin 加入到PATH=$PATH:$HOME/bin一行之後這種方法只對當前登入使用者生效方法三:修改/etc/profile檔案使其永久性生效,並對所有系統使用者生效,在檔案末尾加上如下兩行代碼PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/binexport PATH最後:執行 命令source /etc/profile或 執行點命令 ./profile使其修改生效,執行完可通過echo $PATH命令查看是否添加成功。 

 

Nginx 1.9+PHP5.6 環境搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.