Perforce server setup on Linux box
Preparation
First, determine your Linux kernel version. I'm using kernel 2.6 x64, with Fedora 9. As root, download matching perforce binaries
p4 (client) and p4d (server). It's good idea to download man pages
p4.1 and p4d.1 as well.
Give execute permission and move them to appropriate location, such as
/usr/local/bin.
# chmod a+x p4 p4d
# mv -t /usr/local/bin p4 p4d
Copy man pages to appropriate location.
# mv -t /usr/local/share/man/man1 p4.1 p4d.1
Running Perforce daemon
You probably don't want to run
p4d (the daemon) with root privilege. Let's create dedicated user account and group.
# groupadd p4admin
# useradd -g p4admin perforce
Next, create root repository where the perforce server stores all data. I chose
/usr/local/p4root
# mkdir /usr/local/p4root
# chown perforce:p4admin /usr/local/p4root
Perforce writes journal and error log, which I would like to put in
/var/log/. Note that we are doing this because we are going to run the daemon with non-root privilege.
# touch /var/log/p4err /var/log/p4journal
# chown perforce:p4admin /var/log/p4err /var/log/p4journal
Now, as 'perforce', not 'root', run the following command. '-p 1666' specifies the listening port.
$ p4d -r /usr/local/p4root -J /var/log/p4journal -L /var/log/p4err -p 1666 &
Or as root, execute
# runuser -c '/usr/local/bin/p4d -r /usr/local/p4root -J /var/log/p4journal -L /var/log/p4err -p 1666' - perforce &
Check if the perforce server is running and listening to the port. Change your firewall setting as needed.
To run
p4d automatically every time the system reboots, you need to hook into the system init sequence. There are many ways of doing this, but the simplest hack is to add the above command line to
/etc/rc.d/rc.local file. Or you can write a full init script for perforce daemon. For example,
here is my p4d init script.
To use this, copy it to
/etc/rc.d/init.d, modify for your configuration, give execute permission, and run the following command.
# chkconfig --add p4d
Next time you reboot, the
p4d daemon will be brought up.
Creating a depot
'depot' is the perforce equivalent of 'repository' of other SCM programs.
-- Main.jisooy - 15 Jun 2008
- p4d: copy it to /etc/rc.d/init.d