首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法通过PHP执行.sh文件

问无法通过PHP执行.sh文件
EN

Stack Overflow用户
提问于 2018-02-06 12:55:44
回答 1查看 66关注 0票数 0

我正在尝试通过.sh文件备份数据库。如果我手动打开这个文件,它工作得很好。但是我正在尝试用PHP(laravel)来做这件事。

这是我的mysql_backup.sh文件:

代码语言:javascript
复制
#!/bin/bash

#
#   Use this script to perform backups of one or more MySQL databases.
#

# Databases that you wish to be backed up by this script. You can have any number of databases specified; encapsilate each database name in single quotes and separate each database name by a space.
#
# Example:
# databases=( '__DATABASE_1__' '__DATABASE_2__' )
databases=('sasty')

# The host name of the MySQL database server; usually 'localhost'
db_host="127.0.0.1"

# The port number of the MySQL database server; usually '3306'
db_port="3306"

# The MySQL user to use when performing the database backup.
db_user="root"

# The password for the above MySQL user.
db_pass=""

# Directory to which backup files will be written. Should end with slash ("/").
backups_dir="C:/Users/Kapil/backup/"

backups_user=""

# Date/time included in the file names of the database backup files.
datetime=$(date +'%Y-%m-%dT%H:%M:%S')

for db_name in ${databases[@]}; do
        # Create database backup and compress using gzip.
        C:/xampp/mysql/bin/mysqldump -u $db_user -h $db_host -P $db_port --password=$db_pass $db_name | gzip -9 > $backups_dir$db_name--$datetime.sql.gz
done

# Set appropriate file permissions/owner.
chown $backups_user:$backups_user $backups_dir*--$datetime.sql.gz
chmod 0400 $backups_dir*--$datetime.sql.gz

我使用PHP代码来实现这一点

代码语言:javascript
复制
shell_exec('/path/to/my/file');

但它不起作用。但是,shell_exec('ls')工作正常。如何解决我的问题?

EN

回答 1

Stack Overflow用户

发布于 2018-02-06 13:05:28

php.ini

disable_functions =exec、passthru、shell_exec、system、proc_open、popen、curl_exec、curl_multi_exec、parse_ini_file、show_source

删除shell_exec

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48635744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档