Setting Up a Ubuntu Perforce Server
This is a step-by-step guide to installing and configuring Perforce on a Ubuntu server. It assumes that you have already created a Basic Ubuntu Server. There are several sections below:
- Download Perforce
- Configure Perforce
- Run Perforce Server For the First Time
- Setup Perforce As Bootup Service
- Use Lynx to download the P4D software.
- Enter Y to allow the cookie from Perforce.com.
- Press the Down Arrow until the Downloads link is selected. Then press Enter.
- Press the Down Arrow until the Linux Kernel 2.6 for x86 link is selected. Then press Enter.
- Press the Down Arrow until the Download link is selected. Then press Enter.
- Press D to start the download.
- Press the Down Arrow to highlight the ''Save to disk'' link. Then press Enter.
- Use the default filename of `p4d`.
- Press q, then press Enter to exit Lynx.
- Use Lynx to download the P4 software by retrace the steps above expect selecting to download `P4` instead of `P4D`.
Configure PerforceThis information is a reprise of the [http://www.perforce.com/perforce/doc.072/manuals/p4sag/index.html Perforce Administration Guide] along with some additional information.
- Download the `daemon` utility. This utility allows `p4d` to be run by the `perforce` user instead of `root`.
sudo apt-get daemon
- Connect to the directory where the `p4` and `p4d` files where downloaded (probably the home directory).
- Make the `p4` and `p4d` files executable.
chmod +x p4 p4d
- Copy the Perforce executables to `/usr/local/bin` which is already in the system PATH environment variable.
sudo mv p4 /usr/local/bin sudo mv p4d /usr/local/bin
- Create a group for Perforce files.
sudo addgroup p4admin
- Create a user for Perforce administrative work.
sudo adduser perforce
- Use `visudo` to give the perforce user account the ability to use `sudo`. Add the following line at the end o f the file.
perforce ALL = ALL
- Log off your default user account.
- Log in using the `perforce` account.
- Create a directory to hold the repository.
sudo mkdir /perforce_depot sudo chown perforce:p4admin /perforce_depot
- Create a directory to hold Perforce log files.
sudo mkdir /var/log/perforce sudo chown perforce:p4admin /var/log/perforce
- Add the following lines to the end of /etc/profile. These settings will be used by client programs run on the Linux server - not by the Perforce server.
# Perforce Settings export P4JOURNAL=/var/log/perforce/journal export P4LOG=/var/log/perforce/p4err export P4PORT=localhost:1666 export P4ROOT=/perforce_depot export P4USER=perforce
- Load the Perforce settings.
- Create a Perforce group to limit resource usage using `sudo p4 group developers` to set the following values. See http://kb.perforce.com/P4dServerReference/Performance/ViewsProtect..Maxlocktime for more information.
Group: developers MaxResults: 50000 MaxScanRows: 250000 MaxLocktime: 30000 Timeout: 4320 Subgroups: Users: developer
Setup Perforce As Bootup Service
- Connect to the initialization control directory.
- Create the Perforce control script using `sudo vi perforce`.
#!/bin/sh -e export P4JOURNAL=/var/log/perforce/journal export P4LOG=/var/log/perforce/p4err export P4ROOT=/perforce_depot export P4PORT=1666 PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" . /lib/lsb/init-functions p4start="p4d -d" p4stop="p4 admin stop" p4user=perforce case "$1" in start) log_action_begin_msg "Starting Perforce Server" daemon -u $p4user $p4start; ;; stop) log_action_begin_msg "Stopping Perforce Server" daemon -u $p4user $p4stop; ;; restart) stop start ;; *) echo "Usage: /etc/init.d/perforce (start|stop|restart) exit 1 ;; esac exit 0
- Integrate the Perforce control script into the boot process.
sudo update-rc.d perforce defaults
- Goto your home directory then use the control script to start the Perforce server.
cd ~ sudo /etc/init.d/perforce start
- Use the control script to restart the Perforce server.
sudo /etc/init.d/perforce restart
Run Perforce Server For the First TimeBefore Perforce can be used by a team there are two housekeeping task that need to be done - creating the journal and closing a security hole.
- Set the Perforce environment variables.
- Start the perforce server. The command line is short because all of the settings are provided by the variables exported by /etc/profile.
sudo p4d –d
- Create the journal.
sudo p4d –jc
- By default, all users connected to Perforce are administrators. However, that level of security is not acceptable for a normal development environment. Run the `protect` option to switch out of the default security mode. For now, accept the default protections by typing `:wq` and pressing Enter.
sudo p4 protect
- Stop the Perforce server.
sudo p4 admin stop
Resources* Perforce's public depot
* http://kb.perforce.com/AdminTasks/InstallAndUpgrade/RunningAPerf..InetdOnUnix How to start `p4d` via `inetd` instead of a startup script.