Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to install Lamp on Ubuntu 16.04
#1
How to install LAMP on Ubuntu 16.04


Step 1:Install Apache and Allow in Firewall
The Apache web server is among the most popular web servers in the world.

Code:
sudo apt-get update
sudo apt-get install apache2


Step 2:Set Global ServerName to Suppress Syntax Warnings


Next, we will add a single line to the [b]file to suppress a warning message. 

[/b]
Code:
/etc/apache2/apache2.conf


Code:
sudo apache2ctl configtest


Code:
Output
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK


Open up the main configuration file with your text edit:


Code:
sudo nano /etc/apache2/apache2.conf


Inside, at the bottom of the file, add a Server name directive, pointing to your primary domain name. If you do not have a domain name associated with your server, you can use your server's public IP address:

Step 3:Adjust the Firewall to Allow Web Traffic


Code:
sudo ufw app list


Code:
Output
Available applications:
 Apache
 Apache Full
 Apache Secure
 OpenSSH

If you look at the Apache Full profile, it should show that it enables traffic to ports 80 and 443:


Code:
sudo ufw app info "Apache Full"

Code:
Output
Profile: Apache Full
Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
server.

Ports:
 80,443/tcp

Allow incoming traffic for this profile
Code:
sudo ufw allow in "Apache Full"

Step 4: Install Mysql:
Code:
sudo apt-get install mysql-server
Code:
mysql_secure_installation

Step 5: Install PHP:

Code:
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

Code:
sudo nano /etc/apache2/mods-enabled/dir.conf

It will look like this:

/etc/apache2/mods-enabled/dir.conf

Code:
<IfModule mod_dir.c>
   DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

We want to move the PHP index file highlighted above to the first position after the Directory index  specification, like this:

/etc/apache2/mods-enabled/dir.conf

Code:
<IfModule mod_dir.c>
   DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>


Code:
sudo systemctl restart apache2

Code:
sudo systemctl status apache2


Code:
Sample Output
● apache2.service - LSB: Apache2 web server
  Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
 Drop-In: /lib/systemd/system/apache2.service.d
          └─apache2-systemd.conf
  Active: active (running) since Wed 2019-03-13 14:28:43 EDT; 45s ago
    Docs: man:systemd-sysv-generator(8)
 Process: 13581 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
 Process: 13605 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
   Tasks: 6 (limit: 512)
  CGroup: /system.slice/apache2.service
          ├─13623 /usr/sbin/apache2 -k start
          ├─13626 /usr/sbin/apache2 -k start
          ├─13627 /usr/sbin/apache2 -k start
          ├─13628 /usr/sbin/apache2 -k start
          ├─13629 /usr/sbin/apache2 -k start
          └─13630 /usr/sbin/apache2 -k start

Mar 13 14:28:42 ubuntu-16-lamp systemd[1]: Stopped LSB: Apache2 web server.
Mar 13 14:28:42 ubuntu-16-lamp systemd[1]: Starting LSB: Apache2 web server...
Mar 13 14:28:42 ubuntu-16-lamp apache2[13605]:  * Starting Apache httpd web server apache2
Mar 13 14:28:42 ubuntu-16-lamp apache2[13605]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerNam
Mar 13 14:28:43 ubuntu-16-lamp apache2[13605]:  *
Mar 13 14:28:43 ubuntu-16-lamp systemd[1]: Started LSB: Apache2 web server.


Install PHP Modules:

Code:
apt-cache search php- | less

Code:
ibnet-libidn-perl - Perl bindings for GNU Libidn
php-all-dev - package depending on all supported PHP development packages
php-cgi - server-side, HTML-embedded scripting language (CGI binary) (default)
php-cli - command-line interpreter for the PHP scripting language (default)
php-common - Common files for PHP packages
php-curl - CURL module for PHP [default]
php-dev - Files for PHP module development (default)
php-gd - GD module for PHP [default]
php-gmp - GMP module for PHP [default]

:

Code:
apt-cache show package_name

Code:
apt-cache show php-cli

Code:
Output

Description-en: command-line interpreter for the PHP scripting language (default)
This package provides the /usr/bin/php command interpreter, useful for
testing PHP scripts from a shell or performing general shell scripting tasks.
.
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
open source general-purpose scripting language that is especially suited
for web development and can be embedded into HTML.
.
This package is a dependency package, which depends on Debian's default
PHP version (currently 7.0).


Code:
sudo apt-get install php-cli

Code:
sudo apt-get install package1 package2 ...
[Image: n-560x95_FFFFFF_FFFFFF_000000_000000.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)