CentOS下Nginx及PHP快速安装
Nginx
# wget http://nginx.org/download/nginx-1.17.2.tar.gz
# tar -zxf nginx-1.17.2.tar.gz
# cd nginx-1.17.2/
# ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.43 --with-openssl=../openssl-1.1.1c --with-zlib=../zlib-1.2.11 --with-http_ssl_module --with-http_v2_module
# make & make install
# ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
# nginx -v
必须为pcre,不能为pcre2
pcre、openssl、zlib需要指定源码目录,不能是已编译安装的目录
PHP
PHP编译安装
# wget https://www.php.net/distributions/php-7.2.20.tar.gz
# tar -zxf php-7.2.20.tar.gz
# cd php-7.2.20/
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg-9c --with-png-dir=/usr/local/libpng --with-zlib=/usr/local/zlib --with-libxml-dir=/usr/local/libxml2 --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-ftp --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-ldap=/usr --disable-fileinfo --enable-maintainer-zts --with-libzip=/usr/local/libzip
# make && make install
# cd /data/server/php7/etc/
# cp php-fpm.conf.default php-fpm.conf
# cp php-fpm.d/www.conf.default php-fpm.d/www.conf
# ln -s /usr/local/php/bin/* /usr/bin/
# ln -s /usr/local/php/sbin/* /usr/sbin/
# php -v
# php-fpm
注意configure之前添加依赖库搜索路径到配置文件
# vim /etc/ld.so.conf.d/local.conf
# ldconfig
/usr/local/lib64
/usr/local/lib
/usr/lib64
/usr/lib
/usr/local/zlib/lib
/usr/local/libzip/lib
/usr/local/libgd/lib
/usr/local/libevent/lib
/usr/local/libmcrypt/lib
/usr/local/freetype/lib
/usr/local/mysql/lib
/usr/local/net-snmp/lib
常见错误
(1)liblber
/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_scanf'
/usr/lib64/liblber-2.4.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
解决:在PHP源码目录下vim Makefile
找到EXTRA_LIBS
行,在行末添加-llber
保存退出再次make即可
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/02/12/centos-install-nginx-php/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
3
二维码
打赏
海报
CentOS下Nginx及PHP快速安装
Nginx
# wget http://nginx.org/download/nginx-1.17.2.tar.gz
# tar -zxf nginx-1.17.2.tar.gz
# cd nginx-1.17.2/
# ./configure --prefix=/usr/local/ngin……
文章目录
关闭
共有 0 条评论