{"id":34,"date":"2019-02-02T11:38:00","date_gmt":"2019-02-02T11:38:00","guid":{"rendered":"https:\/\/hostup.org\/blog\/?p=34"},"modified":"2021-01-24T20:44:10","modified_gmt":"2021-01-24T20:44:10","slug":"how-to-install-apache-and-mysql-ubuntu","status":"publish","type":"post","link":"https:\/\/hostup.se\/en\/blog\/how-to-install-apache-and-mysql-ubuntu\/","title":{"rendered":"How to install Apache and MySQL in Ubuntu"},"content":{"rendered":"\n<p>This works for Ubuntu 16.04 and Ubuntu 18.04. I would highly recommend that you install a Nginx server over Apache since it is overall much better and faster.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Before we start, please proceed following <a href=\"https:\/\/blog.hostup.org\/2019\/02\/02\/how-to-secure-a-ubuntu-linux-server-in-3-simple-steps\/\" target=\"_blank\" rel=\"noopener\">this<\/a> tutorial&#8217;s first step if you do not already have a different account than root.<\/p><\/blockquote>\n\n\n\n<p>Before anything we need to make sure that our system is up to date.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt-get update -y<\/code><br><code>apt-get upgrade -y<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Apache And PHP 7.2<\/h2>\n\n\n\n<p>To install the Apache server, run the following command: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get install apache2 -y<br>sudo apt-get install php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-intl php7.2-mysql php7.2-xml php7.2-zip <\/pre>\n\n\n\n<p>You can access your website by the url<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/Server_Ip_Here<\/pre>\n\n\n\n<p>If you want to use a domain name instead, then simply point it to your server IP.<\/p>\n\n\n\n<p>There are many different settings for security here too you may want to configure. One of the most common ones is to hide directories. You can follow this tutorial <a href=\"https:\/\/www.techrepublic.com\/article\/how-to-make-apache-more-secure-by-hiding-directory-folders\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing MySQL<\/h2>\n\n\n\n<p>To install the MySQL server, run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt-get install mysql-server<\/code><\/pre>\n\n\n\n<p>After the installation is finished you want to enable it by running the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl start mysql<\/code><br><code>systemctl enable mysql<\/code><br><code>sudo mysql_secure_installation<\/code><\/pre>\n\n\n\n<p>To configure the MySQL server please click here to jump down a bit. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Firewall Configuration<\/h2>\n\n\n\n<p>If you followed our previous tutorial and set up a <a href=\"https:\/\/www.techrepublic.com\/article\/how-to-make-apache-more-secure-by-hiding-directory-folders\/\" target=\"_blank\" rel=\"noopener\">firewall<\/a>, then you need to allow MySQL and Apache.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw allow mysq<\/code>l<br><code>sudo ufw allow in \"Apache Full\"<\/code> <br><code>sudo ufw restart<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring MySQL<\/h2>\n\n\n\n<p>So you have gotten this far, good job! But now comes the hard part.<\/p>\n\n\n\n<p>If you want to allow remote access from outside of your server to the MySQL database:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ufw allow mysql<\/pre>\n\n\n\n<p>To open up MySQL shell:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/bin\/mysql -u root -p<\/code><br><\/pre>\n\n\n\n<p>If you have set any password to root, then type it after -p<\/p>\n\n\n\n<p>To update\/set the root password: (Change &#8216;password&#8217; with your specified password. Example of this &#8216;MyPasswordwow!&#8217;.)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>UPDATE mysql.user SET authentication_string = PASSWORD('password') WHERE User = 'root';<\/code><\/pre>\n\n\n\n<p>To create a database in MySQL:<\/p>\n\n\n\n<p>Simply replace &#8216;name&#8217; with the database name you want.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE DATABASE Name;<\/pre>\n\n\n\n<p>After each change, do not forget to reload the MySQL server by running:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FLUSH PRIVILEGES;<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This works for Ubuntu 16.04 and Ubuntu 18.04. I would highly recommend that you install a Nginx server over Apache since it is overall much better and faster. Before we start, please proceed following this tutorial&#8217;s first step if you do not already have a different account than root. Before anything we need to make [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":160,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":2,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":36,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/34\/revisions\/36"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/media\/160"}],"wp:attachment":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/media?parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/categories?post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/tags?post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}