How To Set-up LAMP Stack On Ubuntu 18.10
- 00:36 lsb_release -a
- 00:50 apt install apache2 mariadb-server -y
- 01:06 systemctl enable apache2 mariadb
- 01:15 systemctl start apache2 mariadb
- 01:47 mysql_secure_installation
- 02:22 mysql -u root -p
- 02:53 apt install php php-gd php-pdo php-mysql php-simplexml php-mbstring php-zip
- 03:10 apt install php-pear php-dev libmcrypt-dev -y
- 03:33 pecl install mcrypt-1.0.2
- 03:51 vim /etc/php/7.2/cli/php.ini
- 04:17 php -m | grep mcrypt
- 04:53 vim test.php
- 05:22 apache2 -v
- 05:32 mariadb -V
- 05:38 php -v
Installation of LAMP Stack On Ubuntu 18.10:
Pre-requisites:
Apache 2.4.34
PHP 7.2
MariaDB 5.5
Check the version of Ubuntu by using the lsb_release command.
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.10
Release: 18.10
Codename: cosmic
Install Both Apache And Mariadb server using apt command
root@linuxhelp:~# apt install apache2 mariadb-server -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils galera-3 gawk libaio1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libhtml-template-perl libjemalloc2 liblua5.2-0 libmysqlclient20
libreadline5 libsigsegv2 libterm-readkey-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common mariadb-server-10.1
mariadb-server-core-10.1 mysql-common socat
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl
.
.
.
.
Setting up mariadb-server-10.1 (1:10.1.29-6ubuntu2) ...
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up mariadb-server (1:10.1.29-6ubuntu2) ...
Processing triggers for libc-bin (2.28-0ubuntu1) ...
Processing triggers for systemd (239-7ubuntu10) ...
Processing triggers for ufw (0.35-6) ...
After the successful installation Of Apache And MariaDb, Enable the service of Apache and MariaDB
root@linuxhelp:~# systemctl enable apache2 mariadb
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2
Start the service of Apache and Mariadb as follows
root@linuxhelp:~# systemctl start apache2 mariadb
Check the status of Apache And MariaDB by executing the following command.
root@linuxhelp:~# systemctl status apache2 mariadb
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-04-09 00:29:30 PDT; 2min 15s ago
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-04-09 00:29:47 PDT; 1min 58s ago
Secure the MariaDB through the below installation procedure
root@linuxhelp:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Log in to the MariaDB using root credentials as follows
root@linuxhelp:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 56
Server version: 10.1.29-MariaDB-6ubuntu2 Ubuntu 18.10
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> exit
Bye
By default,version of PHP in Ubuntu 18.10 is 7.2. Install the default most-popular modules by executing the following command.
root@linuxhelp:~# apt install php php-gd php-pdo php-mysql php-simplexml php-mbstring php-zip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.2-common' instead of 'php-pdo'
Note, selecting 'php7.2-xml' instead of 'php-simplexml'
The following additional packages will be installed:
libapache2-mod-php7.2 libzip4 php-common php7.2 php7.2-cli php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache
php7.2-readline php7.2-zip
.
.
.
.
.
apache2_invoke: Enable module php7.2
Setting up php-mysql (1:7.2+62) ...
Setting up php7.2 (7.2.15-0ubuntu0.18.10.2) ...
Setting up php (1:7.2+62) ...
To install mcrypt module,the below given three modules should be installed in advance which is pre-requisite for installation of mcrypt module.
root@linuxhelp:~# apt install php-pear php-dev libmcrypt-dev -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
autoconf automake autopoint autotools-dev build-essential debhelper dh-autoreconf dh-strip-nondeterminism dpkg-dev dwz fakeroot
g++ g++-8 gcc gcc-8 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libarchive-cpio-perl libasan5
libatomic1 libc-dev-bin libc6-dev libfakeroot libfile-stripnondeterminism-perl libgcc-8-dev libitm1 liblsan0 libltdl-dev
libmail-sendmail-perl libmcrypt4 libmpx2 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libquadmath0 libssl-dev libssl1.1
libstdc++-8-dev libsys-hostname-long-perl libtool libtsan0 libubsan1 linux-libc-dev m4 make manpages-dev php7.2-dev pkg-php-tools
po-debconf shtool
.
.
.
.
Setting up dh-autoreconf (19) ...
Setting up dh-strip-nondeterminism (0.042-1) ...
Setting up debhelper (11.3.2ubuntu1) ...
Setting up pkg-php-tools (1.36) ...
Processing triggers for libc-bin (2.28-0ubuntu1) ...
After the Successful installation of pre-requisites modules, install the mcrypt module using pecl .
root@linuxhelp:~# pecl install mcrypt-1.0.2
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading mcrypt-1.0.2.tgz ...
Starting to download mcrypt-1.0.2.tgz (33,698 bytes)
.........done: 33,698 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
libmcrypt prefix? [autodetect] :
.
.
.
.
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
Add the mcrypt extension in the php configuration file of Ubuntu 18.10
root@linuxhelp:~# vim /etc/php/7.2/cli/php.ini
extension-mcrypt.so
.
.
:x!
Check the mcrypt module by grepping in the following way.
root@linuxhelp:~# php -m | grep mcrypt
mcrypt
Test the configuration of Apache by entering the IP address as follows
create a file named test.php under the document root directory of Apache server to test the PHP Configuration in the browser.
root@linuxhelp:/var/www/html# vim test.php
<?php
phpinfo();
?>
:x!
Test the Configuration of PHP In Browser
Check the versions of Apache MAriaDB and PHP by executing the following commands.
root@linuxhelp:/var/www/html# apache2 -v
Server version: Apache/2.4.34 (Ubuntu)
Server built: 2019-04-03T12:50:09
root@linuxhelp:/var/www/html# mariadb -V
mariadb Ver 15.1 Distrib 10.1.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
root@linuxhelp:/var/www/html# php -v
PHP 7.2.15-0ubuntu0.18.10.2 (cli) (built: Mar 25 2019 16:02:58) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.15-0ubuntu0.18.10.2, Copyright (c) 1999-2018, by Zend Technologies
With this, the method to set-up LAMP Stack On Ubuntu 18.10 comes to an end.
Comments ( 0 )
No comments available