IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> PHP知识库 -> Linux系统源码安装PHP以及相关问题总结 -> 正文阅读

[PHP知识库]Linux系统源码安装PHP以及相关问题总结

1 安装依赖

# 添加epel
yum install epel-release
yum update
# 添加依赖包
yum -y install systemtap-sdt-devel libxml2 libxml2-devel openssl-devel libcurl-devel enchant-devel libpng-devel libicu-devel libmcrypt-devel recode-devel net-snmp-devel libtidy-devel autoconf readline-devel libtidy-devel aspell-devel unixODBC-devel libicu-devel libc-client-devel freetype-devel libXpm-devel libpng-devel install libvpx-devel enchant-devel libcurl-devel libc-client-devel openldap-devel openldap postgresql-devel curl-devel libxslt-devel bzip2-devel db4-devel libjpeg-devel gmp-devel sqlite-devel pcre-devel mysql-devel pspell-devel gcc gcc-c++ make autoconf cmake wget oniguruma oniguruma-devel 

2 配置及安装

2.1 下载php源码

wget https://www.php.net/distributions/php-7.4.28.tar.gz
tar -zxf php-7.4.28.tar.gz
cd php-7.4.28

2.2 配置扩展

'./configure' '--prefix=/usr/local/php' '--sharedstatedir=/data/php' '--localstatedir=/data/php' '--enable-fpm' '--enable-phpdbg' '--enable-phpdbg-webhelper' '--enable-phpdbg-debug' '--disable-debug' '--with-layout=GNU' '--with-config-file-path=/usr/local/php/etc' '--with-config-file-scan-dir=/usr/local/php/etc/php.d' '--disable-ipv6' '--enable-dtrace' '--enable-libxml' '--with-openssl' '--with-pcre-regex' '--with-sqlite3' '--with-zlib' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-ctype' '--with-openssl=shared,/usr/local/openssl' '--with-curl=shared,/usr/local/curl' '--with-curl' '--enable-dom' '--with-enchant' '--enable-exif' '--enable-fileinfo' '--enable-filter' '--enable-ftp' '--with-gd' '--with-webp-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-freetype-dir' '--enable-gd-native-ttf' '--with-gettext' '--with-gmp' '--with-mhash' '--enable-hash' '--with-iconv' '--enable-json' '--enable-mbstring' '--with-mcrypt' '--with-mysqli=mysqlnd' '--enable-opcache' '--enable-opcache-file' '--enable-huge-code-pages' '--enable-pcntl' '--enable-pdo' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql' '--with-pdo-sqlite' '--with-pgsql' '--enable-phar' '--enable-posix' '--with-readline' '--with-recode' '--enable-session' '--enable-shmop' '--enable-simplexml' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader' '--with-xmlrpc' '--enable-xmlwriter' '--with-xsl' '--enable-zip' '--enable-mysqlnd' '--enable-mysqlnd-compression-support' '--with-pear'

2.3 编译安装

make && make install
## 完成安装之后可以通过以下命令查看安装的PHP扩展
php -m

2.4 nginx添加模块

(1)LuaJIT(lua-nginx-module)

首先在Linux本地安装LuaJIT:

git clone https://github.com/openresty/luajit2 /tmp/luajit2
cd /tmp/luajit2
make && make install PREFIX=/usr/local/luajit
echo "export LUAJIT_LIB=/usr/local/luajit/lib" >> /etc/profile
echo "export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1" >> /etc/profile
source /etc/profile

然后下载对应的压缩包:

git clone https://github.com/openresty/luajit2

在编译nginx的时候,添加如下配置:

./configure ...  --add-module=/usr/local/nginx/modules/lua-nginx-module

(2)ngx_devel_kit

下对应的压缩包:

git clone https://github.com/vision5/ngx_devel_kit.git /usr/local/nginx/modules/ngx_devel_kit

在编译nginx的时候,添加如下配置:

