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

This guide is slightly outdated, we have already PHP8 so these lines should look like:

LoadModule php_module modules/libphp.so
AddHandler php-script php
Include conf/extra/php_module.conf
1 Like

thanks, fixed

you solve it? i got this error too

Hi @dstyle ,

First of all thanks for the tutorial.
Is there any tutorial how to use two php version like 7.4 and 8 together with virtual hosting and defining in the virtual host info which php version to use?

I did search in the net and didn’t find any good one.

Tried to follow this one with no luck. link arch wiki

If there is any tutorial please share.
Thanks

anyone on how to correctly setup a symbolic link for web development ? I keep messing up the /srv/http directory…

I’m looking to create a symlink between a folder in my home folder and the http folder so that i can modify files with out sudo but can see the output in localhost.

Anyone ?

I use:

sudo chown MYUSERNAME:http -R /srv/http/

sudo find /srv/http/ -type d -exec chmod 755 {} +
sudo find /srv/http/ -type f -exec chmod 644 {} +

Replace MYUSERNAME with appropriate!

3 Likes

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 
1 Like

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
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