linux下面安装php

本文是自己根据其他人的方法一步步安装,留作记录。 第一步:下载php安装文件到本地

[root@izm5e9rt5ix8dl9ar3j777z local]# wget http://cn2.php.NET/distributions/php-7.1.16.tar.gz --2018-05-28 21:07:53-- http://cn2.php.net/distributions/php-7.1.16.tar.gz Resolving cn2.php.net (cn2.php.net)... 36.51.255.144 Connecting to cn2.php.net (cn2.php.net)|36.51.255.144|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 19470983 (19M) [application/x-gzip] Saving to: ‘php-7.1.16.tar.gz’ 100%[===============================================================================================================================================================================================>] 19,470,983 5.70MB/s in 3.3s 2018-05-28 21:07:57 (5.70 MB/s) - ‘php-7.1.16.tar.gz’ saved [19470983/19470983]


第二部:解压文件
tar zxvf php-7.1.16.tar.gz
第三部:安装
cd php-7.1.16
运行
./configure --enable-fpm --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc
【linux下面安装php】错误:configure: error: libxml2 not found. Please check your libxml2 installation.
缺少libxml2,so我去安装
yum install libxml2-devel
yum install gcc
最好都安装了,我这里都执行了一遍。
然后别忘了再次执行 ./configure --enable-fpm --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc,你再提示信息的最后面发现如下信息表示成功:
+--------------------------------------------------------------------+
| License: | | This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php7.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/fpm/php-fpm.conf config.status: creating sapi/fpm/www.conf config.status: creating sapi/fpm/init.d.php-fpm config.status: creating sapi/fpm/php-fpm.service config.status: creating sapi/fpm/php-fpm.8 config.status: creating sapi/fpm/status.html config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands
然后执行:
make && make install 时间很长,耐心等待,程序刷屏,可以无视去干别的了。
最后看到如下提示:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ Installing PHP CLI binary: /usr/local/php/bin/ Installing PHP CLI man page: /usr/local/php/php/man/man1/ Installing PHP FPM binary: /usr/local/php/sbin/ Installing PHP FPM defconfig: /usr/local/php/etc/ Installing PHP FPM man page: /usr/local/php/php/man/man8/ Installing PHP FPM status page: /usr/local/php/php/php/fpm/ Installing phpdbg binary: /usr/local/php/bin/ Installing phpdbg man page: /usr/local/php/php/man/man1/ Installing PHP CGI binary: /usr/local/php/bin/ Installing PHP CGI man page: /usr/local/php/php/man/man1/ Installing build environment: /usr/local/php/lib/php/build/ Installing header files: /usr/local/php/include/php/ Installing helper programs: /usr/local/php/bin/ program: phpize program: php-config Installing man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar - installed: 1.4.3 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.4.2 [PEAR] PEAR - installed: 1.10.5 Wrote PEAR system config file at: /usr/local/php/etc/pear.conf You may want to add: /usr/local/php/lib/php to your php.ini include_path /usr/local/php-7.1.16/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin ln -s -f phar.phar /usr/local/php/bin/phar Installing PDO headers: /usr/local/php/include/php/ext/pdo/
配置 (以下配置都是我个人的路径配置 大家请按照各自路径配置)
cpphp.ini-development /usr/local/lib/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
#配置完毕 /etc/init.d/php7-fpm start 启动php

    推荐阅读