<\/span><\/h2>\nWe need to install a web server to serve WordPress’ content. For this purpose, we will install and use Apache web server. It is available in the official Ubuntu repository and it can be easily installed using the apt package manager:<\/p>\n
apt -y install apache2<\/pre>\nOnce the installation of the web server is completed, Apache should be automatically started. You can confirm this by checking its status<\/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 Fri 2019-08-09 02:31:39 CST; 14min ago\r\n Main PID: 406 (apache2)\r\n Tasks: 7 (limit: 1110)\r\n CGroup: \/system.slice\/apache2.service\r\n \u251c\u2500 407 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 423 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 426 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 427 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500 428 \/usr\/sbin\/apache2 -k start\r\n<\/pre>\nEnable Apache to automatically start after a server reboot<\/p>\n
systemctl enable apache2<\/pre>\n<\/span>Step 3: Install PHP<\/strong><\/span><\/h2>\nAs we already mentioned, WordPress is a PHP-based application, so we have to install PHP and several PHP extensions on the server. Run the following command to install all necessary components:<\/p>\n
apt -y install php php-xml php-common php-gd php-mbstring php-xmlrpc php-curl php-soap php-zip php-intl<\/pre>\nAfter the installation of PHP is completed, you can check the installed version:<\/p>\n
PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( 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.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies\r\n<\/pre>\n<\/span>Step 4: Install MySQL on the Remote Server<\/strong><\/span><\/h2>\nThe next step is to install a database server. For the purposes of this tutorial, we will install it on a remote server.<\/p>\n
Login to the remote server via SSH<\/p>\n
ssh root@remote_IP<\/span> -p Port_number<\/span><\/pre>\nand install the MySQL database server using the following command<\/p>\n
apt -y install mysql<\/pre>\nTo accept remote connections, edit the MySQL configuration file and modify the bind-address<\/code> option. It is set to listen on localhost only. We will change 127.0.0.1<\/code> to the database server IP address.<\/p>\n\/etc\/mysql\/mysql.conf.d\/mysqld.cnf\r\n\r\n# Instead of skip-networking the default is now to listen only on\r\n# localhost which is more compatible and is not less secure.\r\nbind-address = remote_IP\r\n<\/span><\/pre>\nand restart MySQL for the changes to take effect:<\/p>\n
systemctl restart mysql<\/pre>\n<\/span>Step 5: Create MySQL Database and User<\/strong><\/span><\/h2>\nWhile you are still logged in to the remote server which we will use as our database server, create a MySQL user and database for the WordPress installation. Login to the MySQL cli as the root user and execute the following commands:<\/p>\n
mysql -u root -p\r\n\r\nmysql> CREATE DATABASE wp;\r\nmysql> CREATE USER 'wpser'@'IP_address' IDENTIFIED BY 'PASSWORD<\/span>';\r\nmysql> GRANT ALL PRIVILEGES ON wp.* TO 'wpser'@'IP_address';\r\nmysql> FLUSH PRIVILEGES;\r\n<\/pre>\nWhere ‘IP_address<\/span>‘ is the IP address of the Ubuntu 18.04 server where WordPress will be installed. Make sure to replace the password with a good and unique one.<\/p>\n<\/span>Step 6: Install WordPress<\/strong><\/span><\/h2>\nNow, go back to the Ubuntu 18.04 VPS where we installed Apache and PHP, and install WordPress on it. To do that, download the WordPress archive:<\/p>\n
wget https:\/\/wordpress.org\/latest.zip<\/pre>\nUnpack the downloaded ZIP archive to the document root directory:<\/p>\n
unzip latest.zip \/var\/www\/html<\/pre>\nSet the proper ownership to the WordPress files:<\/p>\n
chown -R www-data:www-data \/var\/www\/html\/wordpress<\/pre>\nRename the\u00a0wp-config-sample.php<\/code> WordPress configuration file to wp-config.php<\/code>:<\/p>\nmv \/var\/www\/html\/wordpress\/wp-config-sample.php \/var\/www\/html\/wordpress\/wp-config.php<\/pre>\nEdit the WordPress configuration file and modify the following lines<\/p>\n
nano \/var\/www\/html\/wordpress\/wp-config.php\r\n\r\n\/** The name of the database for WordPress *\/\r\ndefine('DB_NAME', 'wp');\r\n\r\n\/** MySQL database username *\/\r\ndefine('DB_USER', 'wpuser');\r\n\r\n\/** MySQL database password *\/\r\ndefine('DB_PASSWORD', 'PASSWORD<\/span>');\r\n\r\n\/** MySQL hostname *\/\r\ndefine('DB_HOST', 'remote_IP<\/span>');\r\n<\/pre>\nand save the file.<\/p>\n
<\/span>Step 7: Create an Apache Virtual Host<\/strong><\/span><\/h2>\nIn order to be able to access WordPress with a domain name instead of the IP address, we have to create Apache virtual host for the specific domain. We will use as an example. Replace all occurences of domain.com<\/code> with your actual domain name.<\/p>\n<VirtualHost *:80>\r\n\r\nServerAdmin admin@domain.com<\/span>\r\nServerName domain.com<\/span>\r\nServerAlias www.domain.com<\/span>\r\nDocumentRoot \/var\/www\/html\/wordpress\r\n\r\n<Directory \/var\/www\/html\/wordpress>\r\n Options Indexes FollowSymLinks\r\n AllowOverride All\r\n Require all granted\r\n<\/Directory>\r\n\r\nErrorLog ${APACHE_LOG_DIR}\/domain.com<\/span>_error.log \r\nCustomLog ${APACHE_LOG_DIR}\/domain.com<\/span>_access.log combined \r\n<\/VirtualHost><\/pre>\nEnable the virtual host<\/p>\n
a2ensite domain.com<\/span><\/pre>\nAnd restart Apache for the changes to take effect<\/p>\n
systemctl restart apache2<\/pre>\nWith this step the WordPress installation is completed, and you can finish its configuration by opening http:\/\/domain.com<\/code> in your favorite web browser. Then follow the on-screen instructions to select a language, create your administrative account, etc…<\/p>\n <\/p>\n
Congratulations! We have not only installed WordPress on our Ubuntu 18.04 VPS, but we also made it use a database server that is remote to the one hosting the WordPress instance.<\/p>\n
\n Of course, you don\u2019t have to install WordPress on Ubuntu 18.04 and configure it to use a Remote Database if you use one of our Optimized WordPress Hosting services, in which case you can simply ask our expert system administrators to install WordPress on Ubuntu 18.04 and configure it to use a Remote Database for you, using the LAMP stack or any other web hosting stack of your choice. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n
PS.<\/strong><\/span> If you liked this post, on how to install WordPress on Ubuntu 18.04 and configure it to use a remote database<\/strong>, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"In this tutorial we will guide you through the steps of installing WordPress on an Ubuntu 18.04 VPS with all … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":32399,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1710,1702,13,1698],"tags":[59,148],"yoast_head":"\nHow to Install WordPress on Ubuntu 18.04 and Configure it to Use a Remote Database - RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n