shell_exec sh file including npm, npx

Viewed 17

I have a .sh file that I execute from PHP with the shell_exec command. The .sh files are like below. It creates the directories and "npm init -yes" line is executed successfully and I get the return lines but "npm install --save-dev hardhat" and "npx hardhat" lines have no return and don't do what expected to. Any idea how can I execute it and it works? When I execute the .sh file with root on the terminal it works also. But not with user apache.

cd /var/nftprojects
mkdir nft57
cd nft57
chmod -R 777  /var/nftprojects/nft57
mkdir ethereum
chmod -R 777  /var/nftprojects/nft57/ethereum
cd ethereum
npm init -yes
npm install --save-dev hardhat
npx hardhat --verbose
cd /var/nftprojects/nft57
mkdir /var/nftprojects/nft57/web
cd /var/nftprojects/nft57/web
npx create-next-app@latest
cd /var/nftprojects/nft57/ethereum
touch .env
npm install dotenv --save
0 Answers
Related