hao0089 发表于 2018-12-12 10:40:34

LNMP构架

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
增加代码

pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log

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 /include/curl/
  搜索curl,相应的包yum list |grep -i curl
选着devel的包安装
yum install -y libcurl-devel



页: [1]
查看完整版本: LNMP构架