• ericosman

    (@ericosman)


    Hi,

    I try to automate the creation of installing WP in my DA, But i keep getting the following issue:

    ERROR 1045 (28000): Access denied for user 'admin_wpb19d'@'localhost' (using password: YES) Error: 'wp-config.php' not found. Either create one manually or use wp config create. Error: 'wp-config.php' not found. Either create one manually or use wp config create.

    And i think thats strange, because i tell it to create a wp-config.php file:

    su -s /bin/bash -c "/usr/local/bin/wp config create --dbname=$wpconfigdbuser --dbuser=$wpconfigdbuser --dbpass=$dbpass --dbhost=localhost" $username

    Here is the full code:

    #!/bin/bash# CHECK CUSTOM PKG ITEM INSTALLWP# THIS DOES NOT CURRENTLY WORK WITH SUBDOMAINS#if [[ $installWP != 'ON' ]]; then#  exit 0;#else# ENABLE ERROR LOGGING# exec 2>/usr/local/directadmin/customscripts.error.log# SET UP DATABASE VARIABLESdbpass=$(openssl rand -base64 12) > /dev/nullext=$(openssl rand -hex 2) > /dev/nulldbuser="wp${ext}"    # do not include the username_ for dataskq here as DA adds thiswpconfigdbuser="${username}_wp${ext}"wpadminpass=$(openssl rand -base64 14) > /dev/null# CHECK IF WORDPRESS EXISTSif [ -f /home/$username/domains/$domain/public_html/$subdomain/index.php ]; thenecho "WARNING: There appears to be an index file already located in this directory, which indicates that an installation is already present! Empty the directory before running the script again."exitelse# DISABLE DIRECTADMIN INDEX.HTML FILEif [ -f /home/$username/domains/$subdomain.$domain/public_html/index.html ]; thenmv /home/$username/domains/$subdomain.$domain/public_html/index.html{,.bak}fi# CREATE DATABASE/usr/bin/mysqladmin -uda_admin -p$(cat /usr/local/directadmin/conf/mysql.conf | grep pass | cut -d\= -f2 ) create ${wpconfigdbuser};echo "CREATE USER ${wpconfigdbuser} IDENTIFIED BY '${dbpass}';" | mysql -uda_admin -p$(cat /usr/local/directadmin/conf/mysql.conf | grep pass | cut -d\= -f2 );echo "GRANT ALL PRIVILEGES ON ${wpconfigdbuser}.* TO ${wpconfigdbuser} IDENTIFIED BY '${dbpass}';" | mysql -uda_admin -p$(cat /usr/local/directadmin/conf/mysql.conf | grep pass | cut -d\= -f2);# DOWNLOAD WORDPRESScd /home/$username/domains/$subdomain.$domain/public_html/su -s /bin/bash -c "/usr/local/bin/wp core download" $usernamesu -s /bin/bash -c "/usr/local/bin/wp config create"# SET DATABASE DETAILS IN THE CONFIG FILEsu -s /bin/bash -c "/usr/local/bin/wp config create --dbname=$wpconfigdbuser --dbuser=$wpconfigdbuser --dbpass=$dbpass --dbhost=localhost" $username# INSTALL WORDPRESSif [[ $ssl == 'ON' ]]; thensu -s /bin/bash -c "/usr/local/bin/wp core install --url=https://$subdomain.$domain/ --admin_user=$username --admin_password=$wpadminpass --title="$subdomain.$domain" --admin_email=$username@$domain " $usernamesu -s /bin/bash -c "/usr/local/bin/wp rewrite structure '/%postname%/'" $usernameprintf "\n\nWORDPRESS LOGIN CREDENTIALS:\nURL: https://$subdomain.$domain/wp-admin/\nUSERNAME: $username\nPASSWORD: $wpadminpass\n\n"if [[ ! -h /home/$username/domains/$domain/$subdomain.$domain/private_html ]]; thenecho "Making a symlink for https..."cd /home/$username/domains/$subdomain.$domain/rm -rf private_htmlsu -s /bin/bash -c "ln -s public_html private_html" $usernamefielsesu -s /bin/bash -c "/usr/local/bin/wp core install --url=https://$subdomain.$domain/ --admin_user=$username --admin_password=$wpadminpass --title="$subdomain.$domain" --admin_email=$username@$domain " $usernamesu -s /bin/bash -c "/usr/local/bin/wp rewrite structure '/%postname%/'" $usernameprintf "\n\nWORDPRESS LOGIN CREDENTIALS:\nURL: https://$subdomain.$domain/wp-admin/\nUSERNAME: $username\nPASSWORD: $wpadminpass\n\n"fi# ADD LOGIN DETAILS TO TEXT FILEprintf "\n\nWORDPRESS LOGIN CREDENTIALS:\nURL: https://$subdomain.$domain/wp-admin/\nUSERNAME: $username\nPASSWORD: $wpadminpass\n\n" >> /home/$username/domains/$subdomain.$domain/public_html/.wp-details.txtchown $username. /home/$username/domains/$subdomain.$domain/public_html/.wp-details.txtfi# DELETE DOLLY PLUGIN AND INSTALL LITESPEED CACHEsu -s /bin/bash -c "/usr/local/bin/wp plugin delete hello" $usernamesu -s /bin/bash -c "/usr/local/bin/wp plugin install litespeed-cache --activate" $username#su -s /bin/bash -c "/usr/local/bin/wp plugin install litespeed-cache jetpack --activate" $username# CREATE .HTACCESScat << EOF > /home/$username/domains/$subdomain.$domain/public_html/.htaccess# BEGIN WordPressRewriteEngine OnRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]RewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]# END WordPressEOFchown $username. /home/$username/domains/$subdomain.$domain/public_html/.htaccess# CHANGE FILE PERMISSIONScd /home/$username/domains/$subdomain.$domain/public_html/find . -type d -exec chmod 0755 {} \;find . -type f -exec chmod 0644 {} \;# WORDPRESS SECURITY AND HARDENINGchmod 400 /home/$username/domains/$subdomain.$domain/public_html/.wp-details.txtchmod 400 /home/$username/domains/$subdomain.$domain/public_html/wp-config.phpexit 0;

  • The topic ‘WP CLI issue’ is closed to new replies.