1. 程式人生 > >LNMP構架-簡介與php安裝(與lamp不同)

LNMP構架-簡介與php安裝(與lamp不同)

LNMP php安裝 lnmp下php安裝

LNMP構架-簡介與php安裝(與lamp不同)

簡介:
LNMP=Linux+nginx+MySQL+php
和LAMP安裝PHP方法有差別,需要開啟php-fpm服務,需要添加php-fpm用戶

清空之前編譯過的php配置(安裝過php的)

cd /usr/local/src/php-5.6.30
make clean

下載和解壓

cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxvf php-5.6.30.tar.gz

添加用戶php-fpm

useradd -s /sbin/nologin php-fpm

指定配置

cd /usr/local/src/php-5.6.30
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl  --with-openssl

編譯與安裝

make && make install

復制php.ini文件

cp /usr/local/src/php-5.6.30/php.ini-production /usr/local/php-fpm/etc/php.ini

創建conf文件

cd /usr/local/php-fpm/etc/
vim php-fpm.conf
增加代碼
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
#listen = 127.0.0.1:9000
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
  rlimit_files = 1024

復制啟動腳本

cd /usr/local/src/php-5.6.30/
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

設置啟動腳本權限

chmod 755 /etc/init.d/php-fpm

設置開機啟動

chkconfig --add php-fpm
chkconfig --list

檢測與啟動

/usr/local/php-fpm/sbin/php-fpm -t
service php-fpm start
ps aux |grep php-fpm

錯誤1:

configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

搜索curl,相應的包yum list |grep -i curl
選著devel的包安裝
yum install -y libcurl-devel

LNMP構架-簡介與php安裝(與lamp不同)