Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of compiling and installing php7.2 with Centos7 Source Code

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the method of compiling and installing Centos7 source code, which is very detailed and has certain reference value. Friends who are interested must finish reading it.

Introduction:

I have long heard about the speed and performance of php7, which is faster than any version of the php5 series. It is recommended to try it first. If you are upgrading or new installation, then you first need to consider whether php7 and the program are compatible, if the program is based on php5, then you need to consider whether php7 is suitable for your current production environment, today I will practice and install it for production.

Install the php dependency package first, otherwise there will be various errors in the process of compiling and installing php7. After the installation is complete, you can move on to the next step.

Install the expansion pack and update the system kernel:

$yum install epel-release-y $yum update

Install php dependency components (including Nginx dependencies):

The copy code is as follows:

$yum-y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel

Create users and groups and download the php installation package to extract:

$cd / tmp$ groupadd www$ useradd-g www www$ wget http://am1.php.net/distributions/php-7.2.1.tar.gz$ tar xvf php-7.2.1.tar.gz$ cd php-7.2.1

Set the variable and start source compilation:

Cp-frp / usr/lib64/libldap* / usr/lib/$. / configure-- prefix=/usr/local/php\-- with-config-file-path=/usr/local/php/etc\-- enable-fpm\-- with-fpm-user=www\-- with-fpm-group=www\-- enable-mysqlnd\-- with-mysqli=mysqlnd\-- with-pdo-mysql=mysqlnd\-- enable-mysqlnd-compression-support\-- with-iconv-dir\-- with-freetype-dir\-- with -jpeg-dir\-- with-png-dir\-- with-zlib\-- with-libxml-dir\-- enable-xml\-- disable-rpath\-- enable-bcmath\-- enable-shmop\-- enable-sysvsem\-- enable-inline-optimization\-- with-curl\-- enable-mbregex\-enable-mbstring\-enable-intl\-- with-mcrypt\-- with-libmbfl\-- enable-ftp\-- with-gd\-- enable-gd-jis -conv\-- enable-gd-native-ttf\-- with-openssl\-- with-mhash\-- enable-pcntl\-- enable-sockets\-- with-xmlrpc\-- enable-zip\-- enable-soap\-- with-gettext\-- disable-fileinfo\-- enable-opcache\-- with-pear\-enable-maintainer-zts\-- with-ldap=shared\-- without-gdbm\

If there is no error to perform the next step of installation, if there is an error in the compilation process, this problem usually does not occur when installing the dependency package according to the error report.

Note:-enable-gd-jis-conv this parameter will cause garbled characters in Zabbix. It is recommended to cancel this parameter.

Start the installation:

$make-j 4 & & make install

Configure the php.ini file after the installation is complete:

$cp php.ini-development / usr/local/php/etc/php.ini$ cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf$ cp / usr/local/php/etc/php-fpm.d/www.conf.default / usr/local/php/etc/php-fpm.d/www.conf

Modify the parameters related to php.ini:

$vim / usr/local/php/etc/php.iniexpose_php = Offshort_open_tag = ONmax_execution_time = 300max_input_time = 300memory_limit = 128Mpost_max_size = 32Mdate.timezone = Asia/Shanghaimbstring.func_overload=2extension = "/ usr/local/php/lib/php/extensions/no-debug-zts-20160303/ldap.so"

Set up the OPcache cache:

[opcache] zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20160303/opcache.soopcache.memory_consumption=128opcache.interned_strings_buffer=8opcache.max_accelerated_files=4000opcache.revalidate_freq=60opcache.fast_shutdown=1opcache.enable_cli=1

Set the php security function:

$vim / usr/local/php/etc/php.ini

Default value:

Disable_functions =

Modified to:

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

Or wildcard:

Disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

Configure www.conf

Uncomment the following and modify and optimize its parameters:

Listen = / var/run/www/php-cgi.socklisten.owner = wwwlisten.group = wwwlisten.mode = 0660listen.allowed_clients = 127.0.0.1pm = dynamiclisten.backlog =-1pm.max_children = 180pm.start_servers = 50pm.min_spare_servers = 50pm.max_spare_servers = 180request_terminate_timeout = 120request_slowlog_timeout = 50slowlog = var/log/slow.log

Create a php-cgi.sock storage directory

$mkdir / var/run/www/$ chown-R www:www / var/run/www

Configure php-fpm.conf

Take the following comments and fill in the full path:

Pid = / usr/local/php/var/run/php-fpm.pid

At this point, php7 has been installed.

Description: disable the php function, if the program needs these functions, you can cancel the ban, beginners recommend ignoring this step.

Create the system system unit file php-fpm startup script:

$vim / usr/lib/systemd/system/php-fpm.service

Add the following variables:

[Unit] Description=The PHP FastCGI Process ManagerAfter=syslog.target network.target [service] Type=simplePIDFile=/usr/local/php/var/run/php-fpm.pidExecStart=/usr/local/php/sbin/php-fpm-- nodaemonize-- fpm-config / usr/local/php/etc/php-fpm.confExecReload=/bin/kill-USR2 $MAINPID [install] WantedBy=multi-user.target

Start the php-fpm service and join the boot self-startup:

$systemctl enable php-fpm.service$ systemctl restart php-fpm.service

The entire installation process of PHP has been completed. If your installation is unsuccessful according to this article, I hope you can leave a message to explain the cause of the error. I will assist you with the configuration free of charge.

If you have any good suggestions to improve this article, you are very welcome to put forward and improve, we learn and progress together.

The above is all the contents of this article entitled "how to compile and install php7.2 with Centos7 source code". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report