<\/span><\/h2>\nTo connect to your server via SSH as user root, use the following command:<\/p>\n
ssh root@IP_ADDRESS -p PORT_NUMBER<\/pre>\nand replace \u201cIP_ADDRESS\u201d and \u201cPORT_NUMBER\u201d with your actual server IP address and SSH port number.<\/p>\n
Once logged in, make sure that your server is up-to-date by running the following commands:<\/p>\n
apt-get update\r\napt-get upgrade<\/pre>\n<\/span>Step 2: Apache Web Server Installation<\/span><\/h2>\nTo install the Apache web server, run the following command:<\/p>\n
apt-get install apache2<\/pre>\nAfter the installation is complete, you should enable Apache to start automatically upon server boot with:<\/p>\n
systemctl enable apache2<\/pre>\nYou can also check the status of your Apache service with the following command:<\/p>\n
systemctl status apache2<\/pre>\nOutput:<\/p>\n
apache2.service - The Apache HTTP Server\r\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\n Drop-In: \/lib\/systemd\/system\/apache2.service.d\r\n \u2514\u2500apache2-systemd.conf\r\n Active: active (running) since Wed 2018-12-19 03:44:49 CST; 21min ago\r\n Main PID: 905 (apache2)\r\n Tasks: 7 (limit: 1110)\r\n CGroup: \/system.slice\/apache2.service\r\n \u251c\u2500 905 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 923 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 926 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 927 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 928 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 929 \/usr\/sbin\/apache2 -k start\r\n \u2514\u250016816 \/usr\/sbin\/apache2 -k start\r\n<\/pre>\n<\/span>Step 3: Install PHP<\/span><\/h2>\nThe next step of our LAMP stack setup is to install PHP. WordPress 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.<\/p>\n
apt install php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip<\/pre>\nYou can check your PHP version with the following command:<\/p>\n
php -v<\/pre>\nOutput:<\/p>\n
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\r\n with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies\r\n<\/pre>\n<\/span>Step 4: Install the MySQL Database server<\/span><\/h2>\nFinally, MySQL is the last software package we need to finish installing our LAMP stack. MySQL is an open-source database management system, commonly installed as part of the popular LAMP (Linux, Apache, MySQL, PHP\/Python\/Perl) stack. It is a very popular choice for managing databases, thanks to its continuous development and extensive feature set.<\/p>\n
On Ubuntu 18.04, only the latest version of MySQL is included in the APT package repository by default.<\/p>\n
To install the default package, run the following command:<\/p>\n
$ apt install mysql-server<\/pre>\nThis will install MySQL version 5.7 on your server, but it will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL vulnerable, in order to improve the security of your MySQL server, we recommend that you run the mysql_secure_installation<\/strong> script by typing the following command:<\/p>\nmysql_secure_installation<\/pre>\nThis script will help you to perform important security tasks, like setting up a root password, disabling remote root login, removing anonymous users, etc.<\/p>\n
<\/span>Step 5: Create a Database for WordPress<\/span><\/h2>\nNow, we will create our MySQL database for our WordPress site. Log in to your MySQL server with the following command and enter your MySQL root password:<\/p>\n
mysql -u root -p<\/pre>\nIn this section, we will create a new MySQL database wordpress<\/code> and assign user access to it to a new user admin_user<\/code> with password StrongPassword<\/code><\/p>\nCREATE DATABASE wordpress;\r\nGRANT ALL PRIVILEGES ON wordpress.* TO 'admin_user'@'localhost' IDENTIFIED BY 'StrongPassword';\r\nFLUSH PRIVILEGES;\r\nexit;<\/pre>\nDon\u2019t forget to replace \u2018StrongPassword\u2019 with an actual strong password.<\/p>\n
<\/span>Step 6: Install WordPress<\/span><\/h2>\nWe can now proceed with the actual installation of WordPress.\u00a0 Run the following commands to download and extract the latest WordPress installation files in the default web server document root directory (\/var\/www\/html<\/strong>).<\/p>\ncd \/var\/www\/html\r\nwget -c http:\/\/wordpress.org\/latest.zip\r\nunzip latest.zip\r\nchown -R www-data:www-data wordpress\r\nrm latest.zip<\/pre>\nAll the WordPress files will be now placed in the wordpress<\/strong> directory in \/var\/www\/html\/wordpress<\/strong><\/p>\nOnce the database is created, we will need to add this information to the WordPress configuration file.<\/p>\n
First, run the following command to rename the sample configuration file:<\/p>\n
cd \/var\/www\/html\/wordpress\r\nmv wp-config-sample.php wp-config.php<\/pre>\nNow open the wp-config.php<\/strong> file with your favorite text editor, for example:<\/p>\nnano wp-config.php<\/pre>\nAnd update the database settings, replacing database_name_here<\/em><\/strong>, username_here<\/em><\/strong> and password_here<\/em><\/strong> with your own details:<\/p>\n\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\r\n\/** The name of the database for WordPress *\/\r\ndefine('DB_NAME', 'wordpress');\r\n\r\n\/** MySQL database username *\/\r\ndefine('DB_USER', 'admin_user');\r\n\r\n\/** MySQL database password *\/\r\ndefine('DB_PASSWORD', 'StrongPassword');\r\n\r\n\/** MySQL hostname *\/\r\ndefine('DB_HOST', 'localhost');\r\n\r\n\/** Database Charset to use in creating database tables. *\/\r\ndefine('DB_CHARSET', 'utf8');\r\n\r\n\/** The Database Collate type. Don't change this if in doubt. *\/\r\ndefine('DB_COLLATE', '');<\/pre>\nSave and exit the file.<\/p>\n