Tips and tricks

How to create a local dev Apache Mysql PHP Setup on Ubuntu / Debian

Tired of using MAMP ?

You should already have Apache installed on Ubuntu

Install Apaache2

sudo apt update && sudo apt install apache2
systemctl reload apache2
check config:
apachectl configtest

in /etc/apache2/apache2.conf , set your username – also can be done in ( /etc/apache2/envvars )

# These need to be set in /etc/apache2/envvars
User raduh
Group root

you can create a new config virtual host

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/devsite.conf

in that file enter

<virtualhost *:80="">
	ServerName devsite
	DocumentRoot "/home/raduh/Dropbox/hosts/devsite"
    Protocols h2 h2c http/1.1
    <ifmodule xsendfile_module="">
        XSendFilePath "/home/raduh/Dropbox/hosts/devsite"
	ServerAlias devsite.*
	<ifmodule wsgi_module="">
		WSGIDaemonProcess devsite processes=2 threads=15
		WSGIProcessGroup devsite
		WSGIScriptAlias /devsiteWsgiApp "/home/raduh/Dropbox/hosts/devsite/"

then you can do

$/opt/homebrew/opt/httpd/bin/httpd -V

Server version: Apache/2.4.48 (Unix)
Server built:   Jul  6 2021 20:11:03
Server's Module Magic Number: 20120211:105
Server loaded:  APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1

remember to add the entry in /etc/hosts

Access the config from /private/etc/apache2/httpd.conf/opt/homebrew/etc/httpd/httpd.conf ( homebrew ) ->

remember to change the User and Group to your user and group settings

also, remember to activate vhost_alias_module if you are going to use multiple hosts, which MAMP does use

LoadModule vhost_alias_module libexec/apache2/

start the server

/opt/homebrew/bin/httpd -k start

install php

sudo apt install php

make sure DirectoryIndex includes php

Add mysql

Normally, you can just install the native mysqld service

you will find it in system preferences > mysql

you can use a tool like MySQL Workbench to see currently running mysql

check currently running mysql instances with $ps aux | grep mysql

you can change the MySQL socket from the php.ini ( write php --ini in Terminal to find )

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =

Add xdebug

Normally, you can just install the native mysqld service

pecl install xdebug

normally this will be added to php.ini


using XDebug 3 – for phpstorm, you would also need to add


{"type":"main_options","images_arr":"'#ffffff'","enable_ajax":"off","soundcloud_apikey":"","bg_isparallax":"off","bg_slideshow_time":"0","bg_transition":"slidedown","site_url":"https:\/\/","theme_url":"https:\/\/\/wp-content\/themes\/qucreative\/","blur_ammount":"26","width_column":"50","width_section_bg":"","width_gap":"30","border_width":"0","border_color":"#ffffff","translate_cancel_comment":"Cancel reply","translate_leave_a_comment":"Leave a comment","translate_leave_a_comment_to":"Leave a comment to","is_customize_preview":"off","width_blur_margin":"30","gallery_w_thumbs_autoplay_videos":"off","content_enviroment_opacity":"30","menu_enviroment_opacity":"70","base_url":"https:\/\/"}