-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_freebsd.txt
950 lines (775 loc) · 25 KB
/
install_freebsd.txt
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
# -----------------------------------------------------------------------------
#
# Create bootable usb on mac
#
Download image for usb-use.
http://www.webupd8.org/2009/04/4-ways-to-create-bootable-live-usb.html
4. Using Diskutil (Mac OS X only)
Download the desired .img file
(or convert from iso: hdiutil convert -format UDRW -o target.dmg file.iso)
Open a Terminal (under Utilities)
Run diskutil list to get the current list of devices
Insert your flash media
Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2)
Run diskutil unmountDisk /dev/diskN
Execute sudo dd if=/path/to/downloaded.img of=/dev/diskN bs=1m
Run diskutil eject /dev/diskN and remove your flash media when the command completes
# -----------------------------------------------------------------------------
#
# Fresh minimal install and some neccessaties
#
# http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html
#
# setenv BATCH yes
install freebsd, minimal install
portsnap fetch
portsnap extract
portsnap update
cd /usr/ports/sysutils/screen && make install clean
cd /usr/ports/irc/irssi && make install clean
cd /usr/ports/devel/git && make install clean
cd /usr/ports/devel/subversion && make install clean
cd /usr/ports/net/rsync/ && make install clean
add iconv support
add -atime
cd /usr/ports/archivers/zip && make install clean
cd /usr/ports/archivers/unzip && make install clean
cd /usr/ports/ftp/wget && make install clean
cd /usr/ports/ports-mgmt/portupgrade && make install clean
sysinstall & install manualpages Configure - Distributions - System Manual Pages
# have /tmp in memory
# man mdmfs
echo 'tmpfs="YES"' >> /etc/rc.conf
echo 'tmpsize="512M"' >> /etc/rc.conf
echo 'tmpmfs_flags="-S"' >> /etc/rc.conf
# -----------------------------------------------------------------------------
#
# Check filesystems in single user mode
#
# remount root partition in writable mode
mount -u /
# Check and repair filesystems
fsck -y
# -----------------------------------------------------------------------------
#
# VIM
#
cd /usr/ports/editors/vim; make install clean
# csh
setenv EDITOR /usr/local/bin/vim
# vimrc
" Set tabwidth and softtabs
" retab
set expandtab tabstop=2 shiftwidth=2
" syntax highlighting
syntax on
# -----------------------------------------------------------------------------
#
# Sudo and rsync as root to keep permissions
#
cd /usr/ports/security/sudo ; make install clean
# Change that a user can run rsync through sudo without password.
visudo
Cmnd_Alias RSYNC = /usr/local/bin/rsync
mos ALL = NOPASSWD: RSYNC
# To enable rsync using root from backup-machine
# https://mebsd.com/cli-commands/rsync-over-ssh-keeping-file-ownerships-and-permissions.html
#
# Set time and timezone
# http://www.cyberciti.biz/faq/howto-set-date-and-time-timezone-in-freebsd/
#
# Setup ntpd
# http://www.cyberciti.biz/tips/freebsd-timeclock-synchronization-with-ntp-server.html
# http://www.freebsd.org/doc/en/books/handbook/network-ntp.html
cd /usr/ports/net/ntp; make install
cat /etc/ntp.conf
echo 'ntpd_enable="YES"' >> /etc/rc.conf
echo 'ntpdate_enable="YES"' >> /etc/rc.conf
echo 'ntpdate_hosts="se.pool.ntp.org"' >> /etc/rc.conf
service ntpd start
# addons to .cshrc
setenv IRCNAME "Mikael Roos"
setenv LC_CTYPE sv_SE.UTF-8
#set prompt = '%m%~: '
set prompt='%n@%m: '
alias ls ls -F
unset autologout
alias screens screen -U -S basic
alias screenr screen -U -d -r basic
alias la ls -a
alias ll ls -l
alias lla ls -ls
# ssh on additional port
vi /etc/ssh/sshd_config
/etc/rc.d/sshd restart
# -----------------------------------------------------------------------------
#
# Adding disks
#
# http://www.freebsd.org/doc/handbook/disks-adding.html
#
ls /etc/dev
cat /var/log/messages
gpart destroy -F /dev/da1
gpart create -s GPT /dev/da1
gpart add -t freebsd-ufs /dev/da1
newfs -U -L usb /dev/da1p1
vi /etc/fstab
/dev/da1p1 /newdisk ufs rw 2 2
# format disk for both Linux and FreeBSD
mkfs.ext2 -I 128 /dev/sdu1
# -----------------------------------------------------------------------------
#
# Optimize jpeg images.
# jpegtran http://jpegclub.org/
#
cd /usr/ports/graphics/jpeg && make install clean
jpegtran -copy none -optimize -outfile d1.jpg d.jpg
# -----------------------------------------------------------------------------
#
# Optimize png images
# optipng http://optipng.sourceforge.net/
#
cd /usr/ports/graphics/optipng && make install clean
optipng d.png
# -----------------------------------------------------------------------------
#
# Minecraft server
#
# http://minecraft.net/download
fetch https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar
# http://www.minecraftwiki.net/wiki/Tutorials/FreeBSD_startup_script
cd /usr/ports/java/diablo-jdk16/; make config install clean
service minecraft start
# -----------------------------------------------------------------------------
#
# Torrents
#
# http://libtorrent.rakshasa.no/wiki
# http://code.google.com/p/rssdler/
#
cd /usr/ports/net-p2p/rtorrent/ && make install clean
# -----------------------------------------------------------------------------
#
# MiniDLNA
#
cd /usr/ports/net/minidlna && make install clean
vi /usr/local/etc/minidlna.conf
mkdir /var/db/minidlna
echo 'minidlna_enable="YES"' >> /etc/rc.conf
minidlna -h
minidlna -d
minidlna
# -----------------------------------------------------------------------------
#
# Authentication with ssh-keys
#
ssh-keygen -t dsa
cat ~/.ssh/id_dsa.pub | ssh mos@server.com 'cat >>.ssh/authorized_keys'
# -----------------------------------------------------------------------------
#
# Samba
#
# http://www.freebsd.org/doc/handbook/network-samba.html
#
cd /usr/ports/net/samba34 && make install clean
cp /usr/local/share/examples/samba34/smb.conf.default /usr/local/etc/smb.conf
vi /usr/local/etc/smb.conf
echo 'samba_enable="YES"' >> /etc/rc.conf
/usr/local/etc/rc.d/samba start|stop|restart
# -----------------------------------------------------------------------------
#
# NFS
#
# http://www.freebsd.org/doc/handbook/network-nfs.html
#
vi /etc/rc.conf
rpcbind_enable="YES"
nfs_server_enable="YES"
mountd_flags="-r"
# with locking
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
# Add exports
vi /etc/exports
/home2 -mapall=mos -alldirs koket mosmbp mosmbp_air
/share -mapall=nobody koket mosmbp mosmbp_air
/backup -mapall=mos koket mosmbp mosmbp_air
/etc/rc.d/mountd onereload
# start up
rpcbind
nfsd -u -t -n 4
mountd -r
/etc/rc.d/lockd start
/etc/rc.d/statd start
#restart when changed /etc/exports
/etc/rc.d/mountd onereload
#utilities
showmount -a
showmount -e
# mount on mac
nolocks,locallocks,intr,soft,wsize=32768,rsize=32768,noatime
nolocks,locallocks,intr,soft,wsize=32768,rsize=32768,noatime,nosuid
# -----------------------------------------------------------------------------
#
# Security
#
#
#
snort? http://www.snort.org/
rkhunter?
pf deny all
mail to sysadm
nmap check open ports
time faulty ssh-logins, see dada
# -----------------------------------------------------------------------------
#
# Working with Jails
#
# http://www.freebsd.org/doc/handbook/jails.html
#
# create file src.config.jail
# http://forums.freebsd.org/showthread.php?t=12022
# src for jail
WITHOUT_ACCT="YES"
WITHOUT_ACPI="YES"
WITHOUT_AMD="YES"
WITHOUT_APM="YES"
WITHOUT_ASSERT_DEBUG="YES"
WITHOUT_AT="YES"
WITHOUT_ATM="YES"
WITHOUT_AUDIT="YES"
WITHOUT_AUTHPF="YES"
WITHOUT_BIND_DNSSEC="YES"
WITHOUT_BIND_ETC="YES"
WITHOUT_BIND_LIBS_LWRES="YES"
WITHOUT_BIND_MTREE="YES"
WITHOUT_BIND_NAMED="YES"
WITHOUT_BLUETOOTH="YES"
WITHOUT_BOOT="YES"
WITHOUT_BSNMP="YES"
WITHOUT_CALENDAR="YES"
WITHOUT_CDDL="YES"
WITHOUT_CTM="YES"
WITHOUT_CVS="YES"
WITHOUT_DICT="YES"
WITHOUT_EXAMPLES="YES"
WITHOUT_FLOPPY="YES"
WITHOUT_FORTH="YES"
WITHOUT_FREEBSD_UPDATE="YES"
WITHOUT_GAMES="YES"
WITHOUT_GDB="YES"
WITHOUT_GPIB="YES"
WITHOUT_GSSAPI="YES"
WITHOUT_HTML="YES"
WITHOUT_INET6="YES"
WITHOUT_IPFILTER="YES"
WITHOUT_IPFW="YES"
WITHOUT_IPX="YES"
WITHOUT_JAIL="YES"
WITHOUT_KERBEROS="YES"
WITHOUT_KVM="YES"
WITHOUT_LEGACY_CONSOLE="YES"
WITHOUT_LIB32="YES"
WITHOUT_LPR="YES"
WITHOUT_MAIL="YES"
WITHOUT_MAILWRAPPER="YES"
WITHOUT_MAN="YES"
WITHOUT_NCP="YES"
WITHOUT_NDIS="YES"
WITHOUT_NETCAT="YES"
WITHOUT_NIS="YES"
WITHOUT_NLS="YES"
WITHOUT_NLS_CATALOGS="YES"
WITHOUT_NS_CACHING="YES"
WITHOUT_NTP="YES"
WITHOUT_PF="YES"
WITHOUT_PMC="YES"
WITHOUT_PPP="YES"
WITHOUT_PROFILE="YES"
WITHOUT_QUOTAS="YES"
WITHOUT_RCMDS="YES"
WITHOUT_RCS="YES"
WITHOUT_RESCUE="YES"
WITHOUT_ROUTED="YES"
WITHOUT_SENDMAIL="YES"
WITHOUT_SHAREDOCS="YES"
WITHOUT_SYSCONS="YES"
WITHOUT_SYSINSTALL="YES"
WITHOUT_TELNET="YES"
WITHOUT_USB="YES"
WITHOUT_WIRELESS="YES"
WITHOUT_WPA_SUPPLICANT_EAPOL="YES"
WITHOUT_ZFS="YES"
# Retrieve sources for FreeBSD
# http://www.freebsd.org/doc/handbook/jails-build.html
# http://www.freebsd.org/doc/handbook/jails-application.html
# 1. prepare and build src
mkdir /home/j /home/j/mroot
cd /usr/src
make buildworld __MAKE_CONF=/~mos/jail/src.config.jail
make installworld DESTDIR=/home/j/mroot __MAKE_CONF=/~mos/jail/src.config.jail
# 2. prepare jail ports collection
cd /home/j/mroot
mkdir usr/ports
portsnap -p /home/j/mroot/usr/ports fetch extract
# cd /usr/ports/sysutils/cpdup && make install clean
cpdup /usr/src /home/j/mroot/usr/src
# 3. Create a skeleton for the read-write portion of the system:
mkdir /home/j/skel /home/j/skel/home /home/j/skel/usr-X11R6 /home/j/skel/distfiles
mv etc /home/j/skel
mv usr/local /home/j/skel/usr-local
mv tmp /home/j/skel
mv var /home/j/skel
mv root /home/j/skel
# 4. Use mergemaster to install missing configuration files.
# Then get rid of the extra directories that mergemaster creates:
# let mergemaster do the proposed changes...
mergemaster -t /home/j/skel/var/tmp/temproot -D /home/j/skel -i
cd /home/j/skel
rm -R bin boot lib libexec mnt proc rescue sbin sys usr dev
# 5. Now, symlink the read-write file system to the read-only file system.
# Please make sure that the symlinks are created in the correct s/ locations.
# Real directories or the creation of directories in the wrong locations will cause the installation to fail.
cd /home/j/mroot
mkdir s
ln -s s/etc etc
ln -s s/home home
ln -s s/root root
ln -s ../s/usr-local usr/local
ln -s ../s/usr-X11R6 usr/X11R6
ln -s ../../s/distfiles usr/ports/distfiles
ln -s s/tmp tmp
ln -s s/var var
# 6. As a last step, create a generic /home/j/skel/etc/make.conf with its contents as shown below:
cat > /home/j/skel/etc/make.conf
WRKDIRPREFIX?= /s/portbuild
#
# Now we have a jail template. Lets setup our first jail.
#
# 1. Add to /etc/fstab
vi /etc/fstab
/home/j/mroot /home/j/www nullfs ro 0 0
/home/js/www /home/j/www/s nullfs rw 0 0
# 2. Configure in /etc/rc.conf
vi /etc/rc.conf
# Jail general
jail_enable="YES"
jail_set_hostname_allow="NO"
jail_list="ns mail www"
jail_interface="re0"
# Specific jail config
jail_www_hostname="www.example.org"
jail_www_ip="10.0.0.10"
jail_www_rootdir="/usr/home/j/www"
jail_www_devfs_enable="YES"
jail_www_exec_start="/bin/sh /etc/rc"
# 3. Create mountpoint
mkdir /home/j/www
# 4. Install the read-write template into each jail.
mkdir /home/js
cpdup /home/j/skel /home/js/www
# 5. In this phase, the jails are built and prepared to run.
# First, mount the required file systems for each jail, and then start them using the /etc/rc.d/jail script:
mount -a
/etc/rc.d/jail start
/etc/rc.d/jail start www
jls
jexec 3 tcsh
# Shutdown jail?
jexec 3 sh /etc/rc.shutdown
#
# Setup ip aliases for each jail (not needed, created by settings in /etc/rc.conf)
#
#ifconfig re0 10.0.0.1 netmask 255.255.255.255 alias
#vi /etc/rc.conf
# IP aliases
#ifconfig_re0_alias0="10.0.0.1 netmask 255.255.255.255"
#/etc/rc.d/netif restart && /etc/rc.d/routing restart
#
# allow ping in jails, aids when testing
#
vi /etc/sysctl.conf
security.jail.allow_raw_sockets=1
/etc/rc.d/sysctl restart
restart the jails.
#
# Read manpage on jail
#
#Setting up the Host Environment to be jail friendly
# disable ip-services that listen on all network adresses.
sendmail_enable="NO"
#inetd_flags="-wW -a 192.0.2.23"
rpcbind_enable="NO"
# sshd
vi /etc/ssh/sshd_config
# sendmail
vi /etc/mail/sendmail.cf
# named
vi /etc/namedb/named.conf
# more rpc(3), rpcbind(8), nfsd(8), and mountd(8)
#
# nat & port forwarding
#
vi /etc/rc.conf
# routing
#defaultrouter="194.47.136.1"
#gateway_enable="YES"
#natd_enable="YES"
#natd_interface="re0"
#natd_flags="-f /etc/natd.conf"
pf_enable="YES"
pf_rules="/etc/pf.conf"
www4# cat /etc/pf.conf
lan_if="re0"
lan_if_subnet="any"
lan_if_ip="194.47.135.68"
jail_vps_server_ip="10.0.0.0/8"
nat on $lan_if inet proto { tcp, udp, icmp } from $jail_vps_server_ip to $lan_if_subnet -> $lan_if_ip
# add nameserver to each jail
vi /etc/resolv.conf
nameserver 194.47.129.17
nameserver 194.47.129.157
# -----------------------------------------------------------------------------
#
# Nginx
#
# http://wiki.nginx.org/Main
# http://forums.freebsd.org/showthread.php?t=4422
#
cd /usr/ports/www/nginx; make install clean
echo 'nginx_enable="YES"' >> /etc/rc.conf
vi /usr/local/etc/nginx/nginx.conf
/usr/local/etc/rc.d/nginx start
# Add support for PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/site$fastcgi_script_name;
include fastcgi_params;
}
#
# http://wiki.nginx.org/Configuration
# /usr/local/etc/nginx/nginx.conf sample
#
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 10M;
client_body_buffer_size 128k;
server {
listen 80;
server_name anna.megamic.se;
location / {
rewrite ^(.*)$ /anna$1 break;
proxy_pass http://192.168.0.197;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80 default_server;
server_name -;
index index.html;
root /usr/home/mos/htdocs/default;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
}
}
# -----------------------------------------------------------------------------
#
# Apache
#
# Backup /usr/local/etc/apache22, its the config directory.
#
cd /usr/ports/www/apache22 && make install clean
echo 'apache22_enable="YES"' >> /etc/rc.conf
vi /usr/local/etc/apache22/httpd.conf
# Include config file for virtualhosts from httpd.conf
Include etc/apache22/extra/httpd-vhosts.conf
# vi /usr/local/etc/apache22/extra/httpd-vhosts.conf
<URL:http://httpd.apache.org/docs/2.2/vhosts/>
<VirtualHost *:80>
DocumentRoot "/usr/home/mos/htdocs/dbwebb.se"
<Directory "/usr/home/mos/htdocs/dbwebb.se">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ServerName dbwebb.se
ServerAlias www.dbwebb.se
ErrorLog "/usr/home/mos/htdocs/log/dbwebb.se-error_log"
CustomLog "/usr/home/mos/htdocs/log/dbwebb.se-access_log" common
</VirtualHost>
# vi /usr/local/etc/apache22/Includes/httpd-hide-git-svn.conf
<DirectoryMatch \.svn>
Order allow,deny
Deny from all
</DirectoryMatch>
<DirectoryMatch \.git>
Order allow,deny
Deny from all
</DirectoryMatch>
apachectl restart
#
# https
#
# http://onlamp.com/pub/a/onlamp/2008/03/04/step-by-step-configuring-ssl-under-apache.html
#
# Create certs
cd /usr/local/etc/apache22
openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 -nodes -keyout server.key -out server.crt -subj '/DC=se/DC=dbwebb/CN=ldap.dbwebb.se'
chmod 400 server.key
ls -l /usr/local/etc/apache22/server.*
-rw-r--r-- 1 root wheel 993 Jun 10 09:32 /usr/local/etc/apache22/server.crt
-r-------- 1 root wheel 887 Jun 10 09:32 /usr/local/etc/apache22/server.key
vi httpd.conf
# Secure (SSL/TLS) connections
Include etc/apache22/extra/httpd-ssl.conf
apachectl restart
# -----------------------------------------------------------------------------
#
# MySQL
#
# http://dev.mysql.com/doc/refman/5.1/en/mysql-installation-freebsd.html
#
cd /usr/ports/databases/mysql55-server/ && make install clean
#cd /usr/ports/databases/mysql55-client && make install clean
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
cd /usr/local && /usr/local/bin/mysql_install_db
#/usr/local/bin/mysql_install_db --basedir=/usr/local
/usr/local/bin/mysql_secure_installation
echo 'mysql_enable="YES"' >> /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start
#/usr/local/bin/mysqld_safe -user=mysql &
#/usr/local/bin/mysqladmin -u root password newpassword
#mysqladmin shutdown -p
# Configure
# http://dev.mysql.com/doc/refman/5.1/en/post-installation.html
#
#mysql -u root -p
#mysql> GRANT ALL ON *.* TO mos@localhost IDENTIFIED BY 'password';
#mysql> SELECT User, Host, Password FROM mysql.user;
#mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
#mysql> SET PASSWORD FOR 'root'@'kaprifolen.dbwebb.se' = PASSWORD('password');
#mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('password');
#mysql> DELETE FROM mysql.user WHERE User = '';
/usr/local/etc/rc.d/mysql-server restart
#
# MySQL setting up slaveserver
# http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html
#
On master:
Create a /etc/my.cnf & enable binary logging
On slave:
Create a /etc/my.cnf & enable as slave
On master:
Create a user which the slave server can use to connect to the master
mysql> CREATE USER 'repl'@'host.com' IDENTIFIED BY 'secretpass';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'host.com' ;
Create a snapshop of the database and record binary log entry.
http://dev.mysql.com/doc/refman/5.5/en/replication-howto-mysqldump.html
On slave:
mysql> CHANGE MASTER TO MASTER_HOST='host.com', MASTER_PORT=3306, MASTER_USER='repl', MASTER_PASSWORD='secretpass';
Useful:
mysql> SLAVE STOP
mysql> SLAVE START
mysql> SHOW SLAVE STATUS
# -----------------------------------------------------------------------------
#
# PHP
#
# Don't forget to check to build for apache (or fpm).
#
cd /usr/ports/lang/php5 && make config install clean
cat /usr/local/etc/apache22/Includes/enable-php5.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#AddType application/x-httpd-php .php .htm .html
# Create the php.ini-file. Disable magic quotes, enable error reporting.
# Test configuration using Utility/check_php_config.php
cd /usr/ports/www/php5-session && make install clean
cd /usr/ports/databases/php5-mysqli && make install clean
cd /usr/ports/databases/php5-mysql && make install clean
cd /usr/ports/databases/php5-pdo_mysql && make install clean
cd /usr/ports/net/php5-ldap && make install clean
#cd /usr/ports/databases/php5-pdo && make install clean
cd /usr/ports/databases/php5-pdo_sqlite && make install clean
cd /usr/ports/graphics/php5-gd && make install clean
cd /usr/ports/security/php5-hash ; make install clean
cd /usr/ports/security/php5-filter ; make install clean
cd /usr/ports/textproc/php5-xml ; make install clean
cd /usr/ports/converters/php5-mbstring ; make install clean
cd /usr/ports/textproc/php5-ctype ; make install clean
cd /usr/ports/textproc/php5-simplexml ; make install clean
cd /usr/ports/archivers/php5-zlib ; make install clean
cd /usr/ports/devel/php5-json ; make install clean
cd /usr/ports/devel/php5-tokenizer ; make install clean
cd /usr/ports/textproc/php5-dom ; make install clean
cd /usr/ports/ftp/php5-curl ; make install clean
cd /usr/ports/net/php5-sockets ; make install clean
cd /usr/ports/devel/php5-gettext ; make install clean
cd /usr/ports/converters/php5-iconv ; make install clean
cd /usr/ports/devel/pecl-intl/ ; make install clean
cd /usr/ports/graphics/ImageMagick/; make install clean
cd /usr/ports/graphics/php5-exif/; make install clean
apachectl restart
# using php-fpm?
echo 'php_fpm_enable="YES"' >> /etc/rc.conf
# review
vi /usr/local/etc/php-fpm.conf
/usr/local/etc/rc.d/php-fpm start
/usr/local/etc/rc.d/nginx restart
# -----------------------------------------------------------------------------
#
# Drupal
#
#
# download and install drush in $HOME/bin
# http://drupal.org/project/drush
cd ~/bin/git
git clone --branch 7.x-4.x http://git.drupal.org/project/drush.git
cd ~/bin/git; ln -s git/drush/drush
cd /usr/ports/devel/bazaar-ng && make config install clean
#
# or take from ports (did not work for me)
#
cd /usr/ports/www/drush && make config install clean
cd /usr/ports//devel/pear-Console_Table && make config install clean
# install a clean site
drush --drupal-project-rename=dbwebb.se/betapal dl drupal-7.0
# Install drupal using GIT
git clone --branch 7.x http://git.drupal.org/project/drupal.git
cd drupal; git checkout -b 72 7.2
cd sites; cp -r default dbwebb.se.betapal;
cd dbwebb.se.betapal
chmod 777 .; cp default.settings.php settings.php; chmod 666 settings.php
#installl it through web
http://dbwebb.se/betapal/
chmod 644 settings.php; chmod 755 .
# Install modules
git clone --branch 7.x-3.x http://git.drupal.org/project/views.git
git clone --branch 7.x-1.x http://git.drupal.org/project/ctools.git
git clone --branch 7.x-2.x http://git.drupal.org/project/advanced_forum.git
git clone --branch 7.x-2.x http://git.drupal.org/project/ldap.git
git checkout -b 710beta1 7.x-1.0-beta1
#git clone --branch 6.x-3.x http://git.drupal.org/project/wysiwyg.git
git clone http://git.drupal.org/project/wysiwyg.git
#git clone --branch 6.x-1.x http://git.drupal.org/project/imce_wysiwyg.git
git clone http://git.drupal.org/project/imce_wysiwyg.git
git clone --branch 7.x-1.x http://git.drupal.org/project/imce.git
#
Added taxenomy for Material
# -----------------------------------------------------------------------------
#
# OpenLDAP, using TSL
#
# Instructions from Utility/ldap.ldif
#
cd /usr/ports/net/openldap24-server && make install clean
vi /usr/local/etc/openldap/slapd.conf
echo 'slapd_enable="YES"' >> /etc/rc.conf
/usr/local/etc/rc.d/slapd start
sockstat -4 -p 389
# Install client (if not already installed)
cd /usr/ports/net/openldap24-client && make install clean
cd /usr/ports/sysutils/ldapvi && make install clean
# Fill database with some content?
#
# Check if there is a namingContext
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
#
# Add entries from file
ldapadd -x -D "cn=Manager,dc=dbwebb,dc=se" -W -f ldap.ldif
#
# Edit entries
ldapvi -D "cn=Manager,dc=dbwebb,dc=se" --discover
# Check that it works from PHP?
#
# http://dbwebb.se/utility/ldap.php
#
# Enable TLS and SSL (ldaps://)
#
vi /usr/local/etc/openldap/slapd.conf
Add ---
#security ssf=128
security tls=0
TLSCertificateFile /usr/local/etc/openldap/ssl/server.crt
TLSCertificateKeyFile /usr/local/etc/openldap/ssl/server.key
TLSCACertificateFile /usr/local/etc/openldap/ssl/server.crt
--- Stop add
# Copy the certificate from apache httpds or create a new ones
# and store them in /usr/local/etc/openldap/ssl
#
openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 -nodes -keyout server.key -out server.crt -subj '/DC=se/DC=dbwebb/CN=ldap.dbwebb.se'
chown ldap server.key
chmod 400 server.key
ls -l /usr/local/etc/openldap/ssl
total 4
-rw-r--r-- 1 root wheel 993 Oct 29 04:53 server.crt
-r-------- 1 ldap wheel 887 Oct 29 04:53 server.key
# Start slapd to listen on both ldap:// and ldaps://
echo 'slapd_flags=\'-h "ldaps:/// ldap:///"\'' >> /etc/rc.conf
/usr/local/etc/rc.d/slapd restart
sockstat -4 -p "389,636"
# Client issue to NOT validate self-signed server cert
vi /usr/local/etc/openldap/ldap.conf
Add ---
TLS_REQCERT allow
--- stop add
# Test that TLS works using -Z
ldapsearch -Z -x -b '' -s base '(objectclass=*)' namingContexts
ldapvi -Z --tls allow -D "cn=Manager,dc=dbwebb,dc=se" --discover
# http://dbwebb.se/utility/ldap.php
# ---------------------------------------------------------------------------------
#
# Enable login through LDAP
#
# http://www.freebsd.org/doc/en/articles/ldap-auth/article.html
#
gm# cd security/pam_ldap/ ; make install clean ;
Create the config-file /usr/local/etc/ldap.conf, may be same settings as openldap/ldap.conf
Edit /etc/pam.d/sshd, add line:
auth sufficient /usr/local/lib/pam_ldap.se no_warn
account required /usr/local/lib/pam_ldap.so no_warn ignore_authinfo_unavail ignore_unknown_user
#
# Not needed to set up nss to allow getting guid&gid from LDAP
#
gm# cd /usr/ports/net/nss_ldap/; make install clean;
The nss_ldap module expects to find its configuration files at the
following paths:
LDAP configuration: /usr/local/etc/nss_ldap.conf
LDAP secret (optional): /usr/local/etc/nss_ldap.secret
# ---------------------------------------------------------------------------------
#
# Install qwebirc
#
# http://qwebirc.org/faq
# http://www.cripperz.sg/index.php/forum/21-Ubuntu-Linux/265--KB--QwebIRC-Installation-quick-guide.html
#
cd /usr/ports/irc/qwebirc/ ; make install clean
cd /usr/ports/dns/py-twistedNames && make install clean
cd /usr/ports/mail/py-twistedMail && make install clean
cd /usr/ports/net-im/py-twistedWords && make install clean
# optional, recommended
cd /usr/ports/devel/mercurial && make install clean
cd /usr/ports/java/linux-sun-jre16 && make install TZUPDATE=off clean
// Install using hd
$ cd ~/
$ hg clone bitbucket.org/slug/qwebirc
$ cd qwebirc
$ hg up -C stable
$ hg pull
$ hg up
# Configure & start
config.py
python compile.py