1.安装php 这是单独配置php ,配合nginx来完成web页面给apache配置需要添加apache的安装目录
官网 下载地址 http://www.php.net/downloads.php 找自己要版本
找合适的镜像下载,我用的是最下面的 php.net镜像
1.下载
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://php.net/distributions/php-7.2.11.tar.gz
2解压 tar xvf php-7.2.11.tar.gz
3. 预编译
进入目录 [root@localhost src]# cd
php-7.2.11
创建php-fpm用户,并禁止登录;
[root@localhost php-7.2.11]# useradd -s /sbin/nologin php-fpm
安装插件包7.2的
yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel epel-release curl-devel postgresql-devel aspell-devel net-snmp-devel unixODBC-devel libicu-devel libc-client-devel libXpm-devel libvpx-devel enchant-devel openldap openldap-devel db4-devel gmp-devel
预编译
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mcrypt --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd
php7移除了 mysql 扩展,php7仅能是用 mysqli 和 pdo_mysql。
出现 Thank you for using PHP. 表示成功
编译 make && make install
[root@147 php-7.2.11]# echo $?
0
0表示上一步执行成功
配置文件
[root@147 php-7.2.11]# cp php.ini-production /usr/local/php7/etc/php.ini
[root@147 php-7.2.11]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@147 php-7.2.11]# cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@147 php-7.2.11]# chmod +x /etc/init.d/php-fpm
[root@147 php-7.2.11]# chkconfig --add php-fpm
[root@147 php-7.2.11]# chkconfig php-fpm on
[root@147 php-7.2.11]# service php-fpm start
如果报错是因为配置的问题 把/usr/local/php7/etc/php-fpm.d/www.conf.default 改为 www.conf 就可以了
[root@147 php-7.2.11] mv /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
然后在启动 service php-fpm start
安装成功
/**********************配置参考******************************************/
设置别名 只能自己当前用户用的(设置 /etc/profile 这是全局的)
vim /root/.bash_profile 添加php7的安装目录就可以
也可以全局使用 vim /
也可以 /etc/init.d/php7-fpm start
启动:
/usr/local/php7/sbin/php-fpm
立刻终止
kill -INT `cat /usr/local/php7/var/run/php-fpm.pid`
kill -TERM `cat /usr/local/php7/var/run/php-fpm.pid`
killall php-fpm
平滑终止
kill -QUIT `cat /usr/local/php7/var/run/php-fpm.pid`
平滑重启
kill -USR2 `cat /usr/local/php7/var/run/php-fpm.pid`
[global]
pid = /usr/local/php7/var/run/php-fpm.pid
error_log = /usr/local/php7/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php7-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1:9001 允许的客户端
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 40
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 40
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log