-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserlamp-makefile
More file actions
223 lines (201 loc) · 7.35 KB
/
userlamp-makefile
File metadata and controls
223 lines (201 loc) · 7.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#
# A Makefile for building user mode apache, mysql, php
#
###########################################################
# Configuration variables
# Source dirs
SRCAPACHEDIR ?= $(wildcard httpd-2.*) #httpd-2.2.17
SRCMYSQLDIR ?= $(wildcard mysql-5.*) #mysql-5.5.11
SRCPHPDIR ?= $(wildcard php-5.*) #php-5.3.6
# Servers directory holds: apache, mysql, php, mysql-database, etc
SERVERS ?= $(HOME)/servers
# Dest dirs for the servers
DSTAPACHEDIR ?= apache
DSTMYSQLDIR ?= mysql
DSTPHPDIR ?= php
# Data dir: the mysql database will be placed here under servers:
DATADIR ?= dbdata
###########################################################
# make sure only one src dir found:
ifneq ($(words $(SRCAPACHEDIR)),1)
$(error Not one dir found: $(SRCAPACHEDIR))
endif
ifneq ($(words $(SRCMYSQLDIR)),1)
$(error Not one dir found: $(SRCMYSQLDIR))
endif
ifneq ($(words $(SRCPHPDIR)),1)
$(error Not one dir found: $(SRCPHPDIR))
endif
# targets:
.PHONY: all bld1 bld2 bld3 help1 help2 help3 help helpadmin helpprereq
.PHONY: prereq bld1run bld2run bld3run
help:
all: bld1 bld2 bld3 help
#note: -so for loading php, -rewrite for clean drupal url
bld1: prereq bld1run help1
bld1run:
cd $(SRCAPACHEDIR) && \
pwd && \
./configure --prefix=$(SERVERS)/$(DSTAPACHEDIR) \
--enable-so --enable-rewrite && \
make && \
make install
# MySql:
bld2: prereq bld2run help2
bld2run:
cd $(SRCMYSQLDIR) && \
pwd && \
cmake . -DCMAKE_INSTALL_PREFIX=$(SERVERS)/$(DSTMYSQLDIR) && \
make && \
make install
#without -DCMAKE_INSTALL_PREFIX=, use make install DESTDIR=
# Php:
# Drupal7 needs -gd, -pdo-mysql. gd needs libpng-devel
bld3: prereq bld3run help3
bld3run:
cd $(SRCPHPDIR) && \
pwd && \
./configure --prefix=$(SERVERS)/$(DSTPHPDIR) \
--with-mysql=$(SERVERS)/$(DSTMYSQLDIR) \
--with-pdo-mysql=$(SERVERS)/$(DSTMYSQLDIR) \
--with-apxs2=$(SERVERS)/$(DSTAPACHEDIR)/bin/apxs \
--with-gd && \
make && \
make install
prereq:
@if [ -d $(SERVERS) ]; then exit 0; \
else echo SERVERS empty; exit 1; fi
@if [ -d $(SRCAPACHEDIR) ]; then exit 0; \
else echo SRCAPACHEDIR empty; exit 1; fi
@if [ -d $(SRCMYSQLDIR) ]; then exit 0; \
else echo SRCMYSQLDIR empty; exit 1; fi
@if [ -d $(SRCPHPDIR) ]; then exit 0; \
else echo SRCPHPDIR empty; exit 1; fi
@if [ ! -f $(HOME)/.my.cnf ]; then \
echo Setup ~/.my.cnf before setup mysql database.; \
echo See help2.; exit 1; fi
help1:
@echo
@echo '--------------------------------------------'
@echo 'Apache configuration:'
@echo ' Edit conf/httpd.conf to set port, php ext etc. '
@echo ' For example, set "Listen 8080", '
@echo ' and "DirectoryIndex index.html index.php".'
@echo '--------------------------------------------'
@echo
help2:
@echo
@echo '--------------------------------------------'
@echo 'MySql configuration: Put this to ~/.my.cnf'
@echo ' [mysqld]'
@echo ' user='$(USER)
@echo ' datadir='$(SERVERS)/$(DATADIR)
@echo ' socket='$(SERVERS)/$(DATADIR)/the.sock
@echo ' port=<port>'
@echo ' '
@echo ' [mysqld_safe]'
@echo ' log-error='$(SERVERS)/$(DATADIR)/the.log
@echo ' pid-file='$(SERVERS)/$(DATADIR)/the.pid
@echo ' '
@echo ' [mysqladmin]'
@echo ' socket='$(SERVERS)/$(DATADIR)/the.sock
@echo ' port=<port>'
@echo ' '
@echo ' [mysql]'
@echo ' socket='$(SERVERS)/$(DATADIR)/the.sock
@echo ' port=<port>'
@echo ' '
@echo ' [mysql.server]'
@echo ' user='$(USER)
@echo ' basedir='$(SERVERS)/$(DATADIR)/lib
@echo ' '
@echo 'Initialize data dir:'
@echo ' cd '$(SERVERS)/$(DSTMYSQLDIR)'; scripts/mysql_install_db'
@echo ' '
@echo 'Start up and setup: Go to '$(SERVERS)/$(DSTMYSQLDIR),' then'
@echo ' ./bin/mysqld_safe &'
@echo ' ./bin/mysqladmin -u root password <password>'
@echo ' ./bin/mysqladmin -u root -h <host> password <password>'
@echo ' '
@echo 'To clean up: make clean && rm CmakeCache.txt'
@echo '--------------------------------------------'
@echo ' '
#Alternatively you can run: ./bin/mysql_secure_installation
help3:
@echo
@echo '--------------------------------------------'
@echo 'Php configuration: Add this to httpd.conf'
@echo ' <FilesMatch \.php$$>'
@echo ' SetHandler application/x-httpd-php'
@echo ' </FilesMatch>'
@echo ' '
@echo 'Copy php.ini-dev... to '$(SERVERS)/$(DSTPHPDIR)'/lib/php.ini.'
@echo ' Set mysql.default_socket properly in the php.ini, '
@echo ' to the same socket path as in ~/.my.cnf. '
@echo ' Restart apache server to take effect of the change.'
@echo 'Use "phpinfo();" in a php web page to see the value used.'
@echo '--------------------------------------------'
@echo ' '
help:
@echo
@echo '--------------------------------------------'
@echo 'Folder Structure:'
@echo ' /home/user/source -- where this makefile is.'
@echo ' /home/user/source/httpd-x.y.z -- the apache source.'
@echo ' /home/user/source/mysql-x.y.z -- the mysql source.'
@echo ' /home/user/source/php-x.y.z -- the php source.'
@echo ' /home/user/servers -- where to install servers.'
@echo ' /home/user/servers/apache -- the apache server.'
@echo ' /home/user/servers/mysql -- the mysql server.'
@echo ' /home/user/servers/php -- the php server.'
@echo ' /home/user/servers/dbdata -- the mysql database dir.'
@echo
@echo 'Build and Help Commands:'
@echo ' make -f <thismakefile> all -- build and install all three.'
@echo ' make -f <thismakefile> bld1 -- build and install apache.'
@echo ' make -f <thismakefile> bld2 -- build and install mysql.'
@echo ' make -f <thismakefile> bld3 -- build and install php.'
@echo ' make -f <thismakefile> help1 -- see apache help.'
@echo ' make -f <thismakefile> help2 -- see mysql help.'
@echo ' make -f <thismakefile> help3 -- see php help.'
@echo ' make -f <thismakefile> helpadmin -- Drupal phpMyAdmin help.'
@echo ' make -f <thismakefile> helpprereq -- required packages.'
@echo
@echo 'Build and Run Steps:'
@echo ' [0] See helpprereq for required packages. Install them first.'
@echo ' [1] Create ~/.my.cnf. See help2.'
@echo ' [2] Build and install apache, mysql, php.'
@echo ' [3] Configure and start apache. See help1 and help3.'
@echo ' [4] Configure and start mysql. See help2.'
@echo ' Be sure the <port>s in ~/.my.cnf are correct.'
@echo ' [5] See helpadmin for phpMyAdmin and Drupal instructions.'
@echo
@echo 'Must build and install in this order: apache, mysql, php.'
@echo ' Then install phpMyAdmin. Install drupal7 at last.'
@echo '--------------------------------------------'
@echo
helpprereq:
@echo
@echo '--------------------------------------------'
@echo 'Required packages for apache: gcc, gcc-c++. '
@echo 'Required packages for mysql: cmake, ncurses-devel. '
@echo 'Required package for php: libxml2-devel. '
@echo 'Reruired package for Drupal 7: libpng-devel. '
@echo ' Drupal needs php with-gd, -gd needs libpng-devel. '
@echo '--------------------------------------------'
@echo
helpadmin:
@echo
@echo '--------------------------------------------'
@echo Put phpMyAdmin under a web folder.
@echo Configure with localhost and cookie authentication.
@echo
@echo To install Drupal 7, use 127.0.0.1:\<port\> instead of localhost.
@echo Then edit settings.php, remove host and port, add unix_socket.
@echo
@echo For Drupal clean url, set apache configure file to:
@echo <Directory "/path/to/your/drupal">
@echo AllowOverride All
@echo </Directory>
@echo '--------------------------------------------'
@echo