Easy Wordpress installation for new customers.

Hey guys! Let me look into this script and I'll get back to you all with an updated version!
 
not work script domain_create_post.sh

from
https://www.knownhost.com/wiki/control-panels/directadmin/custom-package-item-creation-example

write:

/usr/local/directadmin/customscripts.error.log

/usr/local/directadmin/scripts/custom/domain_create_post.sh: line 71: warning: here-document at line 57 delimited by end-of-file (wanted `EOF')
/usr/local/directadmin/scripts/custom/domain_create_post.sh: line 72: syntax error: unexpected end of file

chmod chown 700 diradmin
If you copy/paste the script from the site? If you did, it adds leading white spaces to every line which shouldn’t be there, corrupting the EOF declaration. Does it do the same when downloaded?
 
AMENDMENT: It looks like the custom package item isn't being passed as an env variable to the post script as it once was. It is, though, with the custom domain item feature. I'll inquire further and update this thread with what I find.

AMENDMENT2: Use the custom_domain_items.conf instead of the custom_package_items.conf in step3.


Hey, Regarding the KnownHost link, here are updated instructions:


1. install wp-cli
Code:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

2. remove proc_open and proc_close from php.ini disable_functions if there
https://docs.directadmin.com/webservices/php/secure-php/

3. Create the file /usr/local/directadmin/data/admin/custom_package_items.conf with the content below:

Code:
installWP=type=checkbox&string=Install WordPress&desc=Installs WordPress for domains automatically upon creation&checked=yes

Also, don't forget that DirectAdmin now also has custom domain items, so you don't need a custom package item if you would just rather have a checkbox available for each domain you create, regardless of package selection! To use this, you would use this file instead of the custom_package_times.conf file:

/usr/local/directadmin/data/admin/custom_domain_items.conf


4. chown diradmin. /usr/local/directadmin/data/admin/custom_package_items.conf


5. create this file : /usr/local/directadmin/scripts/custom/domain_create_post.sh
Code:
chown diradmin.   /usr/local/directadmin/scripts/custom/domain_create_post.sh
chmod 700   /usr/local/directadmin/scripts/custom/domain_create_post.sh

Add this code:

Code:
#!/bin/bash -x

exec 2>/usr/local/directadmin/customscripts.error.log

if [[ $installWP != 'ON' ]]; then
  exit 0;
else

  #set up DB variables
  dbpass=$(openssl rand -hex 6) > /dev/null
  ext=$(openssl rand -hex 2) > /dev/null
  dbuser="wp${ext}"    # do not include the username_ for dataskq here as DA adds this
  wpconfigdbuser="${username}_wp${ext}"
  wpadminpass=$(openssl rand -hex 6) > /dev/null

  # install wp
  if [ -f /home/$username/domains/$domain/public_html/index.php ]; then
    echo "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."
    exit;
  else

    #Disable DAs index.html file
    if [ -f /home/$username/domains/$domain/public_html/index.html ]; then
      mv /home/$username/domains/$domain/public_html/index.html{,.bak}
    fi

    #Create DB
    /usr/bin/mysqladmin --defaults-extra-file=/usr/local/directadmin/conf/my.cnf create ${wpconfigdbuser};
    echo "CREATE USER ${wpconfigdbuser} IDENTIFIED BY '${dbpass}';" | mysql --defaults-extra-file=/usr/local/directadmin/conf/my.cnf;
    echo "GRANT ALL PRIVILEGES ON ${wpconfigdbuser}.* TO '${wpconfigdbuser}'@'localhost' IDENTIFIED BY '${dbpass}';" | mysql --defaults-extra-file=/usr/local/directadmin/conf/my.cnf;

    #Download WP
    cd /home/$username/domains/$domain/public_html/
    su -s /bin/bash -c "/usr/local/bin/wp core download" $username

    #set database details in the config file
    su -s /bin/bash -c "/usr/local/bin/wp config create --dbname=$wpconfigdbuser --dbuser=$wpconfigdbuser --dbpass=$dbpass --dbhost=localhost" $username

    if [[ $ssl == 'ON' ]]; then
      su -s /bin/bash -c "/usr/local/bin/wp core install --url=https://$domain/ --admin_user=admin --admin_password=$wpadminpass --title= --admin_email=admin@$domain " $username
      su -s /bin/bash -c "/usr/local/bin/wp rewrite structure '/%postname%/'" $username
      printf "\n\nADMIN LOGIN CREDENTIALS:\nURL:https://$domain/wp-admin/\nUSERNAME:admin\nPASSWORD:$wpadminpass\n\n"
      if [[ ! -h /home/$username/domains/$domain/private_html ]]; then
       echo "Making a symlink for https..."
       cd /home/$username/domains/$domain/
       rm -rf private_html
       su -c "ln -s public_html private_html" $username
      fi
    else
      su -s /bin/bash -c "/usr/local/bin/wp core install --url=http://$domain/ --admin_user=admin --admin_password=$wpadminpass --title= --admin_email=admin@$domain " $username
      su -s /bin/bash -c "/usr/local/bin/wp rewrite structure '/%postname%/'" $username
      printf "\n\nADMIN LOGIN CREDENTIALS:\nURL:http://$domain/wp-admin/\nUSERNAME:admin\nPASSWORD:$wpadminpass\n\n"
    fi

    #Create .htaccess
    cat << EOF > /home/$username/domains/$domain/public_html/.htaccess
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
EOF
    chown $username. /home/$username/domains/$domain/public_html/.htaccess
  fi
fi
exit 0;

And that's it! Tested on CentOS 8

If anyone has any trouble, pm me or reply here. :)

NOTE: You would need a separate post script for subdomains and domain pointers.
 
Last edited:
Here is a guide showing how to setup WordPress for domains and subdomains based on the original script from Knownhost. There is also a script to install WordPress when modifying a domain as well.

 
Hi,
i try this but have an error on this part.
ERROR
+ [[ OFF != \O\N ]]
+ exit 0

# CHECK CUSTOM PKG ITEM INSTALLWP
if [[ $installWP != 'ON' ]]; then
exit 0;
else

If i comment that part everything works well but create wordpress for every domain any help?
 
Use the custom domain items as described in step 3 instead of the custom package items. This will give you a checkbox for each newly created domain. :) Let me know if you have any problems.
 
Here is a guide showing how to setup WordPress for domains and subdomains based on the original script from Knownhost. There is also a script to install WordPress when modifying a domain as well.

Where is Custombuild?
Thank You!
 
Hi there!

I wanted a simple Wordpress installer but besides softaculous or installatron there is no free version. I only want my users to install Wordpress so i made a little script.
The files are placed in the /domains/default/ folder of the reselling user so every new user has the script in his public_html at default. The only thing the user has to do is click the install link and enter server, username and password for directadmin. The script then unzips the wordpress zip-file, creates a wp-config.php and a database and password using a random string. After this the script removes itself and redirects to the final setup of Wordpress where you can enter your Site title, username and so on.

You can check the personalized page at https://dev.adema-it.nl/wordpress-installer/default/ i added a whois checker and a few shortlinks to our homepage.
The version in the download link looks like this: https://dev.adema-it.nl/wordpress-installer/wpinstall/
Download link: https://dev.adema-it.nl/wordpress-installer/wordpress-installer.zip

Why i created this:
1. No need to upload Wordpress to every new user.
2. Update once per server for all new users.
3. Add custom plugins and themes to Wordpress default installation.

IMPORTANT: You need to create a new Wordpress zip-file as you can't use the one from the Wordpress site. All the Wordpress files have to be directly in the wordpress.zip. In the official zip-file the files are located in a subfolder called "wordpress" which i didn't want, i wanted Wordpress to be installed in the root of the public_html.

ALSO IMPORTANT: I'm an amateur/hobby scripter. If you like it (or not) let me know. If you have any improvements or tips: let me know. ( i know it's not responsive,yet :p )

LAST THING: feel free to use it for whatever you want :)
The old link is dead, use this one to download: https://adema-it.nl/downloads/wordpress-installer.zip
 
Hi there!

I wanted a simple Wordpress installer but besides softaculous or installatron there is no free version. I only want my users to install Wordpress so i made a little script.
The files are placed in the /domains/default/ folder of the reselling user so every new user has the script in his public_html at default. The only thing the user has to do is click the install link and enter server, username and password for directadmin. The script then unzips the wordpress zip-file, creates a wp-config.php and a database and password using a random string. After this the script removes itself and redirects to the final setup of Wordpress where you can enter your Site title, username and so on.

You can check the personalized page at https://dev.adema-it.nl/wordpress-installer/default/ i added a whois checker and a few shortlinks to our homepage.
The version in the download link looks like this: https://dev.adema-it.nl/wordpress-installer/wpinstall/
Download link: https://dev.adema-it.nl/wordpress-installer/wordpress-installer.zip

Why i created this:
1. No need to upload Wordpress to every new user.
2. Update once per server for all new users.
3. Add custom plugins and themes to Wordpress default installation.

IMPORTANT: You need to create a new Wordpress zip-file as you can't use the one from the Wordpress site. All the Wordpress files have to be directly in the wordpress.zip. In the official zip-file the files are located in a subfolder called "wordpress" which i didn't want, i wanted Wordpress to be installed in the root of the public_html.

ALSO IMPORTANT: I'm an amateur/hobby scripter. If you like it (or not) let me know. If you have any improvements or tips: let me know. ( i know it's not responsive,yet :p )

LAST THING: feel free to use it for whatever you want :)
Hey

Links are down.
Do you have any ss?
 
Hey

Links are down.
Do you have any ss?
The script is giving errors with the latest WP version, you should not use it. Try softaculous for directadmin it's only 12 dollar for a vps license. You can also check the other method listed in this thread. If you still want the script let me know i can reupload it for you.
 
For anyone who finds this article, I have created an updated & working WordPress Auto Installer that would take maybe 5 minutes to setup.

 
Back
Top