{"id":4794,"date":"2019-11-07T01:53:10","date_gmt":"2019-11-07T04:53:10","guid":{"rendered":"https:\/\/blog.clusterweb.com.br\/?p=4794"},"modified":"2019-11-07T01:53:10","modified_gmt":"2019-11-07T04:53:10","slug":"install-apache2-mariadb-and-php-7-2-with-phpmyadmin-on-ubuntu-16-04-18-04-18-10-lamp-phpmyadmin","status":"publish","type":"post","link":"https:\/\/blog.clusterweb.com.br\/?p=4794","title":{"rendered":"Install Apache2, MariaDB And PHP 7.2 With PhpMyAdmin On Ubuntu 16.04 | 18.04 | 18.10 (LAMP + PhpMyAdmin)"},"content":{"rendered":"<p>This brief tutorial shows students and new users how to install\u00a0<strong>LAMP + phpMyAdmin<\/strong>\u00a0on Ubuntu 16.04 | 18.04 | 18.10 servers\u2026.<\/p>\n<p><strong>LAMP<\/strong>\u00a0is an acronym for\u00a0Linux (Ubuntu),\u00a0Apache2\u00a0HTTP Server,\u00a0MariaDB or\u00a0MySQL Database Server and\u00a0PHP Scripting Language\u2026 It is\u00a0a group of open source software and building blocks of many of the web applications and majority of the content management systems (CMS) in use today\u2026<\/p>\n<p><strong>phpMyAdmin<\/strong>\u00a0is a web-based tool that allows you to interact with MariaDB databases, manage user accounts and privileges, execute SQL-statements, import and export data and much, much more.<\/p>\n<p>If you\u2019re going to be developing any PHP based applications or websites, then you\u2019re probably going to be using the LAMP and phpMyAdmin allows you to easily manage your databases from your favorites web browsers\u2026<\/p>\n<p>This brief tutorial is going to show students and new users how to install Apache2, MariaDB, PHP with phpMyAdmin support on Ubuntu Linux 16.04 | 18.04 and 18.10 servers\u2026<\/p>\n<p><span id=\"more-19947\"><\/span>To get started with installing the LAMP Stack, follow the steps below:<\/p>\n<p><!--more--><\/p>\n<h4>Step 1: Prepare Ubuntu Linux<\/h4>\n<p>The LAMP stack includes the Linux machine\u2026 in this case, Ubuntu\u2026 To get LAMP you must first install a Linux machine\u2026 this post assumes you\u2019ve already install Ubuntu server..<\/p>\n<p>After installing Ubuntu server, run the commands below to update the server\u2026<\/p>\n<p><code>sudo apt update &amp;&amp; sudo apt dist-upgrade &amp;&amp; sudo apt autoremove<\/code><\/p>\n<h4>Step 2: Install Apache2 HTTP Server<\/h4>\n<p>Apache2 HTTP Server represents the E in the LAMP stack\u2026 It\u2019s the probably the second most popular web server installed today\u2026 not far behind the most popular web server, Apache2\u2026<\/p>\n<p>To install Apache2 HTTP on Ubuntu server, run the commands below\u2026<\/p>\n<pre>sudo apt update\r\nsudo apt install apache2<\/pre>\n<p>After installing Apache2, the commands below can be used to stop, start and enable Apache2 service to always start up with the server boots.<\/p>\n<pre>sudo systemctl stop apache2.service\r\nsudo systemctl start apache2.service\r\nsudo systemctl enable apache2.service\r\n<\/pre>\n<p>To test Apache2 setup, open your browser and browse to the server hostname or IP address and you should see Apache2 default test page as shown below.. When you see that, then Nginx is working as expected..<\/p>\n<p>ex..\u00a0<strong>http:\/\/localhost<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19788 size-full\" src=\"https:\/\/websiteforstudents.com\/wp-content\/uploads\/2018\/11\/apache2_test_page.png\" sizes=\"auto, (max-width: 872px) 100vw, 872px\" srcset=\"https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/apache2_test_page.png 872w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/apache2_test_page-300x214.png 300w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/apache2_test_page-768x548.png 768w\" alt=\"Apache2 Test Page\" width=\"872\" height=\"622\" \/><\/p>\n<h4>Step 3: Install MariaDB Database Server<\/h4>\n<p>MariaDB stands for M in LAMP and it\u2019s a great place to start when looking at open source database server\u2026 Although MySQL was originally the default database server among Linux systems, MariaDB has taken over.. To install it run the commands below.<\/p>\n<p><code>sudo apt-get install mariadb-server mariadb-client<\/code><\/p>\n<p>After installing MariaDB database server, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots..<\/p>\n<p><strong>On Ubuntu\u00a016.04\u00a0LTS<\/strong><\/p>\n<pre>sudo systemctl stop mysql.service\r\nsudo systemctl start mysql.service\r\nsudo systemctl enable mysql.service\r\n<\/pre>\n<p><strong>On Ubuntu\u00a018.04\u00a0LTS and\u00a018.10\u00a0<\/strong><\/p>\n<pre>sudo systemctl stop mariadb.service\r\nsudo systemctl start mariadb.service\r\nsudo systemctl enable mariadb.service\r\n<\/pre>\n<p>After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.<\/p>\n<p><code>sudo mysql_secure_installation<\/code><\/p>\n<p>When prompted, answer the questions below by following the guide.<\/p>\n<ul>\n<li>Enter current password for root (enter for none): Just press the\u00a0Enter<\/li>\n<li>Set root password? [Y\/n]:\u00a0Y<\/li>\n<li>New password:\u00a0Enter password<\/li>\n<li>Re-enter new password:\u00a0Repeat password<\/li>\n<li>Remove anonymous users? [Y\/n]:\u00a0Y<\/li>\n<li>Disallow root login remotely? [Y\/n]:\u00a0Y<\/li>\n<li>Remove test database and access to it? [Y\/n]: \u00a0Y<\/li>\n<li>Reload privilege tables now? [Y\/n]: \u00a0Y<\/li>\n<\/ul>\n<p>Restart MariaDB server<\/p>\n<p>To test if MariaDB is installed, type the commands below to logon to MariaDB server<\/p>\n<p><code>sudo mysql -u root -p<\/code><\/p>\n<p>Then type the password you created above to sign on\u2026 if successful, you should see MariaDB welcome message<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-17576\" src=\"https:\/\/websiteforstudents.com\/wp-content\/uploads\/2018\/01\/mariadb_ubuntu_1604.png\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" srcset=\"https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/01\/mariadb_ubuntu_1604.png 658w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/01\/mariadb_ubuntu_1604-300x109.png 300w\" alt=\"mariadb welcome\" width=\"658\" height=\"240\" \/><\/p>\n<h4>Step 4: Install PHP 7.2-FPM and Related Modules<\/h4>\n<p>The last component of the LAMP stack is PHP-FPM\u2026 It\u2019s the P in the LAMP stack\u2026<\/p>\n<p>PHP 7.2-FPM may not be available in Ubuntu default repositories\u2026 in order to install it, you will have to get it from third-party repositories.<\/p>\n<p>Run the commands below to add the below third-party repository to upgrade to PHP 7.2-FPM<\/p>\n<pre>sudo apt-get install software-properties-common\r\nsudo add-apt-repository ppa:ondrej\/php<\/pre>\n<p>Then update and upgrade to PHP 7.2-FPM<\/p>\n<p><code>sudo apt update<\/code><\/p>\n<p>Then run the commands below to install PHP 7.2-FPM and related modules\u2026<\/p>\n<p><code>sudo apt install php7.2-fpm php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-zip php7.2-curl<\/code><\/p>\n<p>After installing PHP, run the commands below to find the version installed on the server\u2026<\/p>\n<p><code>php -v<\/code><\/p>\n<p>You should see an output like the one below:<\/p>\n<pre>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<p>The version number determines the location of PHP default configuration file\u2026 For PHP\u00a07.2, the location is as shown below:<\/p>\n<pre>sudo nano \/etc\/php\/7.2\/apache2\/php.ini\r\n<\/pre>\n<p>Replace the\u00a0version number\u00a0above with the version of PHP installed..,..<\/p>\n<p>When the file opens, make the changes on the following lines below in the file and save.\u00a0The value below is great settings to apply in your environments.<\/p>\n<pre>file_uploads = On\r\nallow_url_fopen = On\r\nmemory_limit = 256M\r\nupload_max_filesize = 100M\r\nmax_execution_time = 360\r\ndate.timezone = America\/Chicago<\/pre>\n<p>After making the change above, save the file and close out.<\/p>\n<h4>Step 5: Install phpMyAdmin<\/h4>\n<p>Now that LAMP is in place, run the commands below to install phpMyAdmin\u2026<\/p>\n<p><code>sudo apt install phpmyadmin<\/code><\/p>\n<p>When prompted to choose the web server, don\u2019t select\u00a0<strong>apache2<\/strong>\u2026<\/p>\n<pre>+------------------------+ Configuring phpmyadmin +-------------------------+\r\n | Please choose the web server that should be automatically configured to   |\r\n | run phpMyAdmin.                                                           |\r\n |                                                                           |\r\n | Web server to reconfigure automatically:                                  |\r\n |                                                                           |\r\n |    [x] apache2                                                            |\r\n |    [ ] lighttpd                                                           |\r\n |                                                                           |\r\n |                                                                           |\r\n |                                 &lt;ok&gt;                                      |\r\n |                                                                           |\r\n +---------------------------------------------------------------------------+\r\n<\/pre>\n<p>When prompted again to allow debconfig-common to install a database and configure select\u00a0Yes.<\/p>\n<pre> +------------------------+ Configuring phpmyadmin +-------------------------+\r\n |                                                                           |\r\n | The phpmyadmin package must have a database installed and configured      |\r\n | before it can be used.  This can be optionally handled with               |\r\n | dbconfig-common.                                                          |\r\n |                                                                           |\r\n | If you are an advanced database administrator and know that you want to   |\r\n | perform this configuration manually, or if your database has already      |\r\n | been installed and configured, you should refuse this option.  Details    |\r\n | on what needs to be done should most likely be provided in                |\r\n | \/usr\/share\/doc\/phpmyadmin.                                                |\r\n |                                                                           |\r\n | Otherwise, you should probably choose this option.                        |\r\n |                                                                           |\r\n | Configure database for phpmyadmin with dbconfig-common?                   |\r\n |                                                                           |\r\n |                  &lt;Yes&gt;                   &lt;No&gt;                             |\r\n |                                                                           |\r\n +---------------------------------------------------------------------------+\r\n<\/pre>\n<p>You will be prompted to create a password for phpMyAdmin to register with the database\u2026 Please provide a password for phpmyadmin to register with the database\u2026\u00a0 \u00a0After that, phpMyAdmin should be installed and ready to use..<\/p>\n<h4>Step 6: Connecting to phpMyAdmin<\/h4>\n<p>Now open your browser and browse to the hostname followed by\u00a0<strong>phpmyadmin<\/strong><\/p>\n<p><strong>http:\/\/example.com\/phpmyadmin<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19941\" src=\"https:\/\/websiteforstudents.com\/wp-content\/uploads\/2018\/11\/phpmyadmin_ubuntu_setup_manual.png\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" srcset=\"https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual.png 903w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual-300x241.png 300w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual-768x617.png 768w\" alt=\"phpMyAdmin Ubuntu setup\" width=\"903\" height=\"726\" \/><\/p>\n<p>When you attempt to logon using MariaDB root account it will fail\u2026 That\u2019s because MariaDB and MySQL have switch their authentication method to\u00a0<strong>auth_socket<\/strong><\/p>\n<p>The\u00a0<strong>auth_socket<\/strong>\u00a0plugin authenticates users that connect from the localhost through the Unix socket file\u2026 which prevents users from connecting with password\u2026 So, you won\u2019t be able to connecto via phpMyAdmin\u2026<\/p>\n<p>When you attempt to logon, you see the error \u201c#1698 \u2013 Access denied for user \u2018root\u2019@\u2019localhost\u2019\u201d<\/p>\n<p>To fix that, run the commands below:<\/p>\n<p><code>sudo mysql -u root<\/code><\/p>\n<p>That should get you into the database server. After that, run the commands below to disable plugin authentication for the root user<\/p>\n<pre class=\"code\">use mysql;\r\nupdate user set plugin='' where User='root';\r\nflush privileges;\r\nexit<\/pre>\n<p>Restart and run the commands below to set a new password.<\/p>\n<p><code>sudo systemctl restart mariadb.service<\/code><\/p>\n<p>Now try again to logon\u2026 this time it should work!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19942\" src=\"https:\/\/websiteforstudents.com\/wp-content\/uploads\/2018\/11\/phpmyadmin_ubuntu_setup_manual_1.png\" sizes=\"auto, (max-width: 1108px) 100vw, 1108px\" srcset=\"https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual_1.png 1108w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual_1-300x197.png 300w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual_1-768x503.png 768w, https:\/\/storage.googleapis.com\/websiteforstudents.com\/2018\/11\/phpmyadmin_ubuntu_setup_manual_1-1024x671.png 1024w\" alt=\"phpMyAdmin Nginx\" width=\"1108\" height=\"726\" \/><\/p>\n<p>Congratulations! You\u2019re successfully installed the LAMP Stack with phpMyadmin on Ubuntu 16.04 | 18.04 | 18.10\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This brief tutorial shows students and new users how to install\u00a0LAMP + phpMyAdmin\u00a0on Ubuntu 16.04 | 18.04 | 18.10 servers\u2026. LAMP\u00a0is an acronym for\u00a0Linux (Ubuntu),\u00a0Apache2\u00a0HTTP Server,\u00a0MariaDB or\u00a0MySQL Database Server and\u00a0PHP Scripting Language\u2026 It is\u00a0a group of open source software and building blocks of many of the web applications and majority of the content management systems [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[455,91,1082,1,730,830,725,42,51,495,548],"tags":[1431,1432,1429,621,1237,291,798,1201,923,132,1419,1430,983],"class_list":["post-4794","post","type-post","status-publish","format-standard","hentry","category-apache2","category-banco-de-dados","category-centos-7-rhel-7","category-viazap","category-clusterweb","category-debian","category-hospedagem","category-leitura-recomendada","category-linux-linuxrs","category-profissional-de-ti","category-ubuntu-2","tag-18-04","tag-18-10","tag-7-2","tag-and","tag-apache2","tag-install","tag-lamp","tag-mariadb","tag-on","tag-php","tag-phpmyadmin","tag-ubuntu-16-04","tag-with"],"_links":{"self":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4794"}],"version-history":[{"count":1,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4794\/revisions"}],"predecessor-version":[{"id":4795,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4794\/revisions\/4795"}],"wp:attachment":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}