Skip to content

Instantly share code, notes, and snippets.

@adnan360
Last active June 10, 2023 11:13
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save adnan360/045d1e4c7619a1e1a9e779d6d35cca92 to your computer and use it in GitHub Desktop.
Save adnan360/045d1e4c7619a1e1a9e779d6d35cca92 to your computer and use it in GitHub Desktop.
Instructions on how to install LAMP on Void Linux for easier PHP development

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/httpd/conf/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 mysqld

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

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

@adnan360
Copy link
Author

adnan360 commented Jul 4, 2021

@pecel-warrior It might be an issue with /etc/hosts. Please check if the file has proper entries to resolve the host void. See here: https://www.cnblogs.com/JohanChan/p/12092337.html

Or if not working, post on Void Linux subreddit.

@johna23-lab
Copy link

Hi! the documentation works fine, BUT i'm trying to make a localhost https server and i get an error, looks i need to configure some .conf, can you please add a text explaining how to configure the apache web server for https//localhost (or ip)?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment