[HowTo] Install Apache, MariaDB (Mysql), PHP (LAMP)

Amazing
Comprehensive and clear instructions - many thanks

I’m experiencing the following error:

$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
2021-07-12 12:50:33 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2021-07-12 12:50:33 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2021-07-12 12:50:33 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-07-12 12:50:33 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-07-12 12:50:33 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2021-07-12 12:50:33 0 [ERROR] Aborting

I’ve changed the permissions on ibdata1 with

sudo chmod 660 /var/lib/mysql

but the error persists
output of ls -l on that file is

  -rw-rw---- 1 root root 12582912 Jul  6 15:28 /var/lib/mysql/ibdata1

That file (entiry directory actually) should belong to user mysql:mysql and its group:

$ sudo chown -R mysql:mysql /var/lib/mysql
1 Like

Solution was to delete /var/lib/mysql, then follow the installation
I would also add for future readers to make sure that in

/usr/lib/systemd/system/mariadb.service:

`ProtectHome=false`

Otherwise it wouldn’t have the permission to create databases

source:

I did only the ProtectHome change and it was enough to enable full use of MariaDB

Thank you!

Was a little confused about what to uncomment/add in httpd.conf. Just to be clear, there are three options for MPM (“event”, “prefork” and “worker”), and you can only uncomment one:

#LoadModule mpm_event_module modules/mod_mpm_event.so
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

The default in most distros is mod_mpm_prefork.so. On my installation, if I try to use mod_mpm_event.so or mod_mpm_worker.so, I get an error:

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.

In short, the differences are:

  • PREFORK: new process created to handle each connection.
  • WORKER: new processes created periodically, each process creates new thread to handle each connection.
  • EVENT: Similar to WORKER, but clients can keep connections open for longer in order to to reduce stateless connection overheads. Used for high-load websites/web applications.

To use the other options, you would have to learn how to build PHP with ZTS (Zend Thread Safety).

Thanks for tutorial. I just want to share my experience to be helpfull. I had php-apache installed (I’m on default PHP8), but php_module.conf wasn’t where it should be. Reinstalled php-apache one more time and i got php_module.conf in the right place. Any clue why.

1 Like

Thanks a lot, great guide !

When I launched phpmyadmin I had this error:

Composer detected issues in your platform: Your Composer dependencies require the following PHP extensions to be installed: iconv

I solved it by uncommenting iconv extension in /etc/php/php.ini as you suggested for bz2 and mysqli

So if you see others users meeting that error I suggest you to add this add this extension in your tuto :slightly_smiling_face:

Cheers

Great explanation, ty!
All was fine.

thank you so much brother :slightly_smiling_face:

I wondering where is actually our databases will be storeed, is it in basedir=/usr or datadir=/var/lib/mysql ?

$ mysql_install_db --help
  --basedir=path       The path to the MariaDB installation directory.
...
  --datadir=path       The path to the MariaDB data directory.
...

So the actual database (data) get’s stored in /var/lib/mysql.

Hi, I suggest you try asdf. It’s a system that allow use a dozen versions of an especific program language.
Should a try GitHub - asdf-vm/asdf: Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
It has a huge documentation.

1 Like

Apologies if this is already covered in the thread, but why would I enable Apache at boot through systemctl? I only want to run it while doing web development stuff.

I’m referring to one of the very first instructions about line 7 or 8.

It is not a requirement - you amend the guide to suit your use case.

Just a correction in the section of the MariaDB
The commands:

mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

mariadb-secure-installation

1 Like

not sure this is correct, but if we’re installing a LAMP stack on Manjaro/Arch, it’s probably for development purposes and not production, therefore in /etc/httpd/conf/httpd.conf it may be wise to change the Listen option…

Listen 127.0.0.1:80

in /etc/webapps/phpmyadmin/config.inc.php, i believe the line $cfg['TempDir'] = '/tmp'; is supposed to go in the ‘Directories for saving/loading files from server’ section

lastly, this was very helpful as already mentioned by @Krassimir

$ sudo chown YOURUSERNAME:http -R /srv/http/
$ sudo find /srv/http/ -type d -exec chmod 755 {} +
$ sudo find /srv/http/ -type f -exec chmod 644 {} +

Thank you so much! Excellent guide and very beginner friendly. Very new to both Manjaro and PHP and this relieved at least 2 days of brain ache!

1 Like

Stuck on Test Web Server:

I followed everything to a T until it says to enter into search engine:

http://ip.x.y.z

I get an error message instead of:

“It Works!”

prior to that, I did receive a message at the end of

systemctl status httpd

it says:

httpd[68586]: AH00558: httpd: 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

I followed the ServerName direction properly and even went back to check. I tried with and without the hashtag. Same for the load direction.

This article is accurate, perfect and on point. thanksa lot.

1 Like

no nonsense, short and precise, thank you!