广告
返回顶部
首页 > 资讯 > 后端开发 > PHP编程 >关于解决shell脚本中无法用cd命令,在指定文件下运行指定文件的解决方法分享
  • 364
分享到

关于解决shell脚本中无法用cd命令,在指定文件下运行指定文件的解决方法分享

phplinux服务器bash 2023-09-06 17:09:53 364人浏览 泡泡鱼
摘要

本人以编写shell脚本,一键安装配置PHP7.3为例 前提:本脚本在linux  /opt/目录下运行 首先解压php压缩包 ###### 配置Nginx,带lua支持 ##############################

本人以编写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

--结束END--

本文标题: 关于解决shell脚本中无法用cd命令,在指定文件下运行指定文件的解决方法分享

本文链接: https://www.lsjlt.com/news/397270.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作