30 C
Jaipur
Sunday, October 25, 2020

Install LAMP On Manjaro

Must read

This Electric Car Is Made From Plastic Waste and Natural Fibers

Although humans have evolved to be the most intelligent species in the world, we still haven’t figured out how to restore our continuously-degrading natural...

Zozo Championship live stream: how to watch 2020’s final round online from anywhere

The new PGA Tour golf season is now under way and this week the action turns to California and the Zozo Championship 2020. Normally...

Valorant Might Be Coming to Mobile Phones Very Soon

Although there are have been reports about Riot prototyping its flagship tactical FPS title, Valorant for gaming consoles, we haven’t seen any further developments...

Chucking out my old Amazon Echo for the new one made me feel like a Pixar villain

When swapping out my old first generation Amazon Echo for the stylish new Amazon Echo (2020) I thought I’d feel relief, joy, excitement. Instead,...

LAMP stands for Linux, Apache, MySQL/MariaDB, and PHP or Perl or Python. If you are using Manjaro, you can easily install LAMP on Manjaro.

Manjaro is one of the cleanest Linux distributions available. If you are using Manjaro for web development, you can easily install LAMP on Manjaro Linux. All the required packages are already available in the default repositories.

Install LAMP On Manjaro

Before installing any package, update the system using pacman.

sudo pacman -Syu

The above command will ask for the sudo password, enter the password and it’ll check for any available updates.

Install Apache

Next, install Apache. Apache is the most popular web server and its extensive documentation helps new users configure it easily. Currently, Apache’s latest stable version is v2.4.46 which is available in the Manjaro repository.

One can either fire up the GUI software installer and search for ‘apache’ to install it or use the CLI package manager ‘pacman’ command.

Install Apache on Manjaro GUI

Or use the CLI to install Apache –

sudo pacman -S apache
Install Apache on Manjaro CLI
Install Apache on Manjaro CLI

It’s just a small package and will be installed in a few seconds. Once the installation has completed, open the Apache configuration file that exists on /etc/httpd/conf/httpd.conf and comment out the following line –

# LoadModule unique_id_module modules/mod_unique_id.so
GUI text editor - mousepad
sudo mousepad /etc/httpd/conf/httpd.conf

CLI text editor - nano
sudo nano /etc/httpd/conf/httpd.conf
Edit Apache configuration
Edit Apache configuration

Save the file and that is it. We can now enable and start the apache server by using the following command –

sudo systemctl enable httpd
sudo systemctl restart httpd

Once done, confirm it by checking service status or by visiting the http://localhost in the browser. If it shows the following page, it means the server is up and running completely fine.

sudo systemctl status httpd
Apache server
Apache server

Important information

By default, the server will serve files in the browser located at ‘/srv/http’. You can change it from the server configuration file or leave it as it is for ease of use. For more information, check out the Apache newcomers guide.

Install MySQL

MariaDB is the default implementation of MySQL in Arch Linux. To install mariadb, use the following command –

sudo pacman -S mysql

The installation will prompt to choose the provider for mysql. Hit enter to choose the default repository, i.e. MariaDB.

[[email protected] http]$ sudo pacman -S mysql
:: There are 2 providers available for mysql:
:: Repository extra
   1) mariadb
:: Repository community
   2) percona-server

Enter a number (default=1): 

Next press enter to confirm the installation.

[[email protected] http]$ sudo pacman -S mysql
:: There are 2 providers available for mysql:
:: Repository extra
   1) mariadb
:: Repository community
   2) percona-server

Enter a number (default=1): 
resolving dependencies...
looking for conflicting packages...

Packages (1) mariadb-10.5.5-2

Total Installed Size:  234.53 MiB

:: Proceed with installation? [Y/n] 

The installation may take 10 to 20 seconds depending on your internet speed. Once completed, begin by initializing the MariaDB data directory using the following command –

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

And that is it. MariaDB is installed on Manjaro. Let’s enable and start it by using the following commands –

sudo systemctl enable mysqld
sudo systemctl restart mysqld

Confirm the installation by checking the service status –

sudo systemctl status mysqld

Desired output –

[[email protected] http]$ sudo systemctl status mysqld
● mariadb.service - MariaDB 10.5.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2020-10-04 12:51:42 IST; 1min 2s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 13481 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 13482 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galer>
    Process: 13508 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
   Main PID: 13491 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 9446)
     Memory: 78.3M
     CGroup: /system.slice/mariadb.service
             └─13491 /usr/bin/mariadbd

Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] InnoDB: 10.5.5 started; log sequence number 4062669; tr>
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_b>
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] Server socket created on IP: '::'.
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] InnoDB: Buffer pool(s) load completed at 201004 12:51:42
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] Reading of all Master_info entries succeeded
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] Added new Master_info '' to hash table
Oct 04 12:51:42 Manjaro mariadbd[13491]: 2020-10-04 12:51:42 0 [Note] /usr/bin/mariadbd: ready for connections.
Oct 04 12:51:42 Manjaro mariadbd[13491]: Version: '10.5.5-MariaDB'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Arch Linux
Oct 04 12:51:42 Manjaro systemd[1]: Started MariaDB 10.5.5 database server.
lines 1-25/25 (END)