./configure ... --add-module=/usr/local/nginx/modules/ngx_devel_kit

(3)nginx_upstream_check_module

git clone https://github.com/xiaokai-wang/nginx_upstream_check_module.git /usr/local/nginx/modules/nginx_upstream_check_module

在编译nginx的时候,添加如下配置:

./configure ... --add-module=/usr/local/nginx/modules/nginx_upstream_check_module-master

3 编译安装FAQ

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
复制代码 代码如下:
yum -y install libxslt-devel
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
复制代码 代码如下:
yum -y install net-snmp-devel
configure: error: Please reinstall readline - I cannot find readline.h
复制代码 代码如下:
yum -y install readline-devel
configure: error: Cannot find pspell
复制代码 代码如下:
yum -y install aspell-devel
checking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!
复制代码 代码如下:
yum -y install unixODBC-devel
configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
复制代码 代码如下:
yum -y install libicu-devel
configure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.
复制代码 代码如下:
yum -y install libc-client-devel
configure: error: freetype.h not found.
复制代码 代码如下:
yum -y install freetype-devel
configure: error: xpm.h not found.
复制代码 代码如下:
yum -y install libXpm-devel
configure: error: png.h not found.
复制代码 代码如下:
yum -y install libpng-devel
configure: error: vpx_codec.h not found.
复制代码 代码如下:
yum -y install libvpx-devel
configure: error: Cannot find enchant
复制代码 代码如下:
yum -y install enchant-devel
configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
复制代码 代码如下:
yum -y install libcurl-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
复制代码 代码如下:
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make && make install
Cannot find imap
复制代码 代码如下:
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
复制代码 代码如下:
yum -y install libc-client-devel
Cannot find ldap.h
复制代码 代码如下:
yum -y install openldap
yum -y install openldap-devel
configure: error: Cannot find ldap libraries in /usr/lib
复制代码 代码如下:
cp -frp /usr/lib64/libldap* /usr/lib/
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
复制代码 代码如下:
yum -y install postgresql-devel
configure: error: Please reinstall the lib curl distribution
复制代码 代码如下:
yum -y install curl-devel
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
复制代码 代码如下:
yum -y install net-snmp-devel
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
复制代码 代码如下:
yum -y install libxslt-devel
checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution

Fix:
复制代码 代码如下:
yum -y install bzip2-devel
checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/

Fix:
复制代码 代码如下:
yum -y install curl-devel
checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).

Fix:
复制代码 代码如下:
yum -y install db4-devel
checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.

Fix:
复制代码 代码如下:
yum -y install libjpeg-devel
checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.

Fix:
复制代码 代码如下:
yum -y install libpng-devel
checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.
Fix:
复制代码 代码如下:
Reconfigure your PHP with the following option. --with-xpm-dir=/usr
checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.

Fix:
复制代码 代码如下:
yum -y install libXpm-devel
checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h

Fix:
复制代码 代码如下:
yum -y install gmp-devel
checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Fix:
复制代码 代码如下:
yum -y install libc-client-devel
checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h

Fix:
复制代码 代码如下:
yum -y install openldap-devel
checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!

Fix:
复制代码 代码如下:
yum -y install unixODBC-devel
checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:
复制代码 代码如下:
yum -y install postgresql-devel
checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution

Fix:
复制代码 代码如下:
yum -y install sqlite-devel
checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell

Fix:
复制代码 代码如下:
yum -y install aspell-devel
checking whether to enable UCD SNMP hack… yes checking for default_store.h… no

checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.

Fix:
复制代码 代码如下:
yum -y install net-snmp-devel
checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
复制代码 代码如下:
yum -y install libxslt-devel
configure: error: xml2-config not found. Please check your libxml2 installation.

Fix:
复制代码 代码如下:
yum -y install libxml2-devel
checking for PCRE headers location… configure: error: Could not find pcre.h in /usr

Fix:
复制代码 代码如下:
yum -y install pcre-devel
configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!

Fix:
复制代码 代码如下:
yum -y install mysql-devel
checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!

Fix:
复制代码 代码如下:
yum -y install unixODBC-devel
checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:
复制代码 代码如下:
yum -y install postgresql-devel
configure: error: Cannot find pspell

Fix:
复制代码 代码如下:
yum -y install pspell-devel
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.

Fix:
复制代码 代码如下:
yum -y install net-snmp-devel
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
复制代码 代码如下:
yum -y install libxslt-devel
./configure: error: the HTTP image filter module requires the GD library. You can either do not enable the module or install the libraries.

Fix:
复制代码 代码如下:
yum install gd gd-devel
./configure: error: the GeoIP module requires the GeoIP library.

Fix:
复制代码 代码如下:
yum install geoip-devel
./configure: error: the Google perftools module requires the Google perftools
library. You can either do not enable the module or install the library.

Fix:
复制代码 代码如下:
yum install gperftools
编译nginx时出现了下面的告警:
nginx "--with-ipv6" option is deprecated

Fix:
查阅相关文档,原来最新版的nginx编译不需要添加--with-ipv6命令
最新版的nginx默认已经自带ipv6模块
nginx /bin/sh: line 0: cd: /usr/local/pcre-8.35: No such file or directory

用make编译nginx的时候提示如下错误:
/bin/sh: line 0: cd: /usr/local/pcre-8.35: No such file or directory
objs/Makefile:1133: recipe for target ‘/usr/local/pcre-8.35/Makefile’ failed
make[1]: *** [/usr/local/pcre-8.35/Makefile] Error 1
make[1]: Leaving directory ‘/root/Downloads/nginx-1.6.2’
Makefile:8: recipe for target ‘build’ failed
  • 使用执行查看相关参数如何填写:./configure --help | grep pcre
  • 其中:--wite-pcre = DIR set path to pcre library sources(设置pcre库的源路径),这是因为我们刚装的pcre库未帮它设置我们当前的文件路径.你需要看下pcre-8.35的目录,
  • 然后执行:
    ./configure --prefix=/home/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/home/pcre-8.35
    /home/nginx
    • 不是你解压包后的目录,是你新增的目录,用来安装nginx
    • /home/pcre-8.35是你的pcre目录
    • 成功后就可以执行nginx安装指令
编译安装nginx时pcre模块报错的解决

CentOS 6.4 x86_64系统,编译安装nginx 1.4.5。

./configure时先是提示需要pcre的lib文件。用rpm -qa | grep pcre看了一下,pcre-7.8-6.el6.x86_64是已经安装过的。

于是用--with-pcre=/lib64指定了pcre的.so文件路径。但是在make的时候提示如下错误

make -f objs/Makefile
make[1]: Entering directory `/usr/local/src/nginx-1.4.5′
cd /usr/local/pcre /
       && if [ -f Makefile ]; then make distclean; fi /
       && CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " /
       ./configure –disable-shared
/bin/sh: line 2: ./configure: No such file or directory
make[1]: *** [/usr/local/pcre/Makefile] Error 127
make[1]: Leaving directory `/usr/local/src/nginx-1.4.5′
make: *** [build] Error 2

用./configure --help看了一下,原来“--with-pcre=”参数要指定的是源码文件。百度了一下也有说是要下个pcre的源码包指定路径过去。

我觉得既然已经安装过一个pcre了,还要在编译安装一个实在有点儿蛋疼。。所以自己倒腾了一下,发现其实并不用再找源码包编译,只要把pcre-devel装上就OK。安装完成后,./configure参数改成--with-pcre,不要=和后面的路径。

还有SSL的支持也是需要openssl-devel的。(这个yum装把,用rpm会被依赖关系搞到蛋疼)

总结一下,nginx编译安装基本上需要以下几个东东:

1.gcc-----------------必不可少的
2.zlib-----------------gzip需要
3.openssl(包括openssl-devel)-----SSL支持需要
4.pcre(包括pcre-devel)--------让nginx支持正则表达式
checking for BZip2 in default path... not found configure: error: Please reinstall

Fix:
yum install bzip2-devel.x86_64 -y
No package 'sqlite3' found

Fix:
sudo yum install sqlite-devel
checking for LuaJIT 2.x ... not found

Fix:
安装luajit2:
git clone https://github.com/openresty/luajit2.git /tmp/luajit2
cd /tmp/luajit2
make && make install PREFIX=/usr/local/luajit
echo "export LUAJIT_LIB=/usr/local/luajit/lib" >> /etc/profile
echo "export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1" >> /etc/profile
source /etc/profile
./configure: error: no /usr/local/nginx/modules/naxsi/config was found

Fix:
地址写错了,应该是naxsi里面的naxsi_Src目录
./configure ... --add-module=/usr/local/nginx/modules/naxsi/naxsi_src

Hi,
It seems you provided a wrong path to nginx, you have to provide the path of the naxsi_src directory (which would be /home/ubuntu/nginxmodule/naxsi-0.54/naxsi_src/ in your case).

nginx服务器启动找不到libluajit-5.1.so解决方法

解决过程
查找本地libluajit-5.1.so.2共享库文件

find / -name libluajit-5.1.so.2

如果找到此文件

cp /文件路径/libluajit-5.1.so.2 /usr/local/lib/
echo "/usr/local/lib"  >>/etc/ld.so.conf
/sbin/ldconfig

找不到此文件
安装luajit

wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
tar xf LuaJIT-2.0.4
cd LuaJIT-2.0.4
make && make install
/sbin/ldconfig

启动nginx即可

CentOS安装Nginx,及编译常见错误

step1:

cd nginx-1.17.5/

step2:

如果编译成功,则显示如下:

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library
 
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

step3:

make

如果编译成功,则显示:

make[1]: Leaving directory `/data/nginx-1.17.5'

step4:

make install

nginx使用openresty时failed to load the resty.core module

报错信息如下:

nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from openresty.org/en/download.html (reason: module 'resty.core' not found:
        no field package.preload['resty.core']
        no file './resty/core.lua'
        no file '/usr/local/share/luajit-2.1.0-beta3/resty/core.lua'
        no file '/usr/local/share/lua/5.1/resty/core.lua'
        no file '/usr/local/share/lua/5.1/resty/core/init.lua'
        no file './resty/core.so'
        no file '/usr/local/lib/lua/5.1/resty/core.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty.so'
        no file '/usr/local/lib/lua/5.1/resty.so'
        no file '/usr/local/lib/lua/5.1/loadall.so') in /usr/local/nginx/conf/nginx.conf:222

原因分析:

找不到lualib库和resty模块,默认到/usr/local/lib/ 去找lualib,然而在编译安装OpenResty时lualib库默认放到/usr/local/openresty/lualib
$ ln -s /usr/local/openresty/lualib /usr/local/lib/lua 
$ ln -s /usr/local/openresty/lualib/resty /usr/local/lib

如果是之前已配置“ln -s /usr/local/openresty/lualib/resty /usr/local/lib”,本次执行“/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf”仍报上述错误,则删除已有的软连接,重新执行“ln -s /usr/local/openresty/lualib/resty /usr/local/lib”

解决:

 # cd /usr/local/lib
 # ls
libluajit-5.1.a  libluajit-5.1.so  libluajit-5.1.so.2  libluajit-5.1.so.2.1.0  lua  pkgconfig  resty
 # rm -rf ./resty
 # ln -s /usr/local/openresty/lualib/resty /usr/local/lib
 # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

nginx: [alert] detected a LuaJIT version which is not OpenResty’s; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty’s LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)

nginx添加lua模块,需要准备两个模块:

  • ngx_devel_kit: NDK(nginx development kit)模块是一个拓展nginx服务器核心功能的模块,第三方模块开发可以基于它来快速实现。NDK提供函数和宏处理一些基本任务,减轻第三方模块开发的代码量。
  • lua-nginx-module: 将Lua的功能嵌入到Nginx HTTP服务器中。
$ mkdir ngx_module
$ wget https://github.com/vision5/ngx_devel_kit/archive/v0.3.1.tar.gz
$ tar -xvf v0.3.1.tar.gz

$ wget https://github.com/openresty/lua-nginx-module/archive/v0.10.14.tar.gz
$ tar -xvf v0.10.14.tar.gz

目前lua-nginx-module的最新release版本是v0.10.19,使用该版本在测试过程中遇到报错如下:

nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
	no field package.preload['resty.core']
	no file './resty/core.lua'
	no file '/usr/local/share/luajit-2.1.0-beta3/resty/core.lua'
	no file '/usr/local/share/lua/5.1/resty/core.lua'
	no file '/usr/local/share/lua/5.1/resty/core/init.lua'
	no file './resty/core.so'
	no file '/usr/local/lib/lua/5.1/resty/core.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file './resty.so'
	no file '/usr/local/lib/lua/5.1/resty.so'
	no file '/usr/local/lib/lua/5.1/loadall.so') in /usr/local/src/nginx/conf/nginx.conf:117

以下链接给出了答案,用lua-nginx-module-0.10.14,不要用lua-nginx-module-0.10.19

测试是否安装成功

nginx.conf配置文件添加以下代码:

location /hello_lua {
    content_by_lua 'ngx.say("hello, lua!")';
}

通过curl进行测试:

$ curl http://127.0.0.1/hello_lua
hello, lua!

Nginx启动报错[emerg] getpwnam(“nginx”) failed

[root@jdev03v conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] getpwnam("nginx") failed
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

原因:Nginx编译的时候指定了用户组和用户,但是系统中并没有这个用户导致的问题

解决方法:新建相应的用户组和用户名,或者不指定用户组和用户名重新编译一次Nginx

groupadd nginx
useradd -g nginx -s /sbin/nologin nginx 

安装nginx+lua时提示:./configure: error: ngx_http_lua_module requires the Lua library.

上回在安装nginx+lua时过程中,在执行./configure命令时提示错误: error: ngx_http_lua_module requires the Lua library,而我确实已经安装luajit(LuaJIT:LuaJIT is a Just-In-Time Compiler (JIT) for the Lua programming language. lua的高效率版本)。在执行.configure时也导入了export LUAJIT_LIB和export LUAJIT_INC的目录路径。如下:

export LUAJIT_LIB=/opt/modules/luajit/lib
export LUAJIT_INC=/opt/modules/luajit/include/luajit-2.0
Fix:
yum install -y lua-devel

lua-devel:Development files for lua,即是lua的开发包,在centos里很多时候都需要安装这么一个开发包的东西:*-devel,记得之前安装过一个python-devel。与此有类似。

如果make的时候出现ngx_http_lua_socket_udp.h:34: 错误:expected specifier-qualifi。可尝试换个lua-nginx-module版本进行编译。

安装nginx环境(含lua)时遇到报错ngx_http_lua_common.h:20:20: error: luajit.h: No such file or directory的解决

下面是安装nginx+lua环境时使用的相关模块及版本,ngx_devel_kit和lua-nginx-module模块用的都是github上最新的模块.并进行了LuaJIT的安装。

#Install nginx by 2019-12-12
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
useradd  -s /sbin/nologin   -M   nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.14.2.tar.gz
wget http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.14.tar.gz
wget http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz\
git clone git://github.com/yzprofile/ngx_http_dyups_module.git
tar zxf v0.3.0.tar.gz
tar zxf LuaJIT-2.1.0-beta3.tar.gz
tar zxf v0.10.14.tar.gz
tar zxf nginx-1.14.2.tar.gz
yum -y  install lua-devel
cd LuaJIT-2.1.0-beta3
make && make install
cd ..
cd nginx-1.14.2
 
./configure --prefix=/usr/local/nginx --sbin-path=/usr/bin/nginx   --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module  --with-pcre --with-http_stub_status_module  --with-http_addition_module --with-http_gzip_static_module  --with-file-aio --with-http_dav_module --add-module=../ngx_devel_kit-0.3.0 --add-module=../lua-nginx-module-0.10.14 --add-module=../ngx_http_dyups_module
make
make install
[root@lua src]# ll
total 3520
-rw-r--r--  1 root  root     1213 Dec 12 17:12 install-nginx.sh
drwxr-xr-x  6 nginx nginx     100 May  2  2017 LuaJIT-2.1.0-beta3
-rw-r--r--  1 root  root  1025180 May  2  2017 LuaJIT-2.1.0-beta3.tar.gz
drwxrwxr-x 10 root  root      225 Feb 24  2019 lua-nginx-module-0.10.14
-rw-r--r--  1 root  root   829900 Dec 12 17:23 lua-nginx-module-master.zip
drwxr-xr-x  9  1001  1001     186 Dec 12 16:57 nginx-1.14.2
-rw-r--r--  1 root  root  1015384 Dec  4  2018 nginx-1.14.2.tar.gz
drwxrwxr-x  9 root  root      221 May 10  2016 ngx_devel_kit-0.3.0
drwxr-xr-x  4 root  root      187 Dec 12 17:04 ngx_http_dyups_module
-rw-r--r--  1 root  root   654097 Dec 12 16:56 v0.10.14.tar.gz
-rw-r--r--  1 root  root    66455 Dec 12 16:56 v0.3.0.tar.gz

.configure执行是成功的,但是在进行make的时候遇到报错:ngx_http_lua_common.h:20:20: error: luajit.h: No such file or directory,详细报错内容如下:

In file included from ../lua-nginx-module-0.10.15/src/ngx_http_lua_script.h:11:0,
                 from ../lua-nginx-module-0.10.15/src/ngx_http_lua_script.c:13:
../lua-nginx-module-0.10.14/src/ngx_http_lua_common.h:20:20: fatal error: luajit.h: No such file or directory
#include <luajit.h>
                    ^
compilation terminated.
make[1]: *** [objs/addon/src/ngx_http_lua_script.o] Error 1
make[1]: Leaving directory `/usr/local/src/nginx-1.14.2'
make: *** [build] Error 2

