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

okay and with that method, you don’t even need to symlink anything ! Just bookmark the /srv/http directory !

Nice thanks !

To be noted, in :

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

You can uncomment only one out of those 3 lines:

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

or else you get a

 httpd: Configuration error: More than one MPM loaded. 

error when running :

sudo systemctl restart httpd 

Someone please help me!! My httpd isn’t stating… :slightly_frowning_face:

Summary

Read what you have on screen – you have syntax error in /etc/httpd/conf/httpd.conf on line 173 – check and repair it.

  1. Please do not post screenshots of terminal output, use copy+paste and proper format with the </> button
  2. this is a tutorial - not a help thread

Thank you for pointing that out.
I’m still new to this. I figured out the problem. :slightly_smiling_face:

Ok. I’ll try doing that next time. :+1:

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

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.