linux下nginx安裝php
阿新 • • 發佈:2017-08-12
啟動 end pen ini 找不到 令行 pdo 主配置文件 ref
把php安裝包上傳到linux的/usr/local/src
1.解壓
cd /usr/local/src tar zxvf php-5.6.9.tar.gz cd php-5.6.9
2.編譯安裝
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --enable-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 --with-freetype-dir --enable-calendar
錯誤1
configure: error: xml2-config not found. Please check your libxml2 installation. 配置:錯誤:xml2-config不見了。請檢查你的libxml2安裝。 解決: yum install libxml2 libxml2-devel -y
錯誤2
configure: error: Cannot find OpenSSL’s <evp.h> 配置:錯誤:找不到OpenSSL的< evp.h > 解決: yum install openssl openssl-devel -y
錯誤3
Configure: error: Please reinstall the BZip2 distribution 配置:錯誤:請重新安裝BZip2分布 解決: yum install bzip2 bzip2-devel -y
錯誤4
configure: error: jpeglib.h not found. 配置:錯誤:jpeglib。沒有找到。 解決: yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y
錯誤5
Configure: error: mcrypt.h not found. Please reinstall libmcrypt. 配置:錯誤:mcrypt。沒有找到。請重新安裝libmcrypt。 解決: 安裝epel-release源 yum install epel-release -y yum install libmcrypt-devel –y
最後最重要
make make install
3.拷貝PHP主配置文件
cp php.ini-production /usr/local/etc/php.ini
2、為php-fpm提供配置文件
cd /usr/local/php cp etc/php-fpm.conf.default etc/php-fpm.conf vim etc/php-fpm.conf
修改
user = www-data group = www-data
如果www-data用戶不存在,那麽先添加www-data用戶,命令行:
groupadd www-data useradd -g www-data www-data
配置文件修改
pm.max_children = 150 pm.start_servers = 8 pm.min_spare_servers = 5 pm.max_spare_servers = 10 pid = /usr/local/php/var/run/php-fpm.pid
3、啟動php-fpm
執行
/usr/local/php/sbin/php-fpm
使用如下命令來驗正(如果此命令輸出有中幾個php-fpm進程就說明啟動成功了):
ps aux | grep php-fpm
3、nginx和php-fpm整合
編輯/usr/local/nginx/nginx.conf
vim /usr/local/nginx/nginx.conf
修改如下:
紅框中“#”號去掉
紅框中“#”號去掉
添加紅框中內容
改成如下
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; }
重新載入nginx的配置文件:
/usr/loca/nginx/sbin/nginx -s reload
4、測試php文件
在/usr/local/nginx/html下創建index.php文件,輸入如下內容
<?php phpinfo(); ?>
5、瀏覽器訪問
訪問http://你的服務器ip/index.php,皆可以見到php信息了。
參考:http://www.cnblogs.com/flywind/p/6019631.html (php-fpm)
linux下nginx安裝php