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即可

上一篇 Java实现拼手气红包算法
下一篇 WordPress及WooCommerce安装
目录
文章列表
1 CentOS下安装编译FFmpeg
CentOS下安装编译FFmpeg
2
Vue.js路由router-link传参以及参数获取
Vue.js路由router-link传参以及参数获取
3
jQuery获得select/option的值和对select/option进行操作
jQuery获得select/option的值和对select/option进行操作
4
Python Selenium警告框处理
Python Selenium警告框处理
5
C++ ANSI及UTF-8与Unicode转码
C++ ANSI及UTF-8与Unicode转码
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。