- Newest
- Most votes
- Most comments
To enable the sodium module for PHP in AWS CodeBuild using the aws/codebuild/standard:7.0 image, you need to compile and install the module during the build process. Since libsodium-dev is already installed in the system, you can use pecl to install the sodium extension. Here's how you can modify your buildspec to achieve this:
- First, ensure you're using the correct PHP version in your runtime-versions.
- Use pecl to install the sodium extension.
- Enable the extension in your PHP configuration.
- Verify the installation.
Here's an example of how your buildspec's install phase could look:
phases: install: runtime-versions: php: 8.2 commands: - pecl install libsodium - echo "extension=sodium.so" >> /root/.phpenv/versions/8.2/etc/php.ini - php -m | grep sodium finally: - echo 'Installation complete' build: # Your build commands here
This approach should successfully install and enable the sodium module for PHP in your CodeBuild environment. The pecl install command will compile and install the sodium extension, and then we add it to the PHP configuration file.
If you encounter any issues, you may need to install additional dependencies or update existing ones. In such cases, you could add commands like apt-get update and apt-get install -y followed by any necessary packages before the pecl install command.
Remember that these changes will only persist for the duration of the build. If you find yourself needing this extension frequently, you might want to consider creating a custom Docker image that includes the sodium extension pre-installed, which you can then use as your CodeBuild environment.
Sources
Managed Build Server - AWS CodeBuild Features - AWS
Troubleshooting AWS CodeBuild - AWS CodeBuild
Build specification reference for CodeBuild - AWS CodeBuild
answered 2 years ago
Relevant content
asked 7 years ago
asked 3 years ago
asked 7 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 10 months ago

pecl is not available in the aws/codebuild/standard:7.0 image: