本人以编写shell脚本,一键安装配置php7.3为例
前提:本脚本在Linux /opt/目录下运行
首先解压php压缩包
###### 配置nginx,带lua支持 #################################################tar -zxvf /opt/php-7.3.30.tar.gzif [ $? -eq 0 ];then echo `date "+%y-%m-%d %H:%M:%S"` "\nphp解压成功" | tee -a /opt/wnote_install.logelse echo `date "+%y-%m-%d %H:%M:%S"` "\nphp解压失败" | tee -a /opt/wnote_install.log exit 1fi
配置php安装路径和模块
当时用以下语句运行configure时,发现cd命令实际上是没有用的,程序并没有切换到/opt/php-7.3.30/目录下执行configure,运行脚本时出现错误,无法按照configure的参数进行配置
cd /opt/php-7.3.30/./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-openssl --with-libxml-dir --with-zlib --enable-mbstring --with-mysqli=mysqlnd --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-sockets --with-curl --enable-maintainer-zts
使用下列命令也不可以
/opt/php-7.3.30/configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-openssl --with-libxml-dir --with-zlib --enable-mbstring --with-mysqli=mysqlnd --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-sockets --with-curl --enable-maintainer-zts
查阅网友的经验,发现某网友提供的代码中,在cd命令后面的路径名加上了双引号,经测试成功运行,如下列代码所示,但是本人并没有在网络上查找到cd命令的这种用法解释,本人网络小白一个并未能分析出原因,欢迎各位网友在评论区给出权威解答
#配置php安装路径和模块、进行编译和安装▲cd "/opt/php-7.3.30/" #切换到该目录下执行下一条命令./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-openssl --with-libxml-dir --with-zlib --enable-mbstring --with-mysqli=mysqlnd --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-sockets --with-curl --enable-maintainer-ztsif [ $? -eq 0 ];then echo `date "+%y-%m-%d %H:%M:%S"` "\nphp安装路径和模块配置成功" | tee -a /opt/wnote_install.logelse echo `date "+%y-%m-%d %H:%M:%S"` "\nphp安装路径和模块配置失败,请检查故障" | tee -a /opt/wnote_install.log exit 1fi
来源地址:https://blog.csdn.net/h11016616/article/details/130047259