本篇文章给大家带来的内容是关于阿里云centos7.6安装php7.3的详细教程,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
新增用户 用户组groupadd wwwuseradd -g www www
下载 phpwget https://downloads.php.net/~cmb/php-7.3.0.tar.gztar xzvf php-7.3.0.tar.gzcd php-7.3.0
编译--with-fpm-user=www --with-fpm-group=www
这里使用www www 用户、用户组
编译出来的程序启动,就是归属这个用户、用户组
./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip --enable-fpm
编译错误,解决依赖configure: error: libxml2 not found. please check your libxml2 installation.
yum install -y libxml2-devel
configure: error: please reinstall the bzip2 distribution
yum install -y bzip2-devel
configure: error: curl version 7.15.5 or later is required to compile php with curl support
yum install -y curl-devel
configure: error: jpeglib.h not found.
yum install -y libjpeg-devel
configure: error: png.h not found.
yum install -y libpng-devel
configure: error: freetype-config not found.
yum install -y freetype-devel
configure: error: xslt-config not found. please reinstall the libxslt >= 1.1.0 distribution
yum install -y libxslt-devel
configure: error: please reinstall the libzip distribution
yum install -y libzip-devel
checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
#先删除旧版本yum remove -y libzip#下载编译安装wget https://nih.at/libzip/libzip-1.2.0.tar.gztar -zxvf libzip-1.2.0.tar.gzcd libzip-1.2.0./configuremake && make install
off_t undefined 报错
checking libzip... yeschecking for the location of zlib... /usrchecking for pkg-config... (cached) /usr/bin/pkg-configchecking for libzip... in default path: found in /usr/localchecking for zip_open in -lzip... yeschecking for zip_file_set_encryption in -lzip... yeschecking for zip_libzip_version in -lzip... nochecking stdbool.h usability... yeschecking stdbool.h presence... yeschecking for stdbool.h... yeschecking fts.h usability... yeschecking fts.h presence... yeschecking for fts.h... yeschecking for int8_t... (cached) yeschecking for int16_t... (cached) yeschecking for int32_t... (cached) yeschecking for int64_t... (cached) yeschecking for uint8_t... (cached) yeschecking for uint16_t... (cached) yeschecking for uint32_t... (cached) yeschecking for uint64_t... (cached) yeschecking for ssize_t... yeschecking size of short... (cached) 2checking size of int... (cached) 4checking size of long... (cached) 8checking size of long long... (cached) 8checking size of off_t... 0configure: error: off_t undefined; check your library configuration
off_t 类型是在 头文件 unistd.h中定义的,
在32位系统 编程成 long int ,64位系统则编译成 long long int ,
在进行编译的时候 是默认查找64位的动态链接库,
但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,
这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。
#添加搜索路径到配置文件echo '/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64'>>/etc/ld.so.conf#然后 更新配置ldconfig -v
安装make && make install
报错
usr/local/include/zip.h:59:21: fatal error: zipconf.h: no such file or directory
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
成功输出
installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/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-configinstalling man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1installing pear environment: /usr/local/php/lib/php/warning: continue targeting switch is equivalent to break. did you mean to use continue 2? in phar:///home/flame/software/php-7.3.0/pear/install-pear-nozlib.phar/pear/packagefile/v2/validator.php on line 1933[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.5wrote pear system config file at: /usr/local/php/etc/pear.confyou may want to add: /usr/local/php/lib/php to your php.ini include_path/home/flame/software/php-7.3.0/build/shtool install -c ext/phar/phar.phar /usr/local/php/binln -s -f phar.phar /usr/local/php/bin/pharinstalling pdo headers: /usr/local/php/include/php/ext/pdo/
配置,建立目录cp php.ini-production /usr/local/php/lib/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confln -s /usr/local/php/sbin/php-fpm /usr/local/bin
cd /usr/local/php/etc/php-fpm.dvim www.conf
输入
[www]listen = 127.0.0.1:9080 listen.mode = 0666 user = www #php代码目录权限 需要跟这个一致,group = www #php代码目录权限 需要跟这个一致pm = dynamicpm.max_children = 128pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 10000rlimit_files = 1024slowlog = log/$pool.log.slow
加入 systemtl 服务cd /home/flame/software/php-7.3.0/sapi/fpmcp php-fpm.service /usr/lib/systemd/system/
启动systemctl start php-fpm
#查看状态systemctl status php-fpm#得到输出● php-fpm.service - the php fastcgi process manager loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) active: active (running) since thu 2018-12-27 16:13:16 cst; 2s ago main pid: 16835 (php-fpm) cgroup: /system.slice/php-fpm.service ├─16835 php-fpm: master process (/usr/local/php/etc/php-fpm.conf) ├─16836 php-fpm: pool www ├─16837 php-fpm: pool www ├─16838 php-fpm: pool www ├─16839 php-fpm: pool www ├─16840 php-fpm: pool www ├─16841 php-fpm: pool www ├─16842 php-fpm: pool www ├─16843 php-fpm: pool www ├─16844 php-fpm: pool www ├─16845 php-fpm: pool www ├─16846 php-fpm: pool www ├─16847 php-fpm: pool www ├─16848 php-fpm: pool www ├─16849 php-fpm: pool www ├─16850 php-fpm: pool www ├─16851 php-fpm: pool www ├─16852 php-fpm: pool www ├─16853 php-fpm: pool www ├─16854 php-fpm: pool www └─16855 php-fpm: pool wwwdec 27 16:13:16 izj6cas4fyg41lxhngh1z0z systemd[1]: started the php fastcgi process manager.
测试mkdir -p /home/www/webroot/phpcd /home/www/webroot/phpvim test.php
输入
<?phpphpinfo();?>
访问
xxx.xxx.xxx.xxx:8080/test.php
php 命令环境在$home/.profile里新增内容为
export path=$path:/usr/local/php/bin
专栏
文章详情
flamefatex 21
1 天前发布
阿里云 centos7.6 安装 php7.3
php
centos
linux
43 次阅读 · 读完需要 26 分钟
2
新增用户 用户组groupadd wwwuseradd -g www www
下载 phpwget https://downloads.php.net/~cmb/php-7.3.0.tar.gztar xzvf php-7.3.0.tar.gzcd php-7.3.0
编译
--with-fpm-user=www --with-fpm-group=www
这里使用www www 用户、用户组
编译出来的程序启动,就是归属这个用户、用户组
./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip --enable-fpm
编译错误,解决依赖configure: error: libxml2 not found. please check your libxml2 installation.
yum install -y libxml2-devel
configure: error: please reinstall the bzip2 distribution
yum install -y bzip2-devel
configure: error: curl version 7.15.5 or later is required to compile php with curl support
yum install -y curl-devel
configure: error: jpeglib.h not found.
yum install -y libjpeg-devel
configure: error: png.h not found.
yum install -y libpng-devel
configure: error: freetype-config not found.
yum install -y freetype-devel
configure: error: xslt-config not found. please reinstall the libxslt >= 1.1.0 distribution
yum install -y libxslt-devel
configure: error: please reinstall the libzip distribution
yum install -y libzip-devel
checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
#先删除旧版本yum remove -y libzip#下载编译安装wget https://nih.at/libzip/libzip-1.2.0.tar.gztar -zxvf libzip-1.2.0.tar.gzcd libzip-1.2.0./configuremake && make install
off_t undefined 报错
checking libzip... yeschecking for the location of zlib... /usrchecking for pkg-config... (cached) /usr/bin/pkg-configchecking for libzip... in default path: found in /usr/localchecking for zip_open in -lzip... yeschecking for zip_file_set_encryption in -lzip... yeschecking for zip_libzip_version in -lzip... nochecking stdbool.h usability... yeschecking stdbool.h presence... yeschecking for stdbool.h... yeschecking fts.h usability... yeschecking fts.h presence... yeschecking for fts.h... yeschecking for int8_t... (cached) yeschecking for int16_t... (cached) yeschecking for int32_t... (cached) yeschecking for int64_t... (cached) yeschecking for uint8_t... (cached) yeschecking for uint16_t... (cached) yeschecking for uint32_t... (cached) yeschecking for uint64_t... (cached) yeschecking for ssize_t... yeschecking size of short... (cached) 2checking size of int... (cached) 4checking size of long... (cached) 8checking size of long long... (cached) 8checking size of off_t... 0configure: error: off_t undefined; check your library configuration
off_t 类型是在 头文件 unistd.h中定义的,
在32位系统 编程成 long int ,64位系统则编译成 long long int ,
在进行编译的时候 是默认查找64位的动态链接库,
但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,
这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。
#添加搜索路径到配置文件echo '/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64'>>/etc/ld.so.conf#然后 更新配置ldconfig -v
安装make && make install
报错
usr/local/include/zip.h:59:21: fatal error: zipconf.h: no such file or directory
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
成功输出
installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/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-configinstalling man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1installing pear environment: /usr/local/php/lib/php/warning: continue targeting switch is equivalent to break. did you mean to use continue 2? in phar:///home/flame/software/php-7.3.0/pear/install-pear-nozlib.phar/pear/packagefile/v2/validator.php on line 1933[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.5wrote pear system config file at: /usr/local/php/etc/pear.confyou may want to add: /usr/local/php/lib/php to your php.ini include_path/home/flame/software/php-7.3.0/build/shtool install -c ext/phar/phar.phar /usr/local/php/binln -s -f phar.phar /usr/local/php/bin/pharinstalling pdo headers: /usr/local/php/include/php/ext/pdo/
配置,建立目录cp php.ini-production /usr/local/php/lib/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confln -s /usr/local/php/sbin/php-fpm /usr/local/bin
cd /usr/local/php/etc/php-fpm.dvim www.conf
输入
[www]listen = 127.0.0.1:9080 listen.mode = 0666 user = www #php代码目录权限 需要跟这个一致,group = www #php代码目录权限 需要跟这个一致pm = dynamicpm.max_children = 128pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 10000rlimit_files = 1024slowlog = log/$pool.log.slow
加入 systemtl 服务cd /home/flame/software/php-7.3.0/sapi/fpmcp php-fpm.service /usr/lib/systemd/system/
启动systemctl start php-fpm
#查看状态systemctl status php-fpm#得到输出● php-fpm.service - the php fastcgi process manager loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) active: active (running) since thu 2018-12-27 16:13:16 cst; 2s ago main pid: 16835 (php-fpm) cgroup: /system.slice/php-fpm.service ├─16835 php-fpm: master process (/usr/local/php/etc/php-fpm.conf) ├─16836 php-fpm: pool www ├─16837 php-fpm: pool www ├─16838 php-fpm: pool www ├─16839 php-fpm: pool www ├─16840 php-fpm: pool www ├─16841 php-fpm: pool www ├─16842 php-fpm: pool www ├─16843 php-fpm: pool www ├─16844 php-fpm: pool www ├─16845 php-fpm: pool www ├─16846 php-fpm: pool www ├─16847 php-fpm: pool www ├─16848 php-fpm: pool www ├─16849 php-fpm: pool www ├─16850 php-fpm: pool www ├─16851 php-fpm: pool www ├─16852 php-fpm: pool www ├─16853 php-fpm: pool www ├─16854 php-fpm: pool www └─16855 php-fpm: pool wwwdec 27 16:13:16 izj6cas4fyg41lxhngh1z0z systemd[1]: started the php fastcgi process manager.
测试mkdir -p /home/www/webroot/phpcd /home/www/webroot/phpvim test.php
输入
<?phpphpinfo();?>
访问
xxx.xxx.xxx.xxx:8080/test.php
php 命令环境在$home/.profile里新增内容为
export path=$path:/usr/local/php/bin
举报
你可能感兴趣的
评论
默认排序 时间排序
载入中...
显示更多评论
以上就是阿里云centos7.6安装php7.3的详细教程的详细内容。