How to install php for 32m free VPS | |
---|---|
Kogen Akira Offline Topics: 1 Replies: 1 Joined: 04/06/2020 |
One: Check if PHP is installed 1) yum installation check: yum list installed| grep php 2) rpm installation check: rpm -qa | grep php 3) There are various ways to query the installation, such as looking for the PHP executable, or checking the process ps -ef | grep php and other methods. Second: check if there is no PHP installation, you can prepare the initial software before PHP installation, use yum install xxxx can be installed, of course, not too much trouble can also compile and install themselves, here is not going to say in detail. 1) zlib and zlib-devel zlib provides a library of data compression functions, and is also the front-end software of nginx. zlib needs to compile the PHP zlib extension, and compilation will require the use of the zlib.h header file, the header file is in zlib-devel, so also need to download zlib-devel. 2) libxml2 as well as libxml-devel libxml2 is a C language xml program library that can simply perform various operations on xml and support xpath query, as well as partial support for xslt conversion and other functions. 3) libxslt as well as libxslt-devel if not installed libxslt-devel will prompt to find the xslt.config file, xslt is an extension to convert xml to other formats.
3) openssl and openssl-devel security proprietary layer ciphers 4) jpeg IJG's jpeg library, php's gd library required. 5) libpng is a cross-platform library for complex pngpng files written in C. It can help to easily read every line of a pngpng file to replace the php gd library required. (6) freetype and freetype-devel free open source and portable font engine, providing a unified interface to access a variety of font formats, both are gd library dependent software, so if not installed, or the version is too low, in the installation of phptime is set to install the gd library insert error, in addition, do not install -evel will also report errors, because when compiling the extension will ft2build.h file, the error is reported below.
7) GD GD is an extended library for PHP processing graphics 8) curl, because the version in my yum is too low, so directly compile and install it myself, the installation method is very simple, that is, wget curl download address and tar decompress, new / usr / local / curl folder, then go to the folder after the curl decompress configuration. /configure--prefix = / usr / local / curl immediately, and finally make and make install is installed. Note: xxx-devel is a development package for xxx software and contains header files as well as static libraries and even source code. Three: php download and install 1)Download the tar.gz file of php with wget: wget http://br2.php.net/get/php-7.2.2.tar.gz 2) Unzip the tar.gz file: tar zxvf php-7.2.2.tar.gz 3) Create a new folder where you want to install php: mkdir / usr / local / php, then go to the unpacked php installer folder and configure it as follows .
Note that. --prefix = installation directory --with-use package name [= package directory] ---enable ---function to be activated IV: Configuring PHP-related files 1) Configure php.ini, this 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, this 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 in the init.d folder: cp -R sbin / php-fpm /etc/init.d/php-fpm 5: Start PHP and make sure it is installed successfully Execute the command /etc/init.d/php-fpm immediately See if it starts: ps -ef | grep php can both see that php has started some progress VI: Configure nginx to support php after successful installation 1) Change php.ini file, vim /usr/local/php/lib/php.ini By looking for cgi.fix_pathinfo = 1 this configuration, and delete the comment, and replace cgi.fix_pathinfo = 0, this does not belong to nginx support php configuration related, or a security vulnerability that belongs to nginx under php, if this narrowed 1, the user side can upload the trojan by uploading the image, and then access the image address through the URL, and add /xxx.php after the address to run the image as a PHP file, this is only a problem in nginx, apache and iis are not the problem The above question can be thought of directly from Bird's blog, written in considerable detail: http://http://www.laruence.com/2010/05/20/1495.html 2) Configure web-specific groups and users Add www user group: groupadd www Add the user under the www user group www: useradd -g www 3)Change php-fpm.conf configuration Remove the user = nobody comment and add nobody as www user as configured above Remove the comment for group = nobody, add nobody and change it to the www user group configured above Finally, check that the last value included in php-fpm.conf is the correct www.conf directory address, and if it is not correct, change it to the correct directory address. 4)Change www.conf configuration Remove the user = nobody comment and add nobody as www user as configured above Remove the comment for group = nobody, add nobody and change it to the www user group configured above 5) Change nginx.conf file /etc/local/nginx/conf/nginx.conf Remove the #user = nobody comment and replace it with user = www Delete location ~\ .php $ {...} For this code, replace $ document_root with / scripts in fastcgi_param
Finally, add index.php after the location / {...} and make sure index.php is used as an alternative home page.
6) Restart php-fpm and nginx, can kill all php-fpm then /etc/init.d/php-pfm can restart, / usr / local / nginx / sbin / nginx -s stop can stop nginx, then execute / usr / local / nginx / sbin / php immediately restart. 7) Create a random php file in the html directory, the content is phpinfo(); then access the file address in the browser to see if the correct php-related information, if the correct display is successful configuration. Translated with www.DeepL.com/Translator (free version) |
04/06/2020 08:46:57 |
|
Kevin Young Offline Topics: 4 Replies: 30 Moderator |
Thank you for sharing but please confirm your email address first. |
04/06/2020 19:16:38 |