This article will walk you through installing WordPress through WP-CLI on AlmaLinux.
WP-CLI is a powerful command-line tool for managing WordPress. It enables users to perform tasks like installation, updates, and configuration from the terminal.
Prerequisites:
- AlmaLinux Server with root or sudo access.
- PHP installed (WordPress requires PHP 7.4 or higher).
- MySQL/MariaDB database and a database user for WordPress.
- Nginx or Apache web server installed and running.
Follow the steps:
- Update Your Server:
Update all packages to ensure compatibility:sudo dnf update -y
- Install PHP and Required Extensions
If PHP is not installed, install it along with the required extensions:sudo dnf install -y php php-mysqlnd php-json php-curl php-gd php-mbstring php-xml php-zip
- Install WP-CLI
- Download WP-CLI:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- Make WP-CLI executable:
chmod +x wp-cli.phar
- Move it to a global location:
sudo mv wp-cli.phar /usr/local/bin/wp
- Verify the installation:
wp --info
- Download WP-CLI:
- Create a Database for WordPress
Log in to MySQL or MariaDB and create a database and user for WordPress:sudo mysql -u root -p
Then, run the following commands in the MySQL prompt:
CREATE DATABASE wordpress_db; CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'secure_password'; GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
Replace wordpress_db, wordpress_user, and secure_password with your chosen values.
- Set Up the WordPress Directory
- Navigate to the web root (usually /var/www/html):
cd /var/www/html
- Create a directory for WordPress:
sudo mkdir wordpress && cd wordpress
- Navigate to the web root (usually /var/www/html):
- Download and Configure WordPress with WP-CLI
- Download WordPress:
wp core download
- Configure the wp-config.php file:
wp config create --dbname=wordpress_db --dbuser=wordpress_user --dbpass=secure_password --dbhost=localhost --dbprefix=wp_
Replace the database name, user, and password with the details you created in Step 4.
- Download WordPress:
- Install WordPress
- Run the installation command:
wp core install --url="http://your-domain.com" --title="Your Site Title" --admin_user="admin_user" --admin_password="admin_password" --admin_email="[email protected]"
- Replace:
- your-domain.com with your domain name.
- Your Site Title with the desired site title.
- admin_user, admin_password, and [email protected] with the desired admin credentials.
- Run the installation command:
- Set Permissions for WordPress Files:
Set the correct permissions to allow the webserver to write to WordPress files:sudo chown -R apache:apache /var/www/html/wordpress sudo chmod -R 755 /var/www/html/wordpress
If you are using Nginx, replace apache:apache with nginx:nginx.
- Finalise the Setup
Once installed, navigate to http://your-domain.com/wp-admin in a browser to access the WordPress dashboard. Log in with the admin credentials you set in Step 7.
You have successfully installed WordPress on AlmaLinux using WP-CLI. This setup provides a faster and more efficient way to manage WordPress installations