centos7源码安装php7

  • 创建用户:
    useradd -s /sbin/nologin -M nginx
  • 安装依赖:
    yum -y install libxml2 libxml2-develyum -y install curl-devel libjpeg-devel libpng-devel freetype-develyum -y install libicu-develyum -y install libxslt-develyum -y install openssl openssl-devel
  • 解压:
    tar -xzf php-7.2.13.tar.gz
  • 进入目录:
    cd php-7.2.13
  • 编译:
    ./configure --prefix=/data/php --with-config-file-path=/data/php/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --enable-maintainer-zts --with-xsl
  • 安装:
    make && make install
  • 添加环境变量:
    echo ‘export PATH=$PATH:/data/php/bin/‘ >> /etc/profileecho ‘export PATH=$PATH:/data/php/sbin/‘ >> /etc/profile. /etc/profile
  • 复制配置文件:
    cp php.ini-production /data/php/etc/php.ini
  • 编辑配置文件:
    vim /data/php/etc/php.ini
    [PHP]engine = Onshort_open_tag = Offprecision = 14output_buffering = 4096zlib.output_compression = Offimplicit_flush = Offunserialize_callback_func =serialize_precision = -1disable_functions =disable_classes =zend.enable_gc = Onexpose_php = Onmax_execution_time = 30max_input_time = 60memory_limit = 512Merror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICTdisplay_errors = ondisplay_startup_errors = Offlog_errors = Onlog_errors_max_len = 1024ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = Onhtml_errors = Onvariables_order = "GPCS"request_order = "GP"register_argc_argv = Offauto_globals_jit = Onpost_max_size = 8Mauto_prepend_file =auto_append_file =default_mimetype = "text/html"default_charset = "UTF-8"doc_root =user_dir =enable_dl = Offfile_uploads = Onupload_max_filesize = 20Mmax_file_uploads = 20allow_url_fopen = Onallow_url_include = Offdefault_socket_timeout = 99999999date.timezone = PRC[CLI Server]cli_server.color = On[Date][filter][iconv][intl][sqlite3][Pcre][Pdo][Pdo_mysql]pdo_mysql.cache_size = 2000pdo_mysql.default_socket=[Phar][mail function]SMTP = localhostsmtp_port = 25mail.add_x_header = Off[ODBC]odbc.allow_persistent = Onodbc.check_persistent = Onodbc.max_persistent = -1odbc.max_links = -1odbc.defaultlrl = 4096odbc.defaultbinmode = 1[Interbase]ibase.allow_persistent = 1ibase.max_persistent = -1ibase.max_links = -1ibase.timestampformat = "%Y-%m-%d %H:%M:%S"ibase.dateformat = "%Y-%m-%d"ibase.timeformat = "%H:%M:%S"[MySQLi]mysqli.max_persistent = -1mysqli.allow_persistent = Onmysqli.max_links = -1mysqli.cache_size = 2000mysqli.default_port = 3306mysqli.default_socket =mysqli.default_host =mysqli.default_user =mysqli.default_pw =mysqli.reconnect = Off[mysqlnd]mysqlnd.collect_statistics = Onmysqlnd.collect_memory_statistics = Off[OCI8][PostgreSQL]pgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0[bcmath]bcmath.scale = 0[browscap][Session]session.save_handler = filessession.use_strict_mode = 0session.use_cookies = 1session.use_only_cookies = 1session.name = PHPSESSIDsession.auto_start = 0session.cookie_lifetime = 0session.cookie_path = /session.cookie_domain =session.cookie_httponly =session.serialize_handler = phpsession.gc_probability = 1session.gc_divisor = 1000session.gc_maxlifetime = 1440session.referer_check =session.cache_limiter = nocachesession.cache_expire = 180session.use_trans_sid = 0session.sid_length = 26session.trans_sid_tags = "a=href,area=href,frame=src,form="session.sid_bits_per_character = 5[Assertion]zend.assertions = -1[COM][mbstring][gd][exif][Tidy]tidy.clean_output = Off[soap]soap.wsdl_cache_enabled=1soap.wsdl_cache_dir="/tmp"soap.wsdl_cache_ttl=86400soap.wsdl_cache_limit = 5[sysvshm][ldap]ldap.max_links = -1[dba][opcache][curl][openssl]
  • 创建php-fpm配置文件:
    vim /etc/php-fpm.conf
    [global]pid = /var/run/php-fpm.piderror_log = /var/log/php-fpm.loglog_level = notice[nginx]listen = 127.0.0.1:9000listen.backlog = -1listen.allowed_clients = 127.0.0.1listen.owner = nginxlisten.group = nginxlisten.mode = 0666user = nginxgroup = nginxpm = dynamicpm.max_children = 20pm.start_servers = 10pm.min_spare_servers = 10pm.max_spare_servers = 20request_terminate_timeout = 100request_slowlog_timeout = 0slowlog = var/log/slow.log
  • 启动php-fpm:
    /data/php/sbin/php-fpm --fpm-config /etc/php-fpm.conf
  • 停止php-fpm:
    pkill php-fpm
  • 相关文章