Cannot Install Composer Using Swap Files

Asked 2 years ago, Updated 2 years ago, 90 views

AWS EC2 is trying to initialize an instance of CentOS automatically created with Auto Scaling with a shell script.

In that case, if you try to install Composer normally, you will experience an error due to lack of memory.
When I heard that I could create a swap file and deal with it, I wrote the following

#Generate as swap file for composer
sudo/bin/ddif=/dev/zero of=/var/swap.1bs=1M count=1024
sudo/sbin/mkswap/var/swap.1
sudo/sbin/swapon/var/swap.1

# Install composer
cd/var/www/html
php-r "copy('https://getcomposer.org/installer','composer-setup.php');"
php composer-setup.php
php-r "unlink('composer-setup.php');"
php composer.phar install

However, when I checked the instance that was created, I found that Composer was not installed.
I know it's mossy when I install Composer because it's ready to create a swap file.

To see how it was mossy, I started up an original CentOS instance and copied the contents of the shell script in order, but this method successfully installed it.

What are the possible causes of failure only when initializing with shell scripts?

php centos shellscript composer

2022-09-30 21:40

1 Answers

Does PHP pass?

 echo "I've made it this far" > logfile

I don't know if it's a good idea to check how far it's going by putting a line like this.
If you include the command output and return value, it will be easier to determine the cause.


2022-09-30 21:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.