How to use Manjaro as a Web Server with Apache, MySQL and PHP (LAMP)

How to use Manjaro as a Web Server. I do believe that Manjaro is a stable Linux distribution, beautiful desktop as well. But with a little efforts, we can turn this cute distribution into a world class Web Server. LAMP (Linux Apache MySQL PHP) is a great combination to create a powerful, secure and stable web server on top of Linux system. This tutorial will show you how to install LAMP on Manjaro. Its a pretty long article but I tried to make it as clear as I can.

Step to build a web server on Manjaro

Please note that this tutorial requires a pretty basic knowledge on Terminal commands. Most steps here can be done via Terminal and as root privileges. 

Step 1. Update Manjaro
pacman -Syu
Step 2. Install and Configure Apache
pacman -S apache
Edit  /etc/httpd/conf/httpd.conf
nano /etc/httpd/conf/httpd.conf
Now search and comment out the following line
#LoadModule authn_file_module modules/mod_authn_file.so
Now restart Apache and start Apache on boot
systemctl enable httpd
systemctl restart httpd
Check the Apache status
systemctl status httpd
Output
[manjaro-tutorial manjaro]# systemctl status httpd
● httpd.service - Apache Web Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since mar 2016-11-08 06:17:44 WIB; 15s ago
 Main PID: 12618 (httpd)
    Tasks: 82 (limit: 4915)
   CGroup: /system.slice/httpd.service
           ├─12618 /usr/bin/httpd -k start -DFOREGROUND
           ├─12620 /usr/bin/httpd -k start -DFOREGROUND
           ├─12621 /usr/bin/httpd -k start -DFOREGROUND
           └─12622 /usr/bin/httpd -k start -DFOREGROUND

nov 08 06:17:44 manjaro-tutorial systemd[1]: Started Apache Web Server.
nov 08 06:17:44 manjaro-tutorial httpd[12618]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name
At this point the Apache is ready. You can test it via your web browser by typing the following address:
http://localhost or http://youripaddress

Step 3. Install MariaDb

To install MariaDB, you can use the following command on Terminal
pacman -S mysql
You will be asked to select which package to install. On the example below, I choose 1.
[manjaro-tutorial manjaro]# pacman -S mysql
:: There are 2 providers available for mysql:
:: Repository extra
   1) mariadb
:: Repository community
   2) percona-server

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

Packages (4) jemalloc-4.3.0-1  libmariadbclient-10.1.18-1  mariadb-clients-10.1.18-1  mariadb-10.1.18-1

Total Download Size:    19.40 MiB
Total Installed Size:  172.36 MiB

:: Proceed with installation? [Y/n]
Once completed, we need to initialize MariaDB to get work.
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Now start MariaDB and make it run on boot
systemctl enable mysqld
systemctl start mysqld
Check the status
systemctl status mysqld
Output:
[manjaro-tutorial manjaro]# systemctl status mysqld
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since mar 2016-11-08 06:25:17 WIB; 2s ago
  Process: 13831 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 13745 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] 
  Process: 13742 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 13801 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 27 (limit: 4915)
   CGroup: /system.slice/mariadb.service
           └─13801 /usr/sbin/mysqld

nov 08 06:25:16 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:16 140392520748544 [Note] InnoDB: Highest supported file format is Ba
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140392520748544 [Note] InnoDB: 128 rollback segment(s) are active.
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140392520748544 [Note] InnoDB: Waiting for purge to start
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140392520748544 [Note] InnoDB:  Percona XtraDB (http://www.percona
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140392520748544 [Note] Plugin 'FEEDBACK' is disabled.
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140391793817344 [Note] InnoDB: Dumping buffer pool(s) not yet star
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140392520748544 [Note] Server socket created on IP: '::'.
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: 2016-11-08  6:25:17 140392520748544 [Note] /usr/sbin/mysqld: ready for connections.
nov 08 06:25:17 manjaro-tutorial mysqld[13801]: Version: '10.1.18-MariaDB'  socket: '/run/mysqld/mysqld.sock'  port: 3306  MariaDB Ser
nov 08 06:25:17 manjaro-tutorial systemd[1]: Started MariaDB database server.

Step 4. Install PHP

To install PHP on Manjaro, use this command
pacman -S php php-apache
Once installed, we need to configure the httpd.conf file once again.
nano /etc/httpd/conf/httpd.conf
Comment out the following line
#LoadModule mpm_event_module modules/mod_mpm_event.so
And also copy and paste these lines to the bottom of the httpd.conf file
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule php7_module modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf
Save and close the httpd.conf file. At this point the web server is ready. 

Test PHP

Optionally, we can check and verify if the php is working. Create a new file, for example my.php inside Apache root directory (/srv/http/)
nano /srv/http/my.php
Type this line into it
<?php
 phpinfo();
?>
Its good to restart the web server.
systemctl restart httpd
Now open web browser and type this:
http://localhost/my.php
Ouput
Now all packages have been installed and well configured. Now our Web Server is ready for further use. Thanks for coming and please share this article if you found useful.

6 comments

im a beginer and iliterate but comneting out
LoadModule authn_file_module modules/mod_authn_file.so
broke things for me :(
helpful otherwise

cheap Christian Louboutin shoes, combining elegant style and cutting-edge technology, a variety of styles of cheap Christian Louboutin shoes, the pointer walks between your exclusive taste style.

Worked great for me. For those having probs editing the text file, log on as Root(Sudo)

Worked like a charm, indeed! Thank you very much!

Informative post! Thank you for sharing about feed water heater. Please keep sharing more posts with us.
Led Installation in Islamabad


EmoticonEmoticon