ps aux | grep apache2<\/pre>\nWe can also check if there are Apache2 packages installed on the server:<\/p>\n
dpkg -l | grep apache2<\/pre>\nIf Apache is already installed on the server, we can skip the Apache installation steps and proceed with PHP\u00a0installation.
\nIf Apache is not installed, we can install it using:<\/p>\n
apt-get install apache2<\/pre>\nOnce installed, start the Apache server and enable it to start on server boot:<\/p>\n
systemctl start apache2<\/pre>\nsystemctl enable apache2<\/pre>\n<\/span>Step 3: Install MariaDB<\/span><\/h2>\nWe will use MariaDB as our database engine. We can install MariaDB server from the Ubuntu base repository using the following commands:<\/p>\n
sudo apt-get install mariadb-server-10.1 mariadb-server-core-10.1<\/pre>\n<\/span>Step 4: Install the Required PHP Extensions<\/span><\/h2>\nThe default PHP version available from the official Ubuntu 18.04 repository is PHP 7.2.
\nInstall the required PHP extensions:<\/p>\n
apt-get install php7.2-curl php7.2-gd php7.2-mbstring php7.2-mysql php7.2-zip<\/pre>\n<\/span>Step 5: Install PHP Module “mcrypt”<\/span><\/h2>\nInstall the PHP “mcrypt” module on the server using pecl channel:<\/p>\n
sudo apt install php-dev libmcrypt-dev\r\nsudo pecl channel-update pecl.php.net\r\nsudo pecl install mcrypt-1.0.1<\/pre>\n<\/span>Step 6: Configure PHP<\/span><\/h2>\nLocate the PHP configuration file:<\/p>\n
php --ini | grep Loaded<\/pre>\nThe output should be something like this:<\/p>\n
Loaded Configuration File: \/etc\/php\/7.2\/cli\/php.ini<\/pre>\nEdit the php.ini configuration file:<\/p>\n
vi \/etc\/php\/7.2\/cli\/php.ini<\/pre>\nAdd\/modify the following options:<\/p>\n
memory_limit = 256M \r\nfile_uploads = On\t\r\nallow_url_fopen = On\r\nallow_url_include = Off\r\nupload_max_filesize = 64M\r\nshort_open_tag = On\t\r\nmax_execution_time = 300\r\ndefault_charset = \"UTF-8\"\r\nextension=mcrypt.so<\/pre>\nMake sure that ‘open_basedir’ and ‘safemode’ are not set:<\/p>\n
#php -i | grep -i safemode\r\n\r\n#php -i | grep -i open_basedir\r\nopen_basedir => no value => no value<\/pre>\n<\/span>Step 7: Enable Apache “Rewrite” Module<\/span><\/h2>\nEnable the Apache rewrite module if it is not already done:<\/p>\n
a2enmod rewrite<\/pre>\nRestart the Apache service for the changes to take effect:<\/p>\n
service apache2 restart<\/pre>\n<\/span>Step 8: Install WordPress<\/span><\/h2>\nDownload and extract the latest WordPress installation files in the document root directory of your WordPress website ( e.g \/var\/www\/html\/your-domain.com<\/code>).<\/p>\ncd \/opt\/\r\nwget https:\/\/wordpress.org\/latest.zip\r\nunzip latest.zip\r\nmkdir -p \/var\/www\/html\/your-domain.com\r\nmv \/opt\/wordpress\/* \/var\/www\/html\/your-domain.com<\/span>\/\r\nchown -R www-data:www-data \/var\/www\/html\/your-domain.com<\/span>\r\nrm latest.zip<\/pre>\nMake sure to replace “your-domain.com<\/span>” with your unique registered domain name.<\/p>\n<\/span>Step 9: Create a Database for WordPress<\/span><\/h2>\nCreate a MySQL database for the WordPress website:<\/p>\n
mysql -u root -p<\/pre>\nMariaDB [(none)]> CREATE DATABASE wpdb;\r\nMariaDB [(none)]> GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'Str0ngPa55w0rd<\/span>';\r\nMariaDB [(none)]> FLUSH PRIVILEGES;\r\nMariaDB [(none)]> exit;<\/pre>\nDon\u2019t forget to replace \u2018Str0ngPa55w0rd<\/span>\u2019 with an actual strong password.<\/p>\n