Learn how to install WordPress, create a database, and set up a database user via the Linux command prompt.
Create a Directory to Store WordPress Files
Open the command prompt and navigate to the apache localhost directory.
cd /var/www/html/ mkdir [folder-name]
Download WordPress
Download the latest version of WordPress.
wget -c http://wordpress.org/latest.tar.gz
Extract the contents. The contents will be extracted to a directory called “wordpress”.
tar -xzvf latest.tar.gz
Copy the contents of the “wordpress” folder to the folder created above.
sudo rsync -av wordpress/* /var/www/html/[folder-name]
Create Database and Database User
For more on MySQL commands, read my Essential MySQL Commands.
mysql -u [username] -p CREATE USER '[newuser]'@'localhost' IDENTIFIED BY '[password]'; CREATE DATABASE [database_name]; GRANT ALL PRIVILEGES ON [database_name].* TO '[newuser]'@'localhost'; exit
Set Up the wp-config.php File
Navigate to the folding holding wp-config.php
cd [folder-name] sudo mv wp-config-sample.php wp-config.php
Enter the database name, database username, and password credentials
With vim, Use i to edit, ESC to finish editing. A couple useful commands:
sudo vim wp-config.php :q! exit vim without saving :wq save and exit :x save and exit
Add the following line below unique keys and salts:
/ ** Disable Post Revisions */ define('WP_POST_REVISIONS', FALSE);
Allow WordPress to Install Plugins and Themes
sudo chown -R www-data:www-data /var/www/html/[folder-name]
www-data is the user that web servers on Apache use by default for normal operation.
Optional Step
Restart and enter the [folder-name] path into the url (localhost/[folder-name]).
sudo systemctl restart apache2.service sudo systemctl restart mysql.service