PHP(外文名:PHP:Hypertext Preprocessor,中文名:"超文本預處理器")是一種通用開源腳本語言,語法吸取了C語言、Java和Perl的特色;主要適用於Web開發領域;執行編譯代碼以後,能夠達到加密和優化代碼運行,使代碼運行更快;php
配置環境 OS:CentOS 7.5 64bit PHP版本:7.2.8
hostname:php-1-1 ip:10.18.43.141
[root@php-1-1 ~]# systemctl stop firewalld [root@php-1-1 ~]# sed -ri '/^SELINUX=*/cSELINUX=disabled' /etc/selinux/config [root@php-1-1 ~]# setenforce 0 [root@php-1-1 ~]# mkdir -p /date/php
依賴環境庫下載mysql
[root@php-1-1 ~]# yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libxslt libxslt-devel
源碼包獲取及編譯linux
[root@php-1-1 ~]# wget -P /data/php/ http://cn2.php.net/distributions/php-7.2.8.tar.bz2 [root@php-1-1 ~]# cd /data/php/ [root@php-1-1 php]# tar xf php-7.2.8.tar.bz2
[root@php-1-1 php]# cd php-7.2.8/
[root@php-1-1 php-7.2.8]#./configure \
--prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-ldap \
--with-gettext \
--with-iconv-dir \
--with-jpeg-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \
--with-fpm-group=nginx \
--with-fpm-user=nginx
[root@php-1-1 php-7.2.8]# cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/ [root@php-1-1 php-7.2.8]# cp /usr/local/php/etc/{php-fpm.conf.default,php-fpm.conf} [root@php-1-1 php-7.2.8]# cp /usr/local/php/etc/php-fpm.d/www.conf{.default,} [root@php-1-1 php-7.2.8]# cp php.ini-production /usr/local/php/lib/php.ini
[root@php-1-1 php-7.2.8]# sed -i '/date.timezone =/s/.*/date.timezone = PRC/g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -n '869p' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/opcache]/azend_extension=opcache.so' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/;opcache.enable=1/s/;//g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/opcache.enable_cli=/s/.*/opcache.enable_cli=1/g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# echo "vm.nr_hugepages = 200" >> /etc/sysctl.conf [root@php-1-1 php-7.2.8]# sysctl -p [root@php-1-1 php-7.2.8]# sed -i '/;opcache.huge_code_pages/s/;//g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/opcache.memory_consumption=/s/.*/opcache.memory_consumption=512/g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/opcache.fast_shutdown=/s/.*/opcache.fast_shutdown=1/g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/opcache.validate_timestamps=/s/.*/opcache.validate_timestamps=1/g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/opcache.revalidate_freq=/s/.*/opcache.revalidate_freq=2/g' /usr/local/php/lib/php.ini [root@php-1-1 php-7.2.8]# sed -i '/listen = 127.0.0.1/s/=.*/= 0.0.0.0:9000/g' /usr/local/php/etc/php-fpm.d/www.conf
此段能夠編寫爲腳本nginx
#!/bin/sh sed -i '/date.timezone =/s/.*/date.timezone = PRC/g' /usr/local/php/lib/php.ini sed -n '869p' /usr/local/php/lib/php.ini sed -i '/opcache]/azend_extension=opcache.so' /usr/local/php/lib/php.ini sed -i '/;opcache.enable=1/s/;//g' /usr/local/php/lib/php.ini sed -i '/opcache.enable_cli=/s/.*/opcache.enable_cli=1/g' /usr/local/php/lib/php.ini echo "vm.nr_hugepages = 200" >> /etc/sysctl.conf sysctl -p sed -i '/;opcache.huge_code_pages/s/;//g' /usr/local/php/lib/php.ini sed -i '/opcache.memory_consumption=/s/.*/opcache.memory_consumption=512/g' /usr/local/php/lib/php.ini sed -i '/opcache.fast_shutdown=/s/.*/opcache.fast_shutdown=1/g' /usr/local/php/lib/php.ini sed -i '/opcache.validate_timestamps=/s/.*/opcache.validate_timestamps=1/g' /usr/local/php/lib/php.ini sed -i '/opcache.revalidate_freq=/s/.*/opcache.revalidate_freq=2/g' /usr/local/php/lib/php.ini sed -i '/listen = 127.0.0.1/s/=.*/= 0.0.0.0:9000/g' /usr/local/php/etc/php-fpm.d/www.conf
[root@php-1-1 php-7.2.8]# systemctl start php-fpm.service [root@php-1-1 php-7.2.8]# systemctl enable php-fpm.service