PHP<\/a>. WordPress is a PHP-based CMS, so we need PHP for processing the dynamic content of our WordPress site.<\/p>\n\n\n\nUbuntu 20.04 comes with PHP 7.4 by default. We will also need some additional modules in order to allow PHP to connect and communicate with our Apache and MySQL instances. To install PHP together with the required MySQL and Apache modules, run the following command:<\/p>\n\n\n\n
sudo apt install php libapache2-mod-php php-mysql<\/pre>\n\n\n\nWordPress and many of its plugins use PHP extensions that you\u2019ll need to install manually. This section is optional, but it will allow you to access some WordPress features you might not have access to with a basic PHP installation. Simply run this command and the packages will install.<\/p>\n\n\n\n
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip<\/pre>\n\n\n\nTo verify that PHP 7.4 is successfully installed, run the following command:<\/p>\n\n\n\n
php -v<\/pre>\n\n\n\nYou should get the following output on your screen:<\/p>\n\n\n\n
PHP 7.4.3 (cli) (built: May 5 2020 12:14:27) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies<\/pre>\n\n\n\n<\/span>Install WordPress<\/span><\/h2>\n\n\n\nNow that we have our LAMP environment completely set up, we can now proceed with the WordPress installation. We will first download and place the WordPress installation files in the default web server document root directory, \/var\/www\/html<\/code>.<\/p>\n\n\n\nYou can move to this directory using the following command:<\/p>\n\n\n\n
cd \/var\/www\/html<\/pre>\n\n\n\nWe can now download the latest WordPress installation with the following command:<\/p>\n\n\n\n
wget -c http:\/\/wordpress.org\/latest.tar.gz<\/pre>\n\n\n\nThen, extract the files with:<\/p>\n\n\n\n
tar -xzvf latest.tar.gz<\/pre>\n\n\n\nThe extracted WordPress files will be now placed in the wordpress<\/code> directory at the following location on your server \/var\/www\/html\/wordpress<\/code><\/p>\n\n\n\nThe owner of these files needs to be the user of the web server running on your system. In our example, we are using the Apache web server and Apache runs as the www-data<\/code> user on Ubuntu 20.04. To change the owner and set the correct permissions for these files, you need to run the following command:<\/p>\n\n\n\nsudo chown -R www-data:www-data \/var\/www\/html\/wordpress<\/pre>\n\n\n\n<\/span>Create a Database for WordPress<\/span><\/h2>\n\n\n\nNext, we will create our MySQL user and database for our WordPress site. Log in to your MySQL server with the following command and enter your MySQL root password:<\/p>\n\n\n\n
mysql -u root -p<\/pre>\n\n\n\nTo create a new database for our WordPress installation, run the following commands:<\/p>\n\n\n\n
CREATE DATABASE wordpress_db<\/span>;\nCREATE USER wordpress_user<\/span>@localhost IDENTIFIED BY 'strong-password<\/span>';\nGRANT ALL PRIVILEGES ON wordpress_db<\/span>.* TO wordpress_user<\/span>@localhost;\nFLUSH PRIVILEGES;\nexit;<\/pre>\n\n\n\nYou can replace the database name (wordpress_db<\/span>) and the MySQL user name (wordpress_user<\/span>) with your own names if you wish. Also, make sure to replace “strong-password<\/span>” with a real, strong password.<\/p>\n\n\n\nOnce the database is created, we will need to add this information to the WordPress configuration file.<\/p>\n\n\n\n
Make sure you are inside the \/var\/www\/html\/wordpress<\/code> directory:<\/p>\n\n\n\ncd \/var\/www\/html\/wordpress<\/pre>\n\n\n\nand then run the following command to rename the sample configuration file:<\/p>\n\n\n\n
mv wp-config-sample.php wp-config.php<\/pre>\n\n\n\nNow open the wp-config.php file with your favorite text editor, for example:<\/p>\n\n\n\n
nano wp-config.php<\/pre>\n\n\n\nAnd update the database settings, replacing wordpress_db<\/code>, wordpress_user<\/code> and strong_password<\/code> with your own details:<\/p>\n\n\n\n\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\n\/** The name of the database for WordPress *\/\ndefine('DB_NAME', 'wordpress_db<\/span>');\n\n\/** MySQL database username *\/\ndefine('DB_USER', 'wordpress_user<\/span>');\n\n\/** MySQL database password *\/\ndefine('DB_PASSWORD', 'strong-password<\/span>');\n\n\/** MySQL hostname *\/\ndefine('DB_HOST', 'localhost');\n\n\/** Database Charset to use in creating database tables. *\/\ndefine('DB_CHARSET', 'utf8');\n\n\/** The Database Collate type. Don't change this if in doubt. *\/\ndefine('DB_COLLATE', '');<\/pre>\n\n\n\nSave and exit the file.<\/p>\n\n\n\n
With this being done, you can now access your WordPress page and finish the installation by following the on-screen instructions in your browser at http:\/\/your_server_ip_address<\/span>\/wordpress<\/code><\/p>\n\n\n\n