Fixed installation
parent
82dc2aad6d
commit
d6c17a99ea
|
@ -218,47 +218,54 @@ if [ -f "wp-config.php" ]; then
|
|||
fi
|
||||
|
||||
# Download WordPress core if not already present
|
||||
if [ ! -f "wp-config.php" ]; then
|
||||
echo -e "${YELLOW}Downloading WordPress core...${NC}"
|
||||
if [ ! -f "index.php" ] && [ ! -d "wp-admin" ]; then
|
||||
echo -e "${YELLOW}WordPress files not detected. Downloading WordPress core...${NC}"
|
||||
wp core download --skip-content --allow-root
|
||||
|
||||
# Get the latest Twenty* theme
|
||||
echo -e "${YELLOW}Detecting latest Twenty* theme...${NC}"
|
||||
mkdir -p wp-content/themes
|
||||
LATEST_TWENTY_THEME=$(wp theme search twenty --fields=name,version --format=csv --allow-root | grep "^twenty" | sort -V | tail -n 1 | cut -d',' -f1)
|
||||
|
||||
if [ -n "$LATEST_TWENTY_THEME" ]; then
|
||||
echo -e "${YELLOW}Installing latest WordPress default theme: $LATEST_TWENTY_THEME${NC}"
|
||||
wp theme install "$LATEST_TWENTY_THEME" --activate --allow-root
|
||||
else
|
||||
echo -e "${RED}Could not detect latest Twenty* theme. Falling back to twentytwentyfive${NC}"
|
||||
wp theme install twentytwentyfive --activate --allow-root
|
||||
fi
|
||||
# Now WordPress core installation will handle theme installation automatically
|
||||
# since we removed the --skip-themes flag from the wp core install command
|
||||
echo -e "${GREEN}WordPress core downloaded successfully${NC}"
|
||||
else
|
||||
echo -e "${GREEN}WordPress files already exist. Skipping download.${NC}"
|
||||
fi
|
||||
|
||||
# Create wp-config.php with the new database credentials
|
||||
echo -e "${YELLOW}Creating wp-config.php...${NC}"
|
||||
echo -e "${YELLOW}Attempting to use WP-CLI to create config with these parameters:${NC}"
|
||||
echo -e "Database: $DB_NAME"
|
||||
echo -e "User: $DB_USER"
|
||||
echo -e "Password: $DB_PASSWORD"
|
||||
echo -e "Host: $DB_HOST"
|
||||
|
||||
# Try to create wp-config.php with WP-CLI first (with error output captured)
|
||||
wp config create --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASSWORD" --dbhost="$DB_HOST" --allow-root --debug || {
|
||||
echo -e "${RED}WP-CLI config create failed. Error code: $?${NC}"
|
||||
|
||||
# Create wp-config.php manually regardless of whether WP-CLI command succeeded
|
||||
echo -e "${YELLOW}Creating wp-config.php manually as a fallback...${NC}"
|
||||
# Immediate check to directly create wp-config.php regardless of previous steps
|
||||
# This is a critical fix to ensure wp-config.php exists before installation continues
|
||||
echo -e "${YELLOW}CRITICAL FIX: Directly creating wp-config.php to prevent errors...${NC}"
|
||||
if [ ! -f "wp-config.php" ]; then
|
||||
echo -e "${RED}wp-config.php is still missing. Creating it directly...${NC}"
|
||||
cat > wp-config.php <<EOF
|
||||
<?php
|
||||
define( 'WP_CACHE', true );
|
||||
|
||||
/**
|
||||
* The base configuration for WordPress
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// ** Database settings - You can get this info from your web host ** //
|
||||
/** The name of the database for WordPress */
|
||||
define( 'DB_NAME', '${DB_NAME}' );
|
||||
|
||||
/** Database username */
|
||||
define( 'DB_USER', '${DB_USER}' );
|
||||
|
||||
/** Database password */
|
||||
define( 'DB_PASSWORD', '${DB_PASSWORD}' );
|
||||
|
||||
/** Database hostname */
|
||||
define( 'DB_HOST', '${DB_HOST}' );
|
||||
|
||||
/** Database charset to use in creating database tables. */
|
||||
define( 'DB_CHARSET', 'utf8' );
|
||||
|
||||
/** The database collate type. Don't change this if in doubt. */
|
||||
define( 'DB_COLLATE', '' );
|
||||
|
||||
/**
|
||||
* Authentication unique keys and salts.
|
||||
*/
|
||||
define( 'AUTH_KEY', '$(openssl rand -base64 48)' );
|
||||
define( 'SECURE_AUTH_KEY', '$(openssl rand -base64 48)' );
|
||||
define( 'LOGGED_IN_KEY', '$(openssl rand -base64 48)' );
|
||||
|
@ -268,32 +275,49 @@ define( 'SECURE_AUTH_SALT', '$(openssl rand -base64 48)' );
|
|||
define( 'LOGGED_IN_SALT', '$(openssl rand -base64 48)' );
|
||||
define( 'NONCE_SALT', '$(openssl rand -base64 48)' );
|
||||
|
||||
/**
|
||||
* WordPress database table prefix.
|
||||
*/
|
||||
\$table_prefix = 'wp_';
|
||||
|
||||
/* Custom values */
|
||||
define( 'WP_AUTO_UPDATE_CORE', false );
|
||||
define( 'WP_HOME', 'https://${DOMAIN}' );
|
||||
define( 'WP_SITEURL', 'https://${DOMAIN}' );
|
||||
define( 'WP_MEMORY_LIMIT', '256M' );
|
||||
|
||||
/**
|
||||
* For developers: WordPress debugging mode.
|
||||
*/
|
||||
define( 'WP_DEBUG', false );
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
define( 'ABSPATH', __DIR__ . '/' );
|
||||
// Fix for HTTP_HOST issue when running WP-CLI
|
||||
if (!isset(\$_SERVER['HTTP_HOST'])) {
|
||||
\$_SERVER['HTTP_HOST'] = '${DOMAIN}';
|
||||
}
|
||||
|
||||
/** Absolute path to the WordPress directory. */
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
define( 'ABSPATH', __DIR__ . '/' );
|
||||
}
|
||||
|
||||
/** Sets up WordPress vars and included files. */
|
||||
require_once ABSPATH . 'wp-settings.php';
|
||||
EOF
|
||||
}
|
||||
echo -e "${GREEN}wp-config.php created directly with fixed method${NC}"
|
||||
|
||||
# Verify that wp-config.php was created successfully (either method)
|
||||
if [ ! -f "wp-config.php" ]; then
|
||||
echo -e "${RED}CRITICAL ERROR: wp-config.php could not be created by either method.${NC}"
|
||||
echo -e "${YELLOW}Checking directory permissions:${NC}"
|
||||
ls -la
|
||||
echo -e "${YELLOW}Checking if we can write to the directory:${NC}"
|
||||
touch test_write_access && echo "Write access confirmed" && rm test_write_access
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}wp-config.php exists. Continuing with installation.${NC}"
|
||||
# Just to make sure, set the right permissions
|
||||
# Ensure file was created and is readable
|
||||
ls -la wp-config.php
|
||||
chmod 644 wp-config.php
|
||||
chown litespeed:litespeed wp-config.php
|
||||
echo -e "${GREEN}wp-config.php permissions fixed${NC}"
|
||||
else
|
||||
echo -e "${GREEN}wp-config.php already exists. Continuing...${NC}"
|
||||
fi
|
||||
|
||||
# Skip the normal wp-config.php creation process since we've already handled it directly
|
||||
echo -e "${YELLOW}Continuing with WordPress installation...${NC}"
|
||||
|
||||
# Set proper permissions
|
||||
echo -e "${YELLOW}Setting proper permissions...${NC}"
|
||||
sudo chown -R litespeed:litespeed "$WP_ROOT"
|
||||
|
@ -310,7 +334,6 @@ if ! wp core is-installed --allow-root; then
|
|||
--admin_password="$WP_ADMIN_PASS" \
|
||||
--admin_email="$WP_ADMIN_EMAIL" \
|
||||
--skip-plugins \
|
||||
--skip-themes \
|
||||
--allow-root
|
||||
|
||||
# Remove default plugins if any were installed
|
||||
|
|
Loading…
Reference in New Issue