WordPress Makefile

From Proxmox VE
Jump to: navigation, search

File Contents

The standard Wordpress Makefile for generating the OpenVZ Template using DAB v1.1-14 is as follows:

BASEDIR:=$(shell dab basedir)

all: info/init_ok
	dab bootstrap
	dab task mysql --password random
	dab install apache2-mpm-prefork
	dab task php
	sed -e 's/^\s*display_errors\s*=\s*On/display_errors = Off/' -i ${BASEDIR}/etc/php5/apache2/php.ini
	dab install php5-mysql
	tar xzf latest.tar.gz -C ${BASEDIR}/var/www/
	# change owner, in order to enable web based updates
	dab exec chown -R www-data.www-data /var/www/wordpress
	install -m 0644 wordpress.conf ${BASEDIR}/etc/apache2/sites-available/wordpress
	install -m 0755 wordpress_setup ${BASEDIR}/etc/init.d/
	dab exec insserv wordpress_setup
	dab exec a2enmod rewrite
	dab exec a2dissite default
	dab exec a2ensite wordpress
	dab finalize

info/init_ok: dab.conf
	dab init
	touch $@

.PHONY: clean
clean:
	dab clean
	rm -f *~

.PHONY: dist-clean
dist-clean:
	dab dist-clean
	rm -f *~

Kindly note that all indents above are tabs (\t).

Alternate Startup script file

The insserv method placing symlinks (of files especially in /etc/init.d) in the various /etc/rc*.d folders is used in the above Makefile.

Whilst this is convenient to manage by creation and deletion of various symlinks while retaining the original scripts for future use or for archival, there is another solution - file-rc - that uses a single file to store the startup scripts viz., /etc/runlevel.conf and backed up in /etc/runlevel.fallback.

The above Makefile can be edited to replace the highlighted lines with the following:

	install -m 0755 wordpress_setup ${BASEDIR}/etc/init.d/
	dab exec update-rc.d wordpress_setup start 21 2 .
	dab install file-rc

The downside here is the need to specify the startup priority and runlevel number (21 and 2 respectively in the above code fragment) manually.

Old Lenny Method

The method used earlier for the old Lenny based Templates was to merely copy over the first boot setup file with the priority number in the name like:

	install -m 0755 wordpress_setup ${BASEDIR}/etc/rc2.d/S21wordpress_setup

This method is now broken due to some lib conflicts that have not been resolved. Information on this method is placed here for archival purposes only.

The runlevel.conf file

The contents of a runlevel.conf file is as below:

# This file was automatically generated by /usr/share/file-rc/rclink2file.sh.
# You can use your favourite editor or update-rc.d(8) to modify it.
# Read runlevel.conf(5) man page for more information about this file.
#
# Format:
# <sort> <off-> <on-levels>     <command>
02	-	S		/etc/init.d/hostname.sh
02	-	S		/etc/init.d/mountkernfs.sh
04	-	S		/etc/init.d/mountdevsubfs.sh
05	-	1		/etc/init.d/single
05	-	S		/etc/init.d/bootlogd
08	-	S		/etc/init.d/hwclockfirst.sh
09	0,1,6	-		/etc/init.d/apache2
10	-	2,3,4,5		/etc/init.d/rsyslog
10	-	S		/etc/init.d/checkroot.sh
11	-	S		/etc/init.d/hwclock.sh
11	0,1,6	-		/etc/init.d/atd
12	-	S		/etc/init.d/mtab.sh
16	-	2,3,4,5		/etc/init.d/ssh
18	-	S		/etc/init.d/ifupdown-clean
19	-	2,3,4,5		/etc/init.d/mysql
20	-	0,6		/etc/init.d/sendsigs
20	0,1,6	2,3,4,5		/etc/init.d/postfix
21	0,1,6	-		/etc/init.d/mysql
25	0,6	-		/etc/init.d/hwclock.sh
30	-	0,6		/etc/init.d/rsyslog
30	-	0,6		/etc/init.d/urandom
30	-	1		/etc/init.d/killprocs
30	-	S		/etc/init.d/checkfs.sh
30	-	S		/etc/init.d/procps
31	-	0,6		/etc/init.d/umountnfs.sh
32	-	0,6		/etc/init.d/portmap
35	-	0,6		/etc/init.d/networking
35	-	S		/etc/init.d/mountall.sh
36	-	0,6		/etc/init.d/ifupdown
36	-	S		/etc/init.d/mountall-bootclean.sh
37	-	S		/etc/init.d/mountoverflowtmp
39	-	S		/etc/init.d/ifupdown
40	-	0,6		/etc/init.d/umountfs
40	-	S		/etc/init.d/networking
43	-	2,3,4,5,S		/etc/init.d/portmap
45	-	S		/etc/init.d/mountnfs.sh
46	-	S		/etc/init.d/mountnfs-bootclean.sh
55	-	S		/etc/init.d/bootmisc.sh
55	-	S		/etc/init.d/urandom
60	-	0,6		/etc/init.d/umountroot
70	-	1,2,3,4,5		/etc/init.d/bootlogs
70	-	S		/etc/init.d/x11-common
81	1	-		/etc/init.d/portmap
89	-	2,3,4,5		/etc/init.d/atd
89	-	2,3,4,5		/etc/init.d/cron
90	-	0		/etc/init.d/halt
90	-	6		/etc/init.d/reboot
90	1	-		/etc/init.d/rsyslog
91	-	2,3,4,5		/etc/init.d/apache2
99	-	2,3,4,5		/etc/init.d/rc.local
99	-	2,3,4,5		/etc/init.d/rmnologin
99	-	2,3,4,5		/etc/init.d/stop-bootlogd
99	-	S		/etc/init.d/stop-bootlogd-single
# THE LAST LINE IS NEVER READ!

The /etc/rc?.d/* links will be converted into one single configuration file /etc/runlevel.conf instead, which is easier to administrate than symlinks, and is also more flexible. The package will automatically convert your existing symlinks into the file method on installation, and convert the file back into symlinks on removal. Both mechanisms are compatible through /etc/init.d/rc, /etc/init.d/rcS, /usr/sbin/update-rc.d, and /usr/sbin/invoke-rc.d scripts.