Maison  >  Article  >  développement back-end  >  Explication détaillée du processus de compilation, d'installation et de configuration de php5.6.30 sous Linux (image et texte)

Explication détaillée du processus de compilation, d'installation et de configuration de php5.6.30 sous Linux (image et texte)

黄舟
黄舟original
2017-03-23 09:41:525666parcourir

1. Compilez et installez php5.6.30

Environnement d'installation :

# cat /etc/redhat-release 
CentOS release 6.8 (Final)
# /application/nginx/sbin/nginx -v
nginx version: nginx/1.6.3

Téléchargez le package d'installation php5.6.30

wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2

Décompressez

tar -xjf php-5.6.30.tar.bz2

Installez les packages de dépendances requis

# rpm -qa zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel 
freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel
# yum install zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel 
freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel -y

Installez la bibliothèque libiconv

wget 
tar zxf libiconv-1.14.tar.gz 
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install

Commencez l'installation de php

[root@darius php-5.6.30]#./configure --prefix=/application/php5.6.30 
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd 
--with-iconv-dir=/usr/local/libiconv --with-freetype-dir --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-fpm
   --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash
    --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags
     --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --without-pear 
     --disable-phar
 
#因为本机没有pear包,所以选择暂时跳过(--without-pear --disable-phar),等php安装后再补装go-pear

Explication détaillée du processus de compilation, dinstallation et de configuration de php5.6.30 sous Linux (image et texte)

make compile

[root@darius php-5.6.30]# make
...
...
...
Build complete.
Don't forget to run 'make test'.
 
[root@darius php-5.6.30]# make test

Le résultat du test make a signalé quelques problèmes, je les ai ignorés et j'ai continué l'installation

Explication détaillée du processus de compilation, dinstallation et de configuration de php5.6.30 sous Linux (image et texte)

Exécuter make installer

[root@darius php-5.6.30]# make install
Installing shared extensions:     /application/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary:        /application/php5.6.30/bin/
Installing PHP CLI man page:      /application/php5.6.30/php/man/man1/
Installing PHP FPM binary:        /application/php5.6.30/sbin/
Installing PHP FPM config:        /application/php5.6.30/etc/
Installing PHP FPM man page:      /application/php5.6.30/php/man/man8/
Installing PHP FPM status page:   /application/php5.6.30/php/php/fpm/
Installing PHP CGI binary:        /application/php5.6.30/bin/
Installing PHP CGI man page:      /application/php5.6.30/php/man/man1/
Installing build environment:     /application/php5.6.30/lib/php/build/
Installing header files:           /application/php5.6.30/include/php/
Installing helper programs:       /application/php5.6.30/bin/
  program: phpize
  program: php-config
Installing man pages:             /application/php5.6.30/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PDO headers:           /application/php5.6.30/include/php/ext/pdo/

2. Configurer php

cp php.ini-production /usr/local/php/etc/php.ini #复制php配置文件到安装目录rm -rf /etc/php.ini #删除系统自带配置文件
ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加软链接到 /etc目录
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #添加软连接到 /etc目录

Modifier php-fpm.conf

pid = run/php-fpm.pid  #取消前面的分号

Modifier php-ini.conf

Rechercher : disable_functions =

est modifié en :

disable_functions = 
passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,
ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,
disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,
posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,
posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,
posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,
posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

# Liste les fonctions qui peuvent être désactivées en PHP. Si certains programmes doivent utiliser cette fonction, c'est le cas. peut être supprimé et désactivé.

Trouvé : ;date.timezone =

modifié par :

date.timezone = PRC #设置时区

Trouvé : expose_php = On

modifié par :

expose_php = Off #禁止显示php版本的信息

Rechercher : short_open_tag = Off

Modifier en :

short_open_tag = ON #支持php短标签

Remarque : short_open_tag doit être activé Après l'avoir activé, vous pouvez utiliser PHP. balises de segment : () . De plus, ce n'est que si cette option est activée que vous pouvez utiliser = au lieu de Certains systèmes open source utilisent des balises courtes et une erreur sera signalée si elles ne sont pas activées.
Rechercher opcache.enable=0

Modifier en

Rechercher :;opcache.enable_cli=1 #php prend en charge la mise en cache des opcodes
opcache.enable=1 #php支持opcode缓存


Modifier en :

Ajouter la dernière ligne :
opcache.enable_cli=0

:wq #Save
zend_extension=opcache.so #开启opcode缓存功能
Quitter


Configurer nginx.conf

Créez un fichier de test :
location ~ \.php$ {
    root html/bbs;      #你网页根目录
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Démarrez php-fpm, redémarrez nginx et testez les résultats
[root@darius bbs]# cat index.php 
<?php phpinfo(); ?>
[root@darius bbs]# cat index.html 
bbs.html
[root@darius bbs]# pwd
/application/nginx/html/bbs

/application/php/sbin/php-fpm -c /application/php/etc/php.ini -y /application/php/etc/php-fpm.conf
/application/nginx/sbin/nginx -s reload

Explication détaillée du processus de compilation, dinstallation et de configuration de php5.6.30 sous Linux (image et texte)

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn