本地VMware编译安装PHP和Nginx组成本地PHP调试环境

2024年10月10日

我以前调试PHP代码,一直都是在真实环境中进行调试了,但这会影响到环境的运行,所以就想着本地安装个环境进行调试。

1、VMware® Workstation 17 Pro 17.5.2 build-23775571

2、Centos6.10

3、Debian12

4、PHP 7.0.33 (cli) (built: Oct 10 2024 09:07:20) ( NTS )

5、Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

6、nginx/1.22.0

原本我是想本地安装军哥的Lnmp1.9的,恰好我有lnmp1.9-full完整安装包,这些安装包是lnmp出事传闻之前我就已经下载到本地备份的了,但是不知道为什么,我连续用了Debian12和Centos6.10两个系统都无法安装,均是提示错误,但这是另外一个话题了,相关的错误我也发到lnmp官方论坛了,但仍然没有人回复。

所以我就换了一个思路,用lnmp1.9-full带的php-7.0.33.tar.bz2和nginx-1.22.0.tar.gz两个安装包进行编译安装

编译安装Php7.0.33

yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel \
 freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses \
 ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap \
 openldap-devel nss_ldap openldap-clients openldap-servers libxslt-devel libxslt httpd-devel
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-curl --with-freetype-dir \
 --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl \
 --with-pcre-regex --with-pdo-mysql --with-apxs2 --with-gd \
 --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
make && make install

Make提示出錯

/usr/bin/ld: warning: libssl.so.10, needed by /usr/lib/libssh2.so.1, may conflict with libssl.so.1.1
/usr/bin/ld: warning: libssl.so.10, needed by /usr/lib/libssh2.so.1, may conflict with libssl.so.1.1
/usr/bin/ld: warning: libcrypto.so.10, needed by /usr/lib/libssh2.so.1, may conflict with libcrypto.so.1.1
/usr/bin/ld: warning: libcrypto.so.10, needed by /usr/lib/libssh2.so.1, may conflict with libcrypto.so.1.1
ext/gd/libgd/.libs/gdkanji.o: In function `do_convert':
/home/RucLinux/php-7.0.33/ext/gd/libgd/gdkanji.c:349: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/gd/libgd/gdkanji.c:364: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/gd/libgd/gdkanji.c:380: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_dtor':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:2557: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_strlen':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:755: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:779: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:813: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_appendl':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:474: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:508: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `_php_iconv_mime_decode':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1505: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1998: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:2001: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1616: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1619: undefined reference to `libiconv_open'
ext/iconv/.libs/iconv.o: In function `_php_iconv_substr':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:876: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:900: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:955: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:959: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:908: undefined reference to `libiconv_open'
ext/iconv/.libs/iconv.o: In function `_php_iconv_mime_encode':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1194: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1208: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1326: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1278: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1310: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1470: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1379: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1411: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1467: undefined reference to `libiconv_close'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1454: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `php_iconv_string':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:578: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:590: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:608: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:618: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_strpos':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1003: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1031: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:1145: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_append_bucket':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:2711: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:2629: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':
/home/RucLinux/php-7.0.33/ext/iconv/iconv.c:2583: undefined reference to `libiconv_open'
ext/xmlrpc/libxmlrpc/.libs/encodings.o: In function `convert':
/home/RucLinux/php-7.0.33/ext/xmlrpc/libxmlrpc/encodings.c:74: undefined reference to `libiconv_open'
/home/RucLinux/php-7.0.33/ext/xmlrpc/libxmlrpc/encodings.c:82: undefined reference to `libiconv'
/home/RucLinux/php-7.0.33/ext/xmlrpc/libxmlrpc/encodings.c:102: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1

解决办法:

vi Makefile 
找到下面这行:
EXTRA_LIBS = -lcrypt ...在最后添加-liconv保存后make通过;make install通过。

 

添加PHP配置conf文件:

cp /home/RucLinux/php-7.0.33/php.ini-production /usr/local/php/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

如果路径不对或文件复制出错,请使用以下使行进行查找。

find / -name php.ini-production
find / -name php-fpm.conf.default
find / -name www.conf.default

 

PHP 启动 重启 停止启动:

/etc/init.d/php-fpm start
/etc/init.d/php-fpm stop
/etc/init./php-fpm restart
ps -ef | grep php

 

编译安装nginx

./configure --user=nginx \
--group=nginx \
--prefix=/usr/local/nginx/1.22.0 \
--conf-path=/usr/local/etc/nginx/1.22.0/nginx.conf \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre

make && make install
启动nginx
cd /usr/local/nginx/1.22.0/sbin/
./nginx

退出nginx
cd /usr/local/nginx/1.22.0/sbin/
./nginx -s quit

重启Nginx
cd /usr/local/nginx/1.22.0/sbin/
./nginx -s reload

如果看到下面的这个图片,说明安装成功了。

 

添加nginx.conf配置文件

cp /usr/local/etc/nginx/1.22.0/nginx.conf.default /usr/local/etc/nginx/1.22.0/nginx.conf

如果路径不对或文件复制出错,请使用以下使行进行查找。

find / -name nginx.conf.default

nginx.conf配置网站:

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       [::]:80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /home/wwwroot/default/;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /home/wwwroot/default/;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        
        location ~ \.php$ {
            root           /home/wwwroot/default/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/wwwroot/default/$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

 


sicnature ---------------------------------------------------------------------
I P 地 址: 3.139.67.157
区 域 位 置: 美国
系 统 信 息: 美国
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://myzhenai.com.cn/post/4578.html

没有评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注