Support #813

Setup a Raspberry Pi as a Wireless Access Point/Router on Arch

Added by Daniel Curtis over 4 years ago. Updated over 4 years ago.

In Progress
Wireless Support
Target version:
Start date:
Due date:
% Done:


Estimated time:
1.50 h
Spent time:


Here is a procedure on how I setup a Raspberry Pi as a wireless access point or wireless router on Arch Linux.

NOTE: The original project used Raspbian as the base Operating System, so I needed to adapt the existing code to work on Arch Linux.

WARNING: This is currently (6/4/16) a work in progress. As such some features may not work properly.

Prepare the Environment

  • Before installation of the components, make sure everything is up to date using the following command:
    pacman -Syu
  • Install a few dependencies:
    pacman -S sudo nginx git curl ntp dnsmasq hostapd wireless_tools
  • Edit the sudoers file:
    • Add the following to the end of the file:
      http ALL=(ALL) NOPASSWD:/usr/bin/ifconfig,/usr/bin/sudo,/usr/bin/ip link set wlan0 down,/usr/bin/ip link set wlan0 up,/bin/cat /etc/wpa_supplicant/wpa_supplicant-wlan0.conf,/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant-wlan0.conf,/usr/bin/wpa_cli scan_results, /usr/bin/wpa_cli scan,/usr/bin/systemctl restart wpa_supplicant@wlan0,/usr/bin/systemctl enable wpa_supplicant@wlan0,/usr/bin/systemctl disable wpa_supplicant@wlan0,/usr/bin/systemctl is-enabled,/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf, /bin/systemctl start hostapd,/bin/systemctl stop hostapd,/bin/systemctl stop dnsmasq, /bin/systemctl stop dnsmasq,/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf
  • Start and enable ntpd:
    systemctl enable ntpd
    systemctl start ntpd
  • Edit the wpa_supplicant config file:
    nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
    • And add the following:
  • Start and enable wpa_supplicant for wlan0 at boot:
    systemctl enable wpa_supplicant@wlan0
    systemctl start wpa_supplicant@wlan0

Install PHP

  • Install fcgiwrap
    pacman -S fcgiwrap php-fpm
  • Edit the php-fpm config:
    vi /etc/php/php-fpm.conf
    • Make the following changes:
      listen = /run/php-fpm/php-fpm.sock
      listen.owner = http = http
      listen.mode = 0660
  • Create a configuration directory to make managing individual server blocks easier
    mkdir /etc/nginx/conf.d
  • Edit the main nginx config file:
    vi /etc/nginx/nginx.conf
    • And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
      worker_processes  1;
      error_log  /var/log/nginx-error.log;
      events {
          worker_connections  1024;
      http {
          include       mime.types;
          default_type  application/octet-stream;
          sendfile        on;
          keepalive_timeout  65;
          include /etc/nginx/conf.d/*.conf;
  • Start and enable nginx, fcgiwrap, and php-fpm at boot:
    systemctl enable nginx
    systemctl start nginx
    systemctl enable fcgiwrap
    systemctl start fcgiwrap
    systemctl enable php-fpm
    systemctl start php-fpm

Install WiFiPi AP

  • Clone the WiFiPi AP code:
    sudo git clone /srv/http/
  • Set the files ownership to the http user:
    sudo chown -R http:http /srv/http/
  • Add a server block:
    vi /etc/nginx/conf.d/
    • Add the following:
      proxy_buffer_size   128k;
      proxy_buffers   4 256k;
      proxy_busy_buffers_size   256k;
      server {
          listen       80;
          root         /srv/http/;
          access_log   /var/log/;
          error_log    /var/log/;
          location / {
              index  index.php index.html index.htm;
          location ~ \.php$ {
              fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
              fastcgi_buffer_size 128k;
              fastcgi_buffers 4 256k;
              fastcgi_busy_buffers_size 256k;
              fastcgi_param SCRIPT_FILENAME /srv/http/$fastcgi_script_name;
              fastcgi_param PATH_INFO $fastcgi_script_name;
              include fastcgi_params;
          location ~ \.cgi$ {
              root           /srv/http/;
              fastcgi_buffer_size 128k;
              fastcgi_buffers 4 256k;
              fastcgi_busy_buffers_size 256k;
              fastcgi_pass   unix:/run/fcgiwrap.sock;
              include        fastcgi.conf;
  • Add the PHP files for the site and change the ownership to the http user:
    chown -R http:http /srv/http/
  • Restart nginx:
    systemctl restart nginx



#1 Updated by Daniel Curtis over 4 years ago

  • Description updated (diff)
  • Status changed from New to In Progress
  • % Done changed from 0 to 20

#2 Updated by Daniel Curtis over 4 years ago

  • Description updated (diff)
  • % Done changed from 20 to 40

#3 Updated by Daniel Curtis over 4 years ago

  • Description updated (diff)

Also available in: Atom PDF