with a Simple Bash Script
Setting up WordPress manually on a server can be time-consuming and error-prone, especially when handling multiple installations. While some hosting environments provide one-click installers like Softaculous, many users might prefer or need to install WordPress manually, especially on VPS or dedicated servers without those tools.
For those using DirectAdmin on a VPS or dedicated server, automating WordPress installations can significantly simplify the process. By using a bash script, we can streamline everything—from creating a database, configuring the WordPress files, to fetching secure salts and setting up admin credentials—all in just a few minutes.
In this article, we’ll dive into a custom bash script that can be run on any of our VPS or dedicated servers running DirectAdmin. This script automatically handles all the heavy lifting of installing WordPress without needing any one-click installer.
Our script is designed to automate the following steps:
wp-config.php
file, ensuring your installation is secure from the start.wp-config.php
file with database credentials and other necessary configurations.Many hosting environments provide one-click installers like Softaculous to handle WordPress installations. However, not all environments include these tools, especially when you’re running on a VPS or dedicated server with custom configurations. Here are the benefits of using this script:
When using a bash script, you have complete control over the installation process. You know exactly what is being set up, how the database is created, and where files are placed. This level of transparency can be vital for developers and advanced users who prefer to avoid third-party tools.
Security is a top priority when setting up any website. Our script leverages the WordPress secret-key API to automatically generate and insert secure salts (AUTH_KEY
, SECURE_AUTH_KEY
, and more) into the wp-config.php
file. These salts help strengthen your WordPress installation against potential threats by securing the authentication process. Unlike manual installations, which often skip this step, our script ensures that your WordPress site is as secure as possible right from the start.
Instead of manually creating databases through the DirectAdmin interface, the script automatically creates a new database and a MySQL user. If a database with the same name already exists, the script appends a random suffix, ensuring no naming conflicts. This makes the process seamless, especially when managing multiple installations.
The script is built with DirectAdmin in mind. Not only does it handle the WordPress setup, but it also updates DirectAdmin’s configuration files to ensure the new MySQL database and user are visible in the DirectAdmin interface. This eliminates the need for manual database entry updates in DirectAdmin, saving you time and effort.
Once WordPress is installed, the script generates a secure password for the admin
user and displays it at the end of the installation. This saves you from having to manually set up admin credentials and ensures that the password is strong and secure.
If you are managing multiple WordPress installations on a VPS or dedicated server, this script is perfect for scaling. You can easily tweak the script to run for different users or domains, making it ideal for developers, agencies, or hosting providers managing multiple WordPress sites.
Using this script on one of our VPS or dedicated servers running DirectAdmin is simple. Here’s a quick guide on how to get started:
Connect to your VPS or dedicated server using SSH as the root user
2. Clone the directadmin-wp Git repository
git clone https://github.com/Entexion/directadmin-wp.git
Run the script, specifying the DirectAdmin username and domain for which you want to install WordPress:
./install_wordpress.sh <directadmin_user> <domain>
For example:
./install_wordpress.sh alice example.com
The script will then:
wp-config.php
file.Once the script finishes running, it will display the admin login credentials and the URL:
WordPress installation complete for example.com
Admin Username: admin
Admin Password: a-generated-password
Login URL: http://example.com/wp-admin
Visit the wp-admin link, log in with the credentials, and start building your WordPress site!
For those running DirectAdmin on VPS or dedicated servers, this bash script is an excellent alternative to using a one-click installer. It offers more control, security, and scalability, making it perfect for users who want full transparency and efficiency during the installation process.
By automating the entire process, from database creation to fetching secure salts, this script not only saves time but also ensures that every WordPress installation is done right—with security and best practices built in. Whether you’re managing a single site or dozens, this script will simplify your workflow and give you the flexibility you need to manage WordPress installations effectively.
If you’re looking for an easy, secure, and reliable way to install WordPress on your DirectAdmin server, give this script a try today!