In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Linux system how to install PHP, for this problem, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and easy way.
PHP, the "hypertext preprocessor", is mainly used in Web server development. The main feature of this language is that it allows web developers to write dynamic web pages quickly.
One: check whether php is installed
1) yum installation check: yum list has been installed | grep php
2) rpm installation check: rpm-qa | grep php
3) self-compiled and installed queries can be made in a variety of ways, such as finding the executor of php, or checking the process ps-ef | grep php and other methods.
Two: check if there is no installation of php, you can prepare the initial software before php installation, you can install it with yum install xxxx, of course, you can compile and install it yourself without any trouble, so I won't go into details here.
1) zlib and zlib-devel zlib provide data compression function library, which is also the front-end software of nginx, because zlib needs to compile php's zlib extension, and the header file is in zlib-devel, so you also need to download zlib-devel.
2) libxml2 and libxml-devel libxml2 is a c language xml library, which can easily operate on xml, support xpath query, and partially support xslt conversion and other functions.
3) libxslt and libxslt-devel will be prompted to find the xslt.config file if you do not install libxslt-devel. Xslt is an extension that converts xml to other formats.
3) openssl and openssl-devel security proprietary layer password library
4) jpeg library of jpeg IJG, required by gd library of php.
5) libpng is a cross-platform library for complex pngpng files written in c language, which can help you easily read every line replacement of pngpng files, as required by php's gd library.
6) freetype and freetype-devel free open source and portable font engine, providing a unified interface to access a variety of font formats, these two are gd library dependent software, so if not installed, or the version is too low, in the installation of phptime set to install the GD library insert error, in addition, do not install-devel will also report an error, because the expansion will be compiled when the ft2build.h file, the error report as shown below.
7) gd gd is an extended library for php to process graphics.
8) curl, because the version in my yum is too low, I compiled and installed it directly by myself. The installation method is very simple, that is, after the download address of wget curl, tar is decompressed, create a new / usr / local / curl folder, and then enter the folder after curl decompression to configure. / configure-prefix = / usr / local / curl immediately, and finally make and make install are installed.
Note: xxx-devel is a development kit for xxx software, including header files, static libraries and even source code.
Three: download and install php
1) download the tar.gz file of php with wget: wget http://br2.php.net/get/php-7.2.2.tar.gz
2) decompress the tar.gz file: tar zxvf php-7.2.2.tar.gz
3) create a new folder to install php later: mkdir / usr / local / php, and then enter the decompressed php installation package folder to configure the configuration:
. / configure-prefix = / usr / local / php-with-curl = / usr / local / curl-with-freetype-dir-with-gd-with-gettext-with-iconv-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
Note:
-prefix = installation directory
-with- uses package name [= package directory]
-functions that need to be activated for enable-
Four: configure php-related files
1) configure php.ini, which is the configuration file for php: cp / home/myload/php-7.2.2/php.ini-development / usr/local/php/lib/php.ini
2) configure php-fpm.conf, which is the php-fpm configuration file: cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf
3) configure www.conf, configure the user's file: cp etc / php-fpm.d / www.conf.default etc / php-fpm.d / www.conf
4) copy the php-fpm startup file to a convenient startup php:cp-R sbin / php-fpm / etc/init.d/php-fpm in the init.d folder
Five: start php to determine whether the installation is successful
Execute command / etc/init.d/php-fpm now
Check to see if it starts: ps-ef | grep php can see that php has started some progress.
6: configure nginx to support php after successful installation
1) change the php.ini file, vim / usr/local/php/lib/php.ini
By looking for the configuration of cgi.fix_pathinfo = 1, deleting the comment, and replacing cgi.fix_pathinfo = 0, it does not belong to nginx supporting php configuration, or it belongs to a security vulnerability of php under nginx. If it is reduced by 1 here, users can upload Trojans by uploading pictures, then visit the image address through the URL, and add / xxx.php after the address to run the pictures as PHP files. This is a problem that only exists in nginx. Neither apache nor iis has this problem.
The above questions can be directly related to Brother Bird's blog, which is written in great detail: http:// http://www.laruence.com/2010/05/20/1495.html
2) configure groups and users dedicated to web
Add www user group: groupadd www
Add user www:useradd-g www www under the www user group
3) change php-fpm.conf configuration
Remove the comment user = nobody, add nobody and change it to the www user configured above
Remove the comments of group = nobody and add nobody to the www user group configured above.
Finally, check that the last value contained in php-fpm.conf is the correct www.conf directory address, and if not, replace it with the correct directory address.
4) change www.conf configuration
Remove the comment user = nobody, add nobody and change it to the www user configured above
Remove the comments of group = nobody and add nobody to the www user group configured above.
5) change the nginx.conf file / etc/local/nginx/conf/nginx.conf
Uncomment # user = nobody and replace user = www
Delete the comments in the code in position ~\ .php, and replace document_root in turn
Finally, the position / {… } add index.php after the replacement index to ensure that index.php is used as the replacement home page
6) restart php-fpm and nginx, kill all php-fpm and then restart / etc/init.d/php-pfm. / usr / local / nginx / sbin / nginx-s stop can stop nginx, and then execute / usr / local / nginx / sbin / php to restart immediately.
7) create a random php file in the html directory with the content of phpinfo ();, and then access the file address in the browser to see if the correct php-related information is correct. If it is displayed correctly, the configuration is successful.
Seven: cooperate with apache to support php, and add this later to continue.
Php is currently the most popular programming voice, so when it comes to the best language, someone will say that pup is the best language.
What are the versions of Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.
This is the answer to the question about how to install PHP in Linux system. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.
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.