Support #813
Updated by Daniel Curtis over 8 years ago
{{>toc}} Here is a procedure on how I setup a Raspberry Pi as a wireless access point or wireless router on Arch Linux. h2. Prepare the Environment * Before installation of the components, make sure everything is up to date using the following command: <pre> pacman -Syu </pre> * Install a few dependencies: <pre> pacman -S sudo nginx git curl ntp dnsmasq hostapd wireless_tools </pre> * Edit the sudoers file: <pre> visudo </pre> #* Add the following to the end of the file: <pre> http ALL=(ALL) NOPASSWD:/sbin/ifdown wlan0,/sbin/ifup wlan0,/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf,/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf,/sbin/wpa_cli scan_results, /sbin/wpa_cli scan,/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 </pre> * Start and enable ntpd: <pre> systemctl enable ntpd systemctl start ntpd </pre> * Edit the wpa_supplicant config file: <pre> nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf </pre> #* And add the following: <pre> ctrl_interface=/run/wpa_supplicant update_config=1 </pre> * Start and enable wpa_supplicant for wlan0 at boot: <pre> systemctl enable wpa_supplicant@wlan0 systemctl start wpa_supplicant@wlan0 </pre> --- h2. Install PHP * Install fcgiwrap <pre> pacman -S fcgiwrap php-fpm </pre> * Edit the php-fpm config: <pre> vi /etc/php/php-fpm.conf </pre> #* Make the following changes: <pre> listen = /run/php-fpm/php-fpm.sock listen.owner = http listen.group = http listen.mode = 0660 </pre> * Create a configuration directory to make managing individual server blocks easier <pre> mkdir /etc/nginx/conf.d </pre> * Edit the main nginx config file: <pre> vi /etc/nginx/nginx.conf </pre> #* And strip down the config file and add the include statement at the end to make it easier to handle various server blocks: <pre> 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; } </pre> * Start and enable nginx, fcgiwrap, and php-fpm at boot: <pre> systemctl enable nginx systemctl start nginx systemctl enable fcgiwrap systemctl start fcgiwrap systemctl enable php-fpm systemctl start php-fpm </pre> h2. Install RaspAP * Clone the raspap-webgui from GitHub: <pre> sudo git clone https://github.com/billz/raspap-webgui /srv/http/raspap.example.com /var/www/raspap.example.com </pre> * Set the files ownership to the http user: <pre> sudo chown -R http:http /srv/http/raspap.example.com </pre> /var/www * Add a *raspap.example.com server block*: <pre> vi /etc/nginx/conf.d/raspap.example.com.conf </pre> #* Add the following: <pre> proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; server { listen 80; server_name raspap.example.com; root /srv/http/raspap.example.com; /var/www/raspap.example.com; access_log /var/log/raspap.example.com-access.log; error_log /var/log/raspap.example.com-error.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/raspap.example.com$fastcgi_script_name; /var/www/raspap.example.com$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } location ~ \.cgi$ { root /srv/http/raspap.example.com; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; /var/www/raspap.example.com; fastcgi_pass unix:/run/fcgiwrap.sock; include fastcgi.conf; } } </pre> * Add the PHP files for the site and change the ownership to the http user: <pre> chown -R http:http /srv/http/raspap.example.com /var/www/raspap.example.com </pre> * Restart nginx: <pre> systemctl restart nginx </pre> h2. Resources * https://github.com/billz/raspap-webgui * http://sirlagz.net/2013/02/06/script-web-configuration-page-for-raspberry-pi/ * http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/ * http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/ * https://wiki.archlinux.org/index.php/Software_Access_Point