WordPress is an open-source content management system (CMS) that powers more than 40% of the web. It lets you easily build websites, blogs or complex applications thanks to a massive ecosystem of themes and plugins.
Why use WordPress?
- Ease of use: Its admin interface is famous for its simplicity.
- Flexibility: Thousands of themes and plugins let you adapt it to almost any need (blog, e-commerce, portfolio, brochure site, etc.).
- Large community: You will find help and resources everywhere on the internet.
- SEO-friendly: Many tools exist to help with your site's search engine optimization.
Prerequisites: The LAMP or LEMP stack
WordPress needs a server environment to run. The two most common setups are:
- LAMP: Linux, Apache (web server), MySQL/MariaDB (database), PHP (scripting language).
- LEMP: Linux, ENGINX (Nginx, web server), MySQL/MariaDB, PHP.
This guide assumes you already have a server with one of these stacks up and running.
Installation
Step 1: Create a database and a user
WordPress stores all of its content in a MySQL or MariaDB database.
-- Connect to the MySQL/MariaDB shell
sudo mysql -u root -p
-- Create a database for WordPress
CREATE DATABASE wordpress_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Create a dedicated user and grant it privileges on this database
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'a_strong_password';
GRANT ALL ON wordpress_db.* TO 'wp_user'@'localhost';
-- Apply the changes
FLUSH PRIVILEGES;
-- Quit
EXIT;
Step 2: Download and extract WordPress
Go to your web server's root directory (e.g. `/var/www/html/`) and download the latest version of WordPress.
cd /var/www/html/
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
# The files will be in a "wordpress" folder. We can move them if needed.
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz
Step 3: Set the permissions
The web server (usually the `www-data` user) must be able to write to these files for updates and uploads.
sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;
Step 4: Configure `wp-config.php`
This is the file that connects WordPress to its database.
# Copy the example
sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
# Edit it
sudo nano /var/www/html/wp-config.php
Edit these lines with the details of the database you created in step 1:
define( 'DB_NAME', 'wordpress_db' );
define( 'DB_USER', 'wp_user' );
define( 'DB_PASSWORD', 'a_strong_password' );
It is also strongly recommended to fill in the unique security keys (SALT). You can generate a fresh set via the official WordPress API.
Step 5: The web installation wizard
Open your browser and go to your site's address. The WordPress installation wizard, famous for its simplicity, will greet you.
It will ask you for:
- Your site title.
- The administrator username (do NOT use "admin").
- A strong password.
- Your email address.
Click "Install WordPress" and you're done!
You can now log in to your WordPress dashboard via `http://your-domain.com/wp-admin`.
Next steps (Crucial)
- Permalinks: Go to `Settings -> Permalinks` and choose "Post name". It's better for SEO.
- Security: Install a security plugin such as Wordfence or iThemes Security.
- Backups: Set up an automated backup solution (e.g. UpdraftPlus).
- Caching: Install a caching plugin (e.g. W3 Total Cache or WP Super Cache) to improve performance.
- HTTPS: Configure an SSL/TLS certificate (with Let's Encrypt) on your web server to switch your site to HTTPS.
WordPress's popularity makes it a target. Security is not optional. Always keep the WordPress core, your themes and your plugins up to date.
Conclusion
Installing WordPress is a quick process, but it's only the beginning. The real work of managing a WordPress site lies in its ongoing maintenance, hardening, and optimization. By following these first steps, you have a solid foundation to build your web project.
Comments