解决方法:把lib的路径写入/etc/profile中

# vim /etc/profile
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/user/local/include/luajit-2.1
# source /etc/profile

重新编译即可成功!

[root@lua src]# nginx
nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
[root@lua src]# find / -name libluajit-5.1.so.2
/usr/local/lib/libluajit-5.1.so.2
[root@lua src]# ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
[root@lua src]# nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/bin/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-pcre --with-http_stub_status_module --with-http_addition_module --with-http_gzip_static_module --with-file-aio --with-http_dav_module --add-module=../ngx_devel_kit-0.3.0 --add-module=../lua-nginx-module-0.10.14 --add-module=../ngx_http_dyups_module

Reference

写在最后

欢迎大家关注鄙人的公众号【麦田里的守望者zhg】,让我们一起成长,谢谢。
微信公众号

  PHP知识库 最新文章
Laravel 下实现 Google 2fa 验证
UUCTF WP
DASCTF10月 web
XAMPP任意命令执行提升权限漏洞(CVE-2020-
[GYCTF2020]Easyphp
iwebsec靶场 代码执行关卡通关笔记
多个线程同步执行,多个线程依次执行,多个
php 没事记录下常用方法 (TP5.1)
php之jwt
2021-09-18
上一篇文章           查看所有文章
加:2022-03-31 23:44:14  更:2022-03-31 23:45:43 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/23 6:56:47-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码