lamp-on-void-linux.md 4.8 KB

How to install LAMP in Void Linux

To install LAMP (Linux, Apache, MySQL/MariaDB, PHP) on Void Linux, follow these steps below.

NOTE: This has been prepared for ease of use in mind, not security. Please do not use these instructions to setup on a public server environment. Use other proper manuals instead.

Install the things we need:

sudo xbps-install apache php-apache php-intl mariadb phpMyAdmin

To start Apache run these once to enable the services:

sudo ln -s /etc/sv/apache /var/service/apache
sudo ln -s /etc/sv/mysqld /var/service/mysqld

then:

sudo sv start apache

Your Apache www directory is /srv/www/apache

To have the www directory on your home:

ln -s /srv/www/apache ~/www

You will then have a www item on your home directory. You can then save files there without going too deep into the filesystem everytime.

Allow writes in the www directory:

sudo usermod -a -G _apache `whoami`
sudo chmod -R g+w /srv/www/apache

then do a Reboot to update the group assignments.

Make PHP7 work:

PHP7 does not work out of the box. Apache just prints out PHP code in plain text. It needs some changes for it to work:

sudo nano /etc/apache/httpd.conf

then comment:

#LoadModule mpm_event_module modules/mod_mpm_event.so

then, uncomment:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

To enable PHP, add these changes below to /etc/apache/httpd.conf:

Place this at the end of the LoadModule list:

LoadModule php7_module /usr/libexec/httpd/modules/libphp7.so
AddHandler php7-script .php

Place this at the end of the Include list:

Include /etc/apache/extra/php7_module.conf

To apply the new changes, run:

sudo sv restart apache

MariaDB fix + phpmyadmin:

sudo nano /etc/php/php.ini

then uncomment:

extension=mysqli

Run sudo nano /etc/apache/extra/phpmyadmin.conf

then put this text 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>

Add the lines to /etc/apache/httpd.conf:

#... phpMyAdmin configuration
Include /etc/apache/extra/phpmyadmin.conf

Install php-mysql package to make it work smoothly and also restart apache service to apply changes

sudo xbps-install php-mysql
sudo sv restart apache

phpMyAdmin username password problem:

https://stackoverflow.com/a/5908864

Run sudo nano /etc/webapps/phpMyAdmin/config.inc.php and add at the end:

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = true;

You can also add this so that it does not logout so often:

$cfg['ExecTimeLimit'] = 0;

To apply the changes, run:

sudo sv restart apache mysqld

WordPress issues

WordPress plugins not updating, wants FTP creds

Run sudo nano /etc/apache/httpd.conf

then change User ... and Group ... lines to your username:

User yourusername
Group yourusername
  • Void always has a group named the username, so we are replacing both of them with the username

Or even easier, run this command:

sudo sed -i "s/^User\s\(.*\)/User $USER/g" /etc/apache/httpd.conf ; sudo sed -i "s/^Group\s\(.*\)/Group $USER/g" /etc/apache/httpd.conf

Then:

sudo sv restart apache mysqld

An error occurred while updating Akismet Anti-Spam: Download failed. No working transports found

sudo nano /etc/php/php.ini

uncomment (remove ";" before the lines):

extension=curl
extension=openssl

Then restart apache

sudo sv restart apache

source: https://wordpress.org/support/topic/update-failed-download-failed-no-working-transports-found/

Prepartions for CakePHP 3

CakePHP is NOT able to connect to the database.

sudo nano /etc/php/php.ini

extension=intl ; uncomment
extension=pdo_mysql ; uncomment
extension=sockets ; for websockets - uncomment

Then under [intl] add:

intl.default_locale = en_utf8
intl.error_level = E_WARNING

https://stackoverflow.com/a/29405081

sudo nano /etc/apache/httpd.conf

uncomment:

LoadModule rewrite_module modules/mod_rewrite.so

find:

<Directory "/srv/www/apache">

make the line:

AllowOverride None

to:

AllowOverride All

then:

sudo sv restart apache

Ref:

https://serverfault.com/questions/400158/runit-created-first-service-directory-sv-start-testrun-does-not-work

https://wiki.archlinux.org/index.php/PhpMyAdmin

https://book.cakephp.org/3.0/en/installation.html