In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how ubuntu compiles and installs PHP7.4. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Download the PHP7.4 source code package
Wget https://www.php.net/distributions/php-7.4.26.tar.gz
Decompression
Tar-zxvf php-7.4.26.tar.gz
Install PHP dependent libraries
Apt-get install libxml2 libxml2-dev sqlite3 libsqlite3-dev libcurl3-dev libxml-dev
Run. / configure
# cd to php source directory. / configure-- prefix=/usr/local/php7\-- with-config-file-path=/etc\-- with-fpm-user=test\-- with-fpm-group=test\-- with-curl-- enable-fpm
Note: there are only a few extensions here, because if you have more, it will take a long time to compile. It's just for testing, compiling and installing php, so not many extensions have been added. If you want to add more extensions later after the installation and forget the previous compilation parameters, you can see the previous compilation parameters in the source directory cat config.nice. Then recompile with new parameters (don't forget to install the extension dependency library first).
Run make & & make install
Run make install to add the-j parameter, which means that multiple job work at the same time, the compilation speed will be faster.
Make install-j 2
Set the PHP environment variable
1. Open a file
Vim / etc/profile
two。 Write content
PATH=$PATH:/usr/local/php7/binexport PATH
3. Make the environment variable effective immediately
Source / etc/profile
4. No error was reported when entering php-v, and the environment variable was set successfully.
Configuration file
# modify configuration file cd / usr/local/php7/etc cp php-fpm.conf.default php-fpm.conf cp php-fpm.d/www.conf.default php-fpm.d/www.conf # modify pid file location vim php-fpm.conf# add this line pid = / run/php-fpm.pid# create php-fpm soft link ln-s / usr/local/php7/sbin/php-fpm / usr/sbin/php-fpm
Start and stop php-fpm
# start / usr/sbin/php-fpm # close kill-INT `cat / run/php- fpm.pid` # restart kill-USR2 `cat / run/php- fpm.pid`
Error handling
ERROR: [pool www] cannot get uid for user 'test'
1. Reason: because the user and user group of php-fpm is set at compilation time, the user and user group of php-fpm is test [randomly set] (--with-fpm-user=test-- with-fpm-group=test). In fact, this user does not exist, so there are two ways to deal with it:
Create users and user groups as test
Modify php-fpm.conf to set users and user groups to the same as nginx or apache user groups
# Open php-fpm.conf vim / usr/local/php7/etc/php-fpm.conf# and change the location to (my nignx user group is www-data user = www-data) group = www-data
2. ERROR: failed to retrieve TCP_INFO for socket: Protocol not available (92)
Reason: I use the linux subsystem (ubuntu system) under windows, which is not a completely virtual system. There will be some problems, but it will not affect it. Check the host task manager to see that php-fpm has been started.
Solution: modify php-fpm.conf
# method 1: listen = / run/php-fpm.sock # method 2 sets log_level = alert
Add daemon
# PHP has its own service script in the source code. You only need to copy it to the / etc/init.d directory and add the execution permission. # make sure that the location of the pid file in / usr/local/php7/etc/php-fpm.conf is the initial value. The original is pid = run/php-fpm.pid# in the source directory to execute cp sapi/fpm/init.d.php-fpm / etc/init.d/php-fpmchmod + x / etc/init.d/php-fpmsystemctl daemon-reload# using the same method as above, you can also use systemctlservice php-fpm start service php-fpm stop service php-fpm restart service php-fpm status# or systemctl start php-fpmsystemctl stop php-fpmsystemctl restart php-fpmsystemctl status php-fpm to thank you for reading! This is the end of this article on "how ubuntu compiles and installs PHP7.4". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.