{"id":6955,"date":"2022-10-27T12:45:27","date_gmt":"2022-10-27T12:45:27","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=6955"},"modified":"2022-10-27T12:45:27","modified_gmt":"2022-10-27T12:45:27","slug":"how-to-install-lamp-linux-apache-mysql-maria-php-on-debian-11","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2022\/10\/27\/how-to-install-lamp-linux-apache-mysql-maria-php-on-debian-11\/","title":{"rendered":"How to install LAMP (Linux, Apache, MySql-Maria, PHP) on Debian 11"},"content":{"rendered":"<p>This article describes How to install LAMP (Linux, Apache, MySql-Maria, PHP) on Debian 11. The first step is to install a Devian server.<\/p>\n<p><!--more--><\/p>\n<p>Once Debian 11 is installed, let&#8217;s follow and install the rest with the apt meta-packager..<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo apt install mariadb-server php libapache2-mod-php php-zip php-mbstring php-cli php-common php-curl php-xml php-mysql\n<\/pre>\n<p><a href=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_07-44-00.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6956\" src=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_07-44-00.png\" alt=\"\" width=\"873\" height=\"580\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-44-00.png 873w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-44-00-300x199.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-44-00-768x510.png 768w\" sizes=\"auto, (max-width: 873px) 100vw, 873px\" \/><\/a><\/p>\n<p>After MySQL and PHP installation finishes, it is often recommended to secure MySQL installation using mysql_secure_installation the utility.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo mysql_secure_installation\n<\/pre>\n<p><a href=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_07-50-59.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6958\" src=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_07-50-59.png\" alt=\"\" width=\"644\" height=\"977\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-50-59.png 644w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-50-59-198x300.png 198w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/a><\/p>\n<p>Now lets change some PHP settings.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo nano \/etc\/php\/7.4\/apache2\/php.ini\n<\/pre>\n<p>Install Apache<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo apt install apache2\n<\/pre>\n<p><a href=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_07-57-20.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6960\" src=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_07-57-20.png\" alt=\"\" width=\"538\" height=\"116\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-57-20.png 538w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_07-57-20-300x65.png 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/a><\/p>\n<p>Once installed, the Apache webserver will be up and serving a default web page. There are several ways to confirm that the Apache webserver is up and running. The easiest option is to use the lsof utility:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo lsof -i :80\n<\/pre>\n<p>Also, curl.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ curl 192.168.0.33 | grep Apache\n<\/pre>\n<p>The other option is to simply navigate to the IP address of the webserver.<\/p>\n<p><a href=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_08-03-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6961\" src=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_08-03-10.png\" alt=\"\" width=\"812\" height=\"284\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_08-03-10.png 812w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_08-03-10-300x105.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_08-03-10-768x269.png 768w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/a><\/p>\n<p>Now we have utilities for managing both sites and modules in Apache.<\/p>\n<p><em>-a2ensite: This utility is used to enable a website after the configuration file has been created.<br \/>\n-a2dissite: This utility is used to disable a website by specifying the website\u2019s configuration file.<br \/>\n-a2enmod: This utility is used to enable extra Apache2 modules.<br \/>\n-a2dismod: This utility is used to disable extra Apache2 modules.<br \/>\n-a2query: This utility can be used to gather information about sites currently enabled.<\/em><\/p>\n<p>Let&#8217;s use these to install Apache modules.<\/p>\n<p>Note: This is important if installing ssl certs at a later date. See: <a href=\"https:\/\/www.geekdecoder.com\/set-up-lets-encrypt-on-debian-11-with-apache-server\/\" target=\"_blank\" rel=\"noopener\">Set Up Let\u2019s Encrypt On Debian 11 With Apache Server<\/a><\/p>\n<p>You can check the apache modules available at \/etc\/apache2\/mods-available:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo ls -la \/etc\/apache2\/mods-available\n<\/pre>\n<p>These are modules that are available for apache. Not all are activated. To see that active modules. Check ls -la \/etc\/apache2\/mods-enabled\/<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo ls -la \/etc\/apache2\/mods-enabled\/\n<\/pre>\n<p><a href=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_12-04-18.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6985\" src=\"https:\/\/linuxandotherstuff.net\/wp-content\/uploads\/2022\/10\/2022-10-27_12-04-18.png\" alt=\"\" width=\"813\" height=\"527\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_12-04-18.png 813w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_12-04-18-300x194.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2022\/10\/2022-10-27_12-04-18-768x498.png 768w\" sizes=\"auto, (max-width: 813px) 100vw, 813px\" \/><\/a><\/p>\n<pre>As we can see...the ssl module is not avaiable! Let's enable it with a2enmod!<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo a2enmod ssl\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nConsidering dependency setenvif for ssl:\nModule setenvif already enabled\nConsidering dependency mime for ssl:\nModule mime already enabled\nConsidering dependency socache_shmcb for ssl:\nEnabling module socache_shmcb.\nEnabling module ssl.\nSee \/usr\/share\/doc\/apache2\/README.Debian.gz on how to configure SSL and create self-signed certificates.\nTo activate the new configuration, you need to run:\n  systemctl restart apache2\n<\/pre>\n<p>Let&#8217;s restart<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo systemctl restart apache2\n<\/pre>\n<p>Now, we can see the modules enabled.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo ls -la \/etc\/apache2\/mods-enabled\/ | grep ssl\nlrwxrwxrwx 1 root root   26 Oct 27 12:07 ssl.conf -&gt; ..\/mods-available\/ssl.conf\nlrwxrwxrwx 1 root root   26 Oct 27 12:07 ssl.load -&gt; ..\/mods-available\/ssl.load\n<\/pre>\n<p>Lets see if the apache ssl server is working ok.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$sudo lsof -i :443\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nCOMMAND  PID     USER   FD   TYPE DEVICE SIZE\/OFF NODE NAME\napache2 7994     root    6u  IPv6  39751      0t0  TCP *:https (LISTEN)\napache2 7995 www-data    6u  IPv6  39751      0t0  TCP *:https (LISTEN)\napache2 7996 www-data    6u  IPv6  39751      0t0  TCP *:https (LISTEN)\napache2 7997 www-data    6u  IPv6  39751      0t0  TCP *:https (LISTEN)\napache2 7998 www-data    6u  IPv6  39751      0t0  TCP *:https (LISTEN)\napache2 7999 www-data    6u  IPv6  39751      0t0  TCP *:https (LISTEN)\n<\/pre>\n<p>Now, let&#8217;s create a site. The first thing to do when setting up a new site is to create a new configuration file in the &#8220;sites-available&#8221; directory.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ cd \/etc\/apache2\/sites-available\n<\/pre>\n<p>Checking this folder, we see 2 files:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ ls -la\ntotal 20\ndrwxr-xr-x 2 root root 4096 Oct 27 12:48 .\ndrwxr-xr-x 8 root root 4096 Oct 27 12:48 ..\n-rw-r--r-- 1 root root 1332 Jun  9 04:22 000-default.conf\n-rw-r--r-- 1 root root 6338 Jun  9 04:26 default-ssl.conf\n<\/pre>\n<blockquote><p>Note: The 0&#8217;s at the front of the file name simply force an order when a directory is scanned and the results are processed one by one. With apache, the first virtual host read\/processed is the one clients are sent to if they connect requesting a host name that your server isn&#8217;t configured to serve up.<\/p><\/blockquote>\n<p>-000-default.conf- normal apache configuration file<br \/>\n-default-ssl.conf-This is the default example configuration of default-ssl.conf provided by Apache<\/p>\n<p>Let&#8217;s create a site by copying the 000-default.conf.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo cp 000-default.conf yourdomain.conf\n<\/pre>\n<p>This will copy the configuration from the default site into the new site configuration file for further modification. Open the new site configuration page with a text editor.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo nano yourdomain.conf\n<\/pre>\n<p>Let&#8217;s modify some of the settings. Change the following to your information:<\/p>\n<p>ServerAdmin webmaster@localhost (where you receive email)<br \/>\nDocumentRoot \/var\/www\/yoursite (where you wnat the files for your website to live)<\/p>\n<p>Save the changes to this file and exit the text editor.<\/p>\n<p>Lets create the file directory from above and change the ownership and permissions.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo mkdir -p \/var\/www\/yoursite\n&#x5B;code]\n\nLets create a test file.\n\n&#x5B;code]\n$ sudo nano \/var\/www\/yoursite\/index.html\n<\/pre>\n<p>Add the following to it.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;\n  &lt;head&gt;\n    &lt;meta charset=&quot;utf-8&quot;&gt;\n    &lt;title&gt;Welcome to yoursite.com&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Success! yoursite.com home page!&lt;\/h1&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>Let&#8217;s set the ownership and permission to the site directory<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo chown -R www-data:www-data \/var\/www\/yoursite\n$ sudo chmod 755 \/var\/www\/yoursite\n<\/pre>\n<p>Now, apache needs to be told to serve this new site.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo a2ensite yoursite.conf\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nEnabling site ipgw.io.\nTo activate the new configuration, you need to run:\n  systemctl reload apache2\n<\/pre>\n<p>Now run:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo systemctl reload apache2\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ sudo a2query -s yoursite.conf\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n...yoursite.com (enabled by site administrator)\n<\/pre>\n<p>Now, we can load the website with the domain name you are hosting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes How to install LAMP (Linux, Apache, MySql-Maria, PHP) on Debian 11. The first step is to install a Devian server.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,25,70,84],"tags":[],"class_list":["post-6955","post","type-post","status-publish","format-standard","hentry","category-apache","category-debian","category-mysql","category-php"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/6955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=6955"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/6955\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=6955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=6955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=6955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}