The final step toward completing mysql setup, run mysql_secure_installation to set up the root password and remove the test database for security.

sudo mysql_secure_installation
[[email protected] http]$ sudo 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
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

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!

That’s it. You can now login to mysql root user and create or manage databases from mySQL command-line interface.

mysql -u root -p

In another tutorial, I will show you how to create mysql user, grant privileges, and create databases in mysql.

Install PHP

The last part of LAMP is PHP. PHP 7 is already available in the Manjaro repository. To install PHP and PHP Apache module in Manjaro, simply use pacman command –

sudo pacman -S php php-apache

Set up PHP Apache module by updating a few entries in the apache configuration file that exists at /etc/httpd/conf/httpd.conf.

sudo mousepad /etc/httpd/conf/httpd.conf

Or

sudo nano /etc/httpd/conf/httpd.conf

Find and comment out the following line in the configuration –

#LoadModule mpm_event_module modules/mod_mpm_event.so

Find and uncomment the following line in the configuration –

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

And at the end of the file, add the following lines –

LoadModule php7_module modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf

Now save the file and exit. Restart the apache server to make sure all the configurations are loaded properly.

sudo systemctl restart httpd

That’s all. PHP is now installed and configured to be used with the Apache webserver.

To test the PHP installation, create a file at /srv/http/phpinfo.php and write the following PHP code –

<?php
phpinfo();
?>

Now open this file in the browser by visiting the localhost/phptest.php.

PHP information
PHP information

With the above set of tools, you should be able to develop and test your web application without any issues. If you want a little more ease in handling databases, we can do that by installing phpMyAdmin. It is a browser-based database management system.

It is extremely easy to use and can be installed on Manjaro in no time.

Install phpMyAdmin

phpMyAdmin is easy to use the graphical interface to create, delete, and update databases.

sudo pacman -S phpmyadmin

phpMyAdmin requires PHP mysqli and PHP bz2 extensions enabled. Edit the php.ini and comment out the following lines to enable the extensions –

extension=bz2
extension=mysqli

Now save and close the file.

In other Linux distributions, phpMyAdmin by default works on http://localhost/phpmyadmin but in Manjaro, we will have to manually configure the apache server to serve phpMyAdmin on this address.

Create apache configuration file for phpMyAdmin.

sudo mousepad /etc/httpd/conf/extra/phpmyadmin.conf

And paste the following configurations in the file –

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
DirectoryIndex index.php
AllowOverride All
Options FollowSymlinks
Require all granted
</Directory>

The Alias refers to the web address where phpMyAdmin will be served and the Directory is the location of phpMyAdmin. Save the file and close it.

Now we’ll need to add the above configuration file in the main Apache configuration in order to enable it. Open the apache configuration and include the address of the phpMyAdmin configuration.

sudo mousepad /etc/httpd/conf/httpd.conf

Paste the following line at the end of file.

Include conf/extra/phpmyadmin.conf

Once done, restart the apache server –

sudo systemctl restart httpd

That is all! Now visit the http://localhost/phpmyadmin and login to the database using the credentials you created above.

Summary

To summarize it, in this article, we successfully installed LAMP in Manjaro and setup phpMyAdmin to easily manage databases on our system. Alternatively, one can also use DBeaver to manage databases graphically. DBeaver is a free and open-source tool for managing not only mysql but other popular database systems such as Microsoft SQL, Oracle, SQL lite, PostgreSQL, and many more.

If you face any trouble in this article, let me know in the comment section below this article.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

This Electric Car Is Made From Plastic Waste and Natural Fibers

Although humans have evolved to be the most intelligent species in the world, we still haven’t figured out how to restore our continuously-degrading natural...

Zozo Championship live stream: how to watch 2020’s final round online from anywhere

The new PGA Tour golf season is now under way and this week the action turns to California and the Zozo Championship 2020. Normally...

Valorant Might Be Coming to Mobile Phones Very Soon

Although there are have been reports about Riot prototyping its flagship tactical FPS title, Valorant for gaming consoles, we haven’t seen any further developments...

Chucking out my old Amazon Echo for the new one made me feel like a Pixar villain

When swapping out my old first generation Amazon Echo for the stylish new Amazon Echo (2020) I thought I’d feel relief, joy, excitement. Instead,...

Audi’s New Headlights Can Project Animations on Walls

With automobile-technology developing at lightning speed, we have seen several useful features make their way to modern cars. Now, Audi has come up with...