Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install and configure CUPS 2.1.2 on CentOS 7 (LXC running on Proxmox VE) host including AirPrint

Basic setup, e.g. enable ssh

yum -y install epel-release
yum -y upgrade
yum -y install openssh-server net-tools iputils psmisc less which man mc bash-completion bash-completion-extras bash-argsparse bind-utils traceroute htop mtr
echo "export HISTTIMEFORMAT='%F %T  '" > /etc/profile.d/
echo "export HISTIGNORE='ls -l:pwd:date:'" >> /etc/profile.d/
echo "export HISTCONTROL=ignoredups" >> /etc/profile.d/
systemctl enable sshd
systemctl start sshd

Build and install CUPS from source

yum -y install gcc gcc-c++ make rpm-build wget tar bzip2 gnutls-devel pam-devel dbus-devel avahi-devel systemd-devel system-config-printer-libs pygobject2 python-cups python-lxml foomatic-db-ppds ghostscript-cups cups-filesystem cups-filters cups-filters-libs cups-filters-libs cups-pdf cups-bjnp
rpmbuild -ta --without libusb1 cups-2.1.3-source.tar.bz2
yum -y install rpmbuild/RPMS/x86_64/cups-2.1.3-1.x86_64.rpm rpmbuild/RPMS/x86_64/cups-libs-2.1.3-1.x86_64.rpm rpmbuild/RPMS/x86_64/cups-devel-2.1.3-1.x86_64.rpm rpmbuild/RPMS/x86_64/cups-lpd-2.1.3-1.x86_64.rpm
rm -rf rpmbuild

Configure CUPS


echo "service printer" > /etc/xinetd.d/cups-lpd
echo "{" >> /etc/xinetd.d/cups-lpd
echo "        socket_type = stream" >> /etc/xinetd.d/cups-lpd
echo "        protocol = tcp" >> /etc/xinetd.d/cups-lpd
echo "        wait = no" >> /etc/xinetd.d/cups-lpd
echo "        user = lp" >> /etc/xinetd.d/cups-lpd
echo "        group = sys" >> /etc/xinetd.d/cups-lpd
echo "        passenv =" >> /etc/xinetd.d/cups-lpd
echo "        server = /usr/lib/cups/daemon/cups-lpd" >> /etc/xinetd.d/cups-lpd
echo "        server_args = -o document-format=application/octet-stream" >> /etc/xinetd.d/cups-lpd
echo "}" >> /etc/xinetd.d/cups-lpd


cat /etc/cups/cupsd.conf.default | grep -v "Listen" > /etc/cups/cupsd.conf
echo "
Port 631
SSLPort 443
AutoPurgeJobs Yes
BrowseWebIF Off
DefaultPaperSize A4
DefaultShared Yes
ErrorPolicy retry-job
ServerTokens ProductOnly
" >> /etc/cups/cupsd.conf

sed -i "s/<\/Location>/  Allow @LOCAL\n<\/Location>/g" /etc/cups/cupsd.conf
sed -i "s/<Location \/admin>/<Location \/admin>\n  Encryption Required\n  AuthType Default\n  Require user @SYSTEM/" /etc/cups/cupsd.conf
sed -i "s/<Location \/admin\/conf>/<Location \/admin\/conf>\n  Encryption Required/g" /etc/cups/cupsd.conf
sed -i "s/<Location \/admin\/log>/<Location \/admin\/log>\n  Encryption Required/g" /etc/cups/cupsd.conf
sed -i "s/^BrowseLocalProtocols.*/BrowseProtocols all/" /etc/cups/cupsd.conf
sed -i "s/^Browsing.*/Browsing On/" /etc/cups/cupsd.conf
sed -i "s/^WebInterface.*/WebInterface Yes/" /etc/cups/cupsd.conf

/etc/pam.d/cups (fix for

echo "auth    required nodelay" > /etc/pam.d/cups
echo "account required" >> /etc/pam.d/cups
chmod 644 /etc/pam.d/cups

Install lighttpd to redirect port 80 to 443

yum -y install lighttpd
sed -i "s/^#  \"mod_redirect\",.*/  \"mod_redirect\",/g" /etc/lighttpd/modules.conf
echo "$SERVER["socket"] == ":80" {" >> /etc/lighttpd/lighttpd.conf
echo "  $HTTP["host"] =~ ".*" {" >> /etc/lighttpd/lighttpd.conf
echo "    url.redirect = (".*" => "https://%0$0")" >> /etc/lighttpd/lighttpd.conf
echo "  }" >> /etc/lighttpd/lighttpd.conf
echo "}" >> /etc/lighttpd/lighttpd.conf


Note: rm -rf /etc/avahi/services && /usr/local/bin/ --cups -d /etc/avahi/services needs to be re-run every time after printers were installed (or significantly changed, e.g. name).

wget -O /usr/share/cups/mime/apple.convs --no-check-certificate
wget -O /usr/local/bin/ --no-check-certificate
wget -O /usr/local/bin/ --no-check-certificate
chmod 755 /usr/local/bin/ /usr/local/bin/
rm -rf /etc/avahi/services && /usr/local/bin/ --cups -d /etc/avahi/services

Enable and start systemd services

systemctl enable org.cups.cupsd.service
systemctl start org.cups.cupsd.service
systemctl disable xinetd
systemctl stop xinetd
systemctl enable avahi-daemon
systemctl start avahi-daemon
systemctl enable lighttpd
systemctl start lighttpd

Optional for my personal setup

Install Canon UFRII Linux drivers

Download Linux_UFRII_PrinterDriver_V320_us_EN.tar.gz and put it to /usr/local/src. Extract and cd to Linux_UFRII_PrinterDriver*

yum -y install beecrypt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.