Class PhpUserDataBuilder
java.lang.Object
com.cloudforgeci.api.core.PhpUserDataBuilder
UserData builder extension for PHP applications on EC2.
Provides helper methods for installing and configuring PHP, NGINX, and CMS platforms on Amazon Linux 2023 EC2 instances.
Usage Example:
public void configureUserData(UserDataBuilder builder, Ec2Context context) {
builder.addSystemUpdate();
PhpRuntimeConfig config = PhpRuntimeConfig.forWordPress();
PhpUserDataBuilder.installPhp(builder, config);
PhpUserDataBuilder.installNginx(builder);
PhpUserDataBuilder.installWordPress(builder, "/var/www/html");
// Mount storage
if (context.hasEfs()) {
builder.mountEfs(...);
}
}
- Since:
- 3.1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcompleteInstallation(UserDataBuilder builder, CmsSpec spec, PhpRuntimeConfig config, String documentRoot) Complete CMS installation with all standard components.static voidconfigureCron(UserDataBuilder builder, CmsSpec spec, String siteUrl) Configure system cron for CMS scheduled tasks.static voidconfigureNginx(UserDataBuilder builder, String nginxConfig) Configure NGINX with a provided configuration.static voidconfigurePhpFpm(UserDataBuilder builder, PhpRuntimeConfig config) Configure PHP-FPM pool settings.static voidconfigurePhpIni(UserDataBuilder builder, PhpRuntimeConfig config) Configure PHP memory limits, execution time, and other settings.static voidconfigureRedisCache(UserDataBuilder builder, String redisHost, int redisPort) Install Redis PHP extension and configure for object caching.static voidconfigureSELinux(UserDataBuilder builder, String documentRoot) Configure SELinux for PHP/NGINX (if enabled).static voidinstallCloudWatchAgent(UserDataBuilder builder, String logGroupName, CmsSpec spec) Install and configure CloudWatch Agent for PHP logs.static voidinstallComposer(UserDataBuilder builder) Install Composer for PHP dependency management.static voidinstallDrush(UserDataBuilder builder) Install Drush for Drupal management.static voidInstall Magento CLI dependencies.static voidinstallNginx(UserDataBuilder builder) Install NGINX web server.static voidinstallPhp(UserDataBuilder builder, PhpRuntimeConfig config) Install PHP and required extensions on Amazon Linux 2023.static voidinstallWordPress(UserDataBuilder builder, String installPath) Download and install WordPress.static voidinstallWpCli(UserDataBuilder builder) Install WP-CLI for WordPress management.static voidsetFilePermissions(UserDataBuilder builder, String documentRoot, String webUser, String webGroup) Set up file permissions for CMS directory.
-
Method Details
-
installPhp
Install PHP and required extensions on Amazon Linux 2023.- Parameters:
builder- the UserDataBuilderconfig- the PHP runtime configuration
-
configurePhpIni
Configure PHP memory limits, execution time, and other settings.- Parameters:
builder- the UserDataBuilderconfig- the PHP runtime configuration
-
configurePhpFpm
Configure PHP-FPM pool settings.- Parameters:
builder- the UserDataBuilderconfig- the PHP runtime configuration
-
installNginx
Install NGINX web server.- Parameters:
builder- the UserDataBuilder
-
configureNginx
Configure NGINX with a provided configuration.- Parameters:
builder- the UserDataBuildernginxConfig- the NGINX configuration content
-
installWpCli
Install WP-CLI for WordPress management.- Parameters:
builder- the UserDataBuilder
-
installWordPress
Download and install WordPress.- Parameters:
builder- the UserDataBuilderinstallPath- the installation directory
-
installComposer
Install Composer for PHP dependency management.- Parameters:
builder- the UserDataBuilder
-
installDrush
Install Drush for Drupal management.- Parameters:
builder- the UserDataBuilder
-
installMagentoDependencies
Install Magento CLI dependencies.- Parameters:
builder- the UserDataBuilder
-
configureCron
Configure system cron for CMS scheduled tasks.- Parameters:
builder- the UserDataBuilderspec- the CMS specificationsiteUrl- the site URL
-
configureRedisCache
Install Redis PHP extension and configure for object caching.- Parameters:
builder- the UserDataBuilderredisHost- Redis server hostnameredisPort- Redis server port
-
installCloudWatchAgent
public static void installCloudWatchAgent(UserDataBuilder builder, String logGroupName, CmsSpec spec) Install and configure CloudWatch Agent for PHP logs.- Parameters:
builder- the UserDataBuilderlogGroupName- CloudWatch log group namespec- the CMS specification
-
setFilePermissions
public static void setFilePermissions(UserDataBuilder builder, String documentRoot, String webUser, String webGroup) Set up file permissions for CMS directory.- Parameters:
builder- the UserDataBuilderdocumentRoot- document root pathwebUser- web server user (e.g., "nginx", "www-data")webGroup- web server group
-
configureSELinux
Configure SELinux for PHP/NGINX (if enabled).- Parameters:
builder- the UserDataBuilderdocumentRoot- document root path
-
completeInstallation
public static void completeInstallation(UserDataBuilder builder, CmsSpec spec, PhpRuntimeConfig config, String documentRoot) Complete CMS installation with all standard components.- Parameters:
builder- the UserDataBuilderspec- the CMS specificationconfig- the PHP runtime configurationdocumentRoot- document root path
-