Author Archives: saisai

Setup Subversion to use HTTP Protocol on Ubuntu Server 11.04 with post-commit Hook

Setup Subversion to use HTTP Protocol on Ubuntu Server 11.04 with post-commit Hook
By Shay Anderson on March 2012
In this example I am setting up subversion to be accessed via HTTP protocol, as in 'http://[server]/svn/example_project', and I commit to the subversion repository I am having the post-commit hook update a local website project. This example assumes you already have subversion installed on your server.

First, Install 'libapache2-svn': >> apt-get install libapache2-svn
Restart Apache: >> service apache2 restart
Edit file '/etc/apache2/mods-available/dav_svn.conf' and add:
DAV svn
SVNParentPath /home/svn
SVNListParentPath On
AuthType Basic
AuthName "My Subversion Server"
AuthUserFile /etc/subversion/passwd

Require valid-user


This will allow anonymous read-only checkouts, and authorized users are allowed to read/edit (write permissions)
To disallow anonymous checkouts, replace this:
Require valid-user
With this:Require valid-user
Restart Apache: >> service apache2 restart
Create password file: >> htpasswd -c /etc/subversion/passwd [new user name]Then add any additional user to file with: >> htpasswd /etc/subversion/passwd [additional user name]You can check if user exists in '/etc/subversion/passwd' file with: >> cat /etc/subversion/passwd
Now you can checkout you project with: >> svn checkout http://[your server location/svn/example_project /var/www/example_projectTest making changes and commit the changes: >> cd /var/www/example_project
>> svn commit -m 'test commit'
If you attempt to commit and receive an error like:Commit
Commit failed (details follow):
Can't open file '/home/svn/example_project/db/txn-current-lock': Permission deniedYou need to change the permissions for the subversion repository: >> chown -R www-data:www-data /home/svn/example_projectOr you can change the permissions for all subversion repositories with: >> chown -R www-data:www-data /home/svn
If you are using a hook, for example a hooks/post-commit like:#!/bin/sh
/usr/bin/svn update /var/www/example_project
You will want to set correct permissions for '/var/www/example_project': >> chown -R www-data:www-data /var/www/example_project-- OR --
If you are using a hook, for example a hooks/post-commit like:#!/bin/sh
sudo -u [your user] /usr/bin/svn update /var/www/example_project
You will need to add this to the end of the '/etc/sudoers' file:www-data ALL=(ALL) NOPASSWD: /usr/bin/svn
NOTE: if you are not allowing anonymous read-only checkouts (explained above), then you would need to add this to your post-commit:/usr/bin/svn update /var/www/example_project --username [your subversion user name] --password [your subversion password]-- OR -- sudo -u [your user] /usr/bin/svn update /var/www/example_project --username [your subversion user name] --password [your subversion password]

Setup New CentOS 6.2 Web Server

Setup New CentOS 6.2 Web Server
By Shay Anderson on November 2012
In the following article I explain how to setup a basic Web server on a new install of CentOS 6 (in my case CentOS 6.2).

Install Nano
First, I use the text editor nano, so I needed to install this editor first: >> yum install nano
Setup Apache Configuration File
Next, I want to disable Indexes for directory options, this means that someone can’t view the ‘Index Of’ or listing of files in my Web directories. To do this edit the ‘/etc/httpd/conf/httpd.conf’ and add ‘-Indexes’ to this line:
[...]
Options FollowSymLinks -Indexes
[...]
Also, add ‘-Indexes’ to this line:
[...]
Options FollowSymLinks -Indexes
[...]
Next, in the same file add ‘index.php’ as a default directory index file: DirectoryIndex index.php index.htmlSave the file and restart the Web server: >> service httpd restart
Setup Root Password
I like to use simple passwords for the root user, if you want to use simple passwords you must edit the ‘/etc/pam.d/system-auth’ file, change these 2 lines: password requisite pam_cracklib.so try_first_pass retry=3 type=
password sufficient pam_unix.so try_first_pass use_authtok nullok sha512 shadowTo this (comment out the first line and remove ‘use_authtok’ from the second line): #password requisite pam_cracklib.so try_first_pass retry=3 type=
password sufficient pam_unix.so try_first_pass nullok sha512 shadowSave the file and now change the root password: >> passwd root
Enter new UNIX password:
Setup Timezone
I am setting up my server on the east coast, so I need to change my server timezone to east coast (or the New York timezone). To check your server date/time and timezone use this command: >> date
Fri Nov 5 22:02:30 CST 2012Now, to change the timezone first create a backup of ‘/etc/localtime’: >> cp -v /etc/localtime /etc/localtime.BAKNext, remove the ‘/etc/localtime’ file: >> rm -fv /etc/localtime Finally, create a link to the correct timezone (in my case New York): >> ln -s /usr/share/zoneinfo/America/New_York /etc/localtimeYou can check all available timezones in the ‘/usr/share/zoneinfo/America’ directory.

Install FTP Server (vsftpd)
Next, install a FTP server (in this example I install vsftpd): >> yum install vsftpdAdd a user for FTP access (-d switch sets the default directory for user, in this case I am setting it to the ‘/var/www/html’ directory for Web server purposes): >> useradd -d /var/www/html ftpuserAdd a password for the user: >> passwd ftpuserNow, edit the ‘/etc/passwd’ file so we can block the ‘ftpuser’ user from SSH access, make sure the ‘ftpuser’ line looks something like: ftpuser:x:500:500::/home/ftpuser:/sbin/nologinNext, edit the vsftpd configuration file ‘/etc/vsftpd/vsftpd.conf’ file and turn anonymous OFF: # Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=NOIn the same file make sure these settings look like: chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
Then create ‘chroot_list’ file: >> touch /etc/vsftpd/chroot_listSave the file and restart vsftpd: >> service vsftpd restartNow, you should be able to access your server via FTP using the ‘ftpuser’ account.

Finally, setup vsftpd to auto startup with the server is booted: >> chkconfig vsftpd onYou can check if vsftpd is set on with: >> chkconfig –list
Install PHP 5.3
Next, install PHP 5.3: >> yum install php.x86_64Check the install with: >> php -v
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend TechnologiesRestart Apache: >> service httpd restart

http://www.shayanderson.com/linux/setup-new-centos-62-web-server.htm

How to Setup Ubuntu 12.10 Server with LAMP and SSH Access

How to Setup Ubuntu 12.10 Server with LAMP and SSH Access
By Shay Anderson on December 2012
In this article I include all the necessary steps for getting a Web (Apache) Server up and running on Ubuntu 12.10 with SSH access and Samba file server.

Installation
Install Ubuntu Server 12.10, during the install select to install OpenSSH, LAMP and Samba.

Add Root User
After installation I want to enable the root user by adding a password at command line: >> sudo passwd rootAfter the password is setup for root I can switch to the root user: >> su root
Setup Aliases
Next, I want to setup aliases that I use, so for that I edit the ‘/home/[user]/.bashrc’ file and add these lines by the other aliases: [...]
alias z=’ls -l’
alias zz=’ls -la’
alias a2r=’service apache2 restart’
alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’
[...]The same steps can be used to setup the root user alias by editing the file ‘/root/.bashrc’ (must have root priviledges).

Setup Static IP
The next thing I want to do is setup a static IP address so I can access the server via SSH. So I edit the ‘/etc/network/interfaces’ file so it looks something like: auto eth0
iface eth0 inet static
address 192.168.1.110
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.1.1Save the file and restart networking with: >> service networking restartYou should be able to see your IP address with the command: >> ifconfigThis should display your new static IP address.

Now you should be able to connect to the server via the new static IP address and SSH.

Setup File Server
The next thing I want to do is enable file sharing on the new server. To do this I simply need to edit the Samba configuration file ‘/etc/samba/smb.conf’, first set the workgroup: workgroup = [your workgroup name]Then at the bottom of the file add your share directories, for example: [webserver]
comment = Linux Web Server
path = /var/www
browsable = yes
guest ok = yes
read only = no
create mask = 0755
force user = [user for share]

[svn]
comment = Subversion Repos
path = /home/svn
browsable = yes
guest ok = yes
read only = no
create mask 0755
force user = [user for share]Then restart the Samba service: >> service smbd restartYou should now be able to access your shared directories.

Downgrading PHP 5.4 to PHP 5.3
When I installed Ubuntu 12.10 I noticed that the it installed a version of PHP I didn’t want to use: >> php -v
PHP 5.4.6-1ubuntu1I want to use PHP 5.3, so first I need to check the packages that were included in the PHP 5.4 install: >> dpkg –list | grep php
ii libapache2-mod-php5 5.4.6-1ubuntu1 amd64 server-side, HTML-embedded scripting language (Apache 2 module)
ii php5-cli 5.4.6-1ubuntu1 amd64 command-line interpreter for the php5 scripting language
ii php5-common 5.4.6-1ubuntu1 amd64 Common files for packages built from the php5 source
ii php5-mysql 5.4.6-1ubuntu1 amd64 MySQL module for php5So I want to remove the PHP 5.4 packages: >> apt-get remove libapache2-mod-php5 php5-cli php5-common php5-mysqlThen run update: >> apt-get updateNext, create the file ‘/etc/apt/sources.list.d/precise.list’ and add these lines: # required for PHP 5.3
deb http://bg.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise main restricted

deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates main restricted

deb http://bg.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise universe
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates universe

deb http://bg.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse

deb-src http://archive.canonical.com/ubuntu natty partner

deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main

deb http://bg.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partnerSave the file and re-run update: >> apt-get updateNow you can re-install PHP (5.3) using the precise list: >> apt-get -t precise install libapache2-mod-php5 php5-cli php5-common php5-mysqlVerify PHP version: >> php -v
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)PHP has been successfully downgraded to PHP 5.3. I also use the PHP GD Library and cURL PHP Library, so I also installed those: >> apt-get -t precise install php5-curl php5-gdThat will install both libraries.

Configure Apache Web Server
Next, edit the ‘/etc/apache2/apache2.conf’ file and at the bottom of the file add these lines: [...]
ServerName localhost

# turn off directory indexing

Options -Indexes

Include /var/www/www.httpd.confThen create the file ‘/var/www/www.httpd.conf’ file and you can now add virtual hosts like:
ServerName 0.0.0.0 # replace 0.0.0.0 with your server IP address
DocumentRoot /var/www
CustomLog ${APACHE_LOG_DIR}/access.log combined


ServerName myexample.com
ServerAlias www.myexample.com
DocumentRoot /var/www/myexample.com
ErrorLog /var/log/www.myexample.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Then enable Apache mods: >> a2enmod rewrite
>> a2enmod headersBecause I am using this server as a development server I want to display all PHP errors, warnings and notices – to do this I edit the ‘/etc/php5/apache2/php.ini’ file, and set these values: [...]
error_reporting = E_ALL | E_STRICT
[...]
display_errors = On
[...]
display_startup_errors = On
[...]
error_prepend_string = “


[...]
error_append_string = “


[...]Restart Apache:>> service apache2 restart
Setup MySQL Server
Next, I setup the MySQL server so that I can connect locally using the root user. First, edit the ‘/etc/mysql/my.cnf’ and comment out the bind-address so it looks like: [...]
;bind-address = 127.0.0.1
[...]Then we need to allow access for root, log into the MySQL server: >> mysql -h localhost -u root -pThen using MySQL command line run these commands: mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES(‘%’,’root’,PASSWORD(‘your-root-password’));
mysql> FLUSH PRIVILEGES;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quitNow restart MySQL: >> service mysql restartNow MySQL should be ready to use.

Install Subversion
I use subversion, so to install I use: >> apt-get install subversionYou can find how to Setup Subversion Server on Ubuntu 12.10 here.

Install Misc Packages
I also use the ‘tree -A’ command, so I install the tree package: >> apt-get install treeAlso, I install zip: >> apt-get install zip

http://www.shayanderson.com/linux/how-to-setup-ubuntu-1210-server-with-lamp-and-ssh-access.htm

Install and Setup Subversion Server on Ubuntu 12.10 Server with Multiple Repositories

Install and Setup Subversion Server on Ubuntu 12.10 Server with Multiple Repositories
By Shay Anderson on January 2013
In this article I explain how to install and setup subversion on a Ubuntu server (in this example Ubuntu 12.10 server).

Install Subversion
First, install subversion: >> apt-get install subversionOr, you can check what version of subversion is already installed: >> svn –version
svn, version 1.7.5 (r1336830)
compiled Sep 28 2012, 11:22:04
[...]
Setup Subversion Repositories
Next, I want to setup a location for the subversion repositories: >> mkdir /home/reposNow this is where I can create subversion repositories. I am going to create two example repositories to use for this example: >> svnadmin create /home/repos/project1>> svnadmin create /home/repos/project2Next, I want to setup the correct permissions for the repositories: >> chmod -R g+rws /home/reposNow I can setup a group that will use the subversion repositories: >> sudo groupadd svnNext I can change the group ownership of the repository directories: >> chgrp -R svn /home/reposI need to add my user to the ‘svn’ group, to do this I do (replace [username] with the correct user): >> usermod -a -G svn [username]Then I can check if my user has been added to the group: >> groups
adm cdrom sudo dip plugdev sambashare lpadmin svn
Test New Repositories
The next step is to test the new repositories that have be setup: >> mkdir /home/tmp
>> svn checkout file:///home/repos/project1 /home/tmp
Checked out revision 0.Now I create a test file that can be used to commit to the new repository: >> echo ‘this is test’ > /home/tmp/test.txtAdd the file: >> svn add /home/tmp/test.txt
A tmp/test.txtTest commit the file: >> svn commit -m “initial test commit” /home/tmp
Adding tmp/test.txt
Transmitting file data .
Committed revision 1.Success!

Remote Access Subversion Repositories Using SVN Protocol
This section is the most important section where we setup remote accessing to our new subversion repositories using the svn protocol. We can to allow access to all repositories, so instead of configuring each separate repository for access, we can setup a central configuration so all repositories can be accessed. First, let’s setup a user/password file for access our repositories, create a new file ‘passwd-users’ using your text editor: >> nano /home/repos/passwd-usersAnd a users and passwords: [users]
shay = mypass
user2 = secret
mike = goodpasswordSave file and exit. Add correct permissions to protect users/passwords file: >> sudo chmod 600 /home/repos/passwd-users
Now we need to edit the ‘conf/svnserve.conf’ files for each repository: >> nano /home/repos/project1/conf/svnserve.confNow replace all the content in the file with: [general]
anon-access = none
auth-access = write
password-db = /home/repos/passwd-users
realm = Development TeamThis needs to be done for all repositories that you want to allow remote access for.

Now I can start the subversion server ‘svnserve’: >> sudo svnserve -d -r /home/reposThis will allow access to our repositories located in ‘/home/repos’.

Test the svn protocol checkout: >> mkdir /home/tmp2
>> svn checkout svn://[server IP address]/project1 –username [username]This should checkout the ‘project1′ repository files.

Note: While the above ‘svnserve.conf’ setup will work, it might be easier for you to use a global/common ‘svnserve.conf’ file. You can accomplish a global/comman ‘svnserve.conf’ file by using symlinks. First, create a copy of the ‘svnserve.conf’ file you created for the ‘project1′ repository in ‘/home/repos’: >> cp -v /home/repos/project1/conf/svnserve.conf /home/reposThen move both ‘svnserve.conf’ files for repositories ‘project1′ and ‘project2′ to backup files: >> mv -v /home/repos/project1/conf/svnserve.conf /home/repos/project1/conf/svnserve.conf.BAK>> mv -v /home/repos/project2/conf/svnserve.conf /home/repos/project2/conf/svnserve.conf.BAKThen create symlinks to global/common ‘svnserve.conf’ file for both repositories: >> ln -s /home/repos/svnserve.conf /home/repos/project1/conf/svnserve.conf>> ln -s /home/repos/svnserve.conf /home/repos/project2/conf/svnserve.confFinally, restart the subversion server: >> sudo killall svnserve
>> sudo svnserve -d -r /home/reposNow you have an easy-to-use ‘svnserve.conf’ file.

Setup Script for Subversion Server Auto-Startup
Another important part of setting up a subversion server is forcing the subversion server service to auto start when the server boots, as well as giving us a convenient way to start/stop/restart the subversion server service. To do this create the file: >> nano /etc/init.d/svnserveThen add a simple script like: #! /bin/sh
#
# svnserve {start|stop|restart|force-reload} script
#
# @author Shay Anderson 01.13
#

# set repositories path
REPOS=/home/repos

# set svnserve daemon
DAEMON=/usr/bin/svnserve

# configuration settings
PATH=/sbin:/bin:/usr/sbin:/usr/bin
SVN=svnserve
SVN_DESC=”Subversion Server Daemon ($SVN)”

case “$1″ in
start)
echo “Starting $SVN_DESC…”
start-stop-daemon –start –quiet –oknodo –exec $DAEMON — -d -r $REPOS >/dev/null 2>&1
echo
;;
stop)
echo “Stopping $SVN_DESC…”
start-stop-daemon –stop –quiet –oknodo –exec $DAEMON
echo
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo “Usage: $0 {start|stop|restart|force-reload}”
echo
exit 1
;;
esac

exit 0Make the script executable: >> chmod +x /etc/init.d/svnserveRegister the script with the Ubuntu OS: >> update-rc.d svnserve defaults
update-rc.d: warning: /etc/init.d/svnserve missing LSB information
update-rc.d: see
Adding system startup for /etc/init.d/svnserve …
/etc/rc0.d/K20svnserve -> ../init.d/svnserve
/etc/rc1.d/K20svnserve -> ../init.d/svnserve
/etc/rc6.d/K20svnserve -> ../init.d/svnserve
/etc/rc2.d/S20svnserve -> ../init.d/svnserve
/etc/rc3.d/S20svnserve -> ../init.d/svnserve
/etc/rc4.d/S20svnserve -> ../init.d/svnserve
/etc/rc5.d/S20svnserve -> ../init.d/svnserveNow the subversion server daemon should start when the server boots.

Update Project Directory When Project is Committed to Subversion Repository
Often times it is help to update a project directory after a commit has been done to the project repository. For example, say we makes changes to a file in our ‘project1′ repository and after we commit the changes we want the Website directory for the project to up auto updated. For this example, create a Website directory for the ‘project1′ project: >> mkdir /var/www/project1Now checkout the ‘project1′ repository: >> svn checkout svn://[server IP address]/project1 –username [user] /var/www/project1Now we need to setup a post-commit script that will update this project Website directory when someone commits to the ‘project1′ repository. Copy the post-commit hook template to a post-commit script file: >> cp -v /home/repos/project1/hooks/post-commit.tmpl /home/repos/project1/hooks/post-commitMake the new file executable: >> chmod +x /home/repos/project1/hooks/post-commitEdit the post-commit script: >> nano /home/repos/project1/hooks/post-commitAnd add a couple lines that will update the Website directory: #!/bin/sh
sudo -u [shell username] /usr/bin/svn update /var/www/project1 –username [svn repo username] –password [svn repo user password]Save and close the file. Now when a commit is executed on the ‘project1′ repository, the post-commit script will auto update the ‘/var/www/project1′ directory. If any errors occur when committing make sure that all permissions and credentials are correct.

http://www.shayanderson.com/linux/install-and-setup-subversion-server-on-ubuntu-1210-server-with-multiple-repositories.htm

Set and Change the Default Editor in Linux

Set and Change the Default Editor in Linux
By Shay Anderson on January 2013
Changing and setting the default editor in Linux is easy, here is an example using the command line: >> export EDITOR=nanoOr if you wanted to use for one time, like when using crontab: >> EDITOR=nano crontab -e

http://www.shayanderson.com/linux/set-and-change-the-default-editor-in-linux.htm

Tutorial: Install and Configure Subversion 1.7 on CentOS 5

Tutorial: Install and Configure Subversion 1.7 on CentOS 5
By Shay Anderson on May 2013
In this simple tutorial I am going to walk you through installing Subversion 1.7 (or Subversion 1.6 if you don’t need Subversion 1.7) on CentOS 5 (in this tutorial I am installing Subversion on Cent OS 5.9).

Subversion Installation
First, if you don’t require Subversion 1.7, installing Subversion using command line is very easy: >> yum install subversionAt the time of writing this the default yum install of Subversion installs the Subversion 1.6 version. You can check what version yum will install by using command line: >> yum list available | grep subversion
If you want Subversion 1.7 installed (which is much better in my opinion than 1.6) you first have to download Subversion 1.7 from here: http://opensource.wandisco.com/centos/5/devel/RPMS/x86_64/.

If you already have Subversion installed and want to switch to Subversion 1.7 you can remove Subversion with: >> yum remove subversion*
Here is an example of how to download and install Subversion 1.7: >> wget http://opensource.wandisco.com/centos/5/devel/RPMS/x86_64/subversion-1.7.9-1.x86_64.rpm /home/tmpNow, install the package: >> rpm -ivh /home/tmp/subversion-1.7.9-1.x86_64.rpmFinally, check version and you should see something like this: >> svn –version
svn, version 1.7.9 (r1462340)
compiled Mar 29 2013, 19:59:15
Creating a Subversion Repository
Now we can setup a Subversion repository. First create a directory where the Subversion subversion repository(ies) can reside: >> mkdir /var/svnNow create Subversion repository: >> svnadmin create /var/svn/myrepoThen set correct user/group: >> chown -R myuser:myuser /var/svn/myrepoThen set correct permissions: >> chmod -R 755 /var/svn/myrepoNow your Subversion repository should look something like: myrepo
|– README.txt
|– conf
| |– authz
| |– passwd
| `– svnserve.conf
|– db
| |– current
| |– format
| |– fs-type
| |– fsfs.conf
| |– min-unpacked-rev
| |– rep-cache.db
| |– revprops
| | `– 0
| | `– 0
| |– revs
| | `– 0
| | `– 0
| |– transactions
| |– txn-current
| |– txn-current-lock
| |– txn-protorevs
| |– uuid
| `– write-lock
|– format
|– hooks
| |– post-commit.tmpl
| |– post-lock.tmpl
| |– post-revprop-change.tmpl
| |– post-unlock.tmpl
| |– pre-commit.tmpl
| |– pre-lock.tmpl
| |– pre-revprop-change.tmpl
| |– pre-unlock.tmpl
| `– start-commit.tmpl
`– locks
|– db-logs.lock
`– db.lock
Subversion Server Configuration
Next, we need to make a global ‘svnserve.conf’ file for all repositories (this is the easiest way to do it in my opinion, but you can have separate ‘svnserve.conf’ files for each Subversion repository).

Copy ‘svnserve.conf’ from repository to /var/svn >> cp -v /var/svn/myrepo/conf/svnserve.conf /var/svnNow edit ‘/var/svn/svnserve.conf’: >> nano /var/svn/svnserve.confSo it looks something like: [general]
anon-access = none
auth-access = write
password-db = /var/svn/passwd
realm = My Subversion ServerNext, create backup copy of ‘svnserve.conf’: >> mv -v /var/svn/myrepo/conf/svnserve.conf /var/svn/myrepo/conf/svnserve.conf.BAKCreate symlink to svnserve.conf: >> ln -s /var/svn/svnserve.conf /var/svn/myrepo/conf/svnserve.conf
Create Subversion Users
Next, we need to create the users/passwords files: >> nano /var/svn/passwdAdd users/passwords so your file looks something like:[users]
shay = mypass
mike = hispassSave file and close, set permissions:>> chmod 644 /var/svn/passwd
Start the Subversion Server
We can now start the svnserve server: >> svnserve -dr /var/svn(-d option: daemon mode, -r option: root of directory to serve)

You can now test accessing the Subversion repository by checking out repository: >> svn checkout file:///var/svn/myrepo /home/myproj
Setting up Post Commit Hook
Finally, here is how to setup a Subversion hook that will auto update a project directory post commit: first, copy post-commit hook template file: >> cd /var/svn/myrepo/hooks
>> cp -v ./post-commit.tmpl ./post-commitMake hook executable: >> chmod +x ./post-commitThen edit the ‘./post-commit’ hook file so it looks something like:#!/bin/sh

sudo -u [shell user] /usr/bin/svn update /home/myproj –username [svn user] –password [svn password]Now you can test a commit and see if the update happens through the hook.

If you get an error like:”sudo: sorry, you must have a tty to run sudo”You can fix that error by editing ‘/etc/sudoers’ file and disabling (comment out) tty:#Defaults requiretty
Stopping the Subversion Server
First, find process ID of “svnserve -dr /var/svn”:>> ps -aux | grep svnWhich should give you results like:root 9292 0.0 0.0 80284 1152 ? Ss 11:18 0:00 svnserve -dr /var/svnNow you can kill process using: >> kill -9 9292The daemon ‘svnserve’ is no longer running.

Setting up Subversion Server to run on Server Boot
We can now setup a script that will auto start the Subversion server (svnserve) when the machine boots. First, create the ‘svnserve’ file in ‘/etc/init.d’: #!/bin/sh
# chkconfig: 2345 95 20
# description: svnserve {start|status|stop}
# processname: /etc/init.d/svnserve

# @file /etc/init.d/svnserve
# @author Shay Anderson 05.13

# repositories path
REPOS=/var/svn

# svnserve command
SVN=svnserve
SVN_OPT=”-dr”
SVN_DESC=”Subversion Server Daemon ($SVN)”

start() {
echo “Starting $SVN_DESC…”
$SVN $SVN_OPT $REPOS
echo “Done.”
echo
}

status() {
echo “$SVN_DESC status:”
ps -aux | grep “$SVN $SVN_OPT $REPOS”
echo
}

stop() {
echo “Stopping $SVN_DESC…”
pkill -f $SVN
echo
}

case “$1″ in
start)
start
;;
status)
status
;;
stop)
stop
;;
*)
echo “Usage: $0 {start|status|stop}”
echo
;;
esac

exit 1Make sure the file is executable: >> chmod +x /etc/init.d/svnserveNow you should be able to start, stop or restart the svnserve process by using this script: >> /etc/init.d/svnserve stop
>> /etc/init.d/svnserve start
>> /etc/init.d/svnserve status
Next, to set this script to run ‘start’ on server boot register the service: >> chkconfig –add /etc/init.d/svnserveNow, you can check if it is registered: >> chkconfig –list | grep svnserve
svnserve 0:off 1:off 2:on 3:on 4:on 5:on 6:offIf you ever want to remove the registered service use: >> chkconfig –del /etc/init.d/svnserve

The install and configuration of Subversion 1.7 on CentOS 5.9 is complete.

http://www.shayanderson.com/linux/tutorial-install-and-configure-subversion-1-7-on-centos-5.htm

CentOS 5 or CentOS 6 Upgrade PHP to PHP 5.4 or PHP 5.5

CentOS 5 or CentOS 6 Upgrade PHP to PHP 5.4 or PHP 5.5
By Shay Anderson on August 2013
This article describes how to upgrade to PHP 5.4 or PHP 5.5 on a CentOS 5 or CentOS 6 server.

First, detect if any PHP packages are installed:
# yum list installed | grep phpIf packages are installed remove them, for example:
# yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
Add PHP 5.4 packages to yum using this command for CentOS 5.x
# rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpmOr, for CentOS 6.x:
# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
Now, you can check if the new PHP (5.4: php54w or 5.5: php55w) packages are available:
# yum list available | grep phpOr, version specific search:
# yum list available | grep php54
Next, install the new PHP 5.4 or 5.5 packages, for example when installing PHP 5.4 packages I used:
# yum install php54w.x86_64 php54w-cli.x86_64 php54w-common.x86_64 php54w-gd.x86_64 php54w-ldap.x86_64 php54w-mbstring.x86_64 php54w-mcrypt.x86_64 php54w-mysql.x86_64 php54w-pdo.x86_64
PHP should now be upgraded to the new version, you can verify with the command:
# php -v
PHP 5.4.17 (cli) (built: Jul 23 2013 00:02:04)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Finally, restart the Web server: # service httpd restart

Set SSH Login Message or User Notice

Set SSH Login Message or User Notice
By Shay Anderson on July 2013
You can set a custom login message/banner or user notice/warning on your server by following these instructions.

First, create the login message (banner): # nano /etc/ssh/bannerThen add the message you want to be displayed on SSH login, for example: ***************************************************************************
NOTICE TO USERS

This computer system is the private property and is NOT for public use.
It is for authorized use only. Log off immediately if you are not an
allowed authorized user of this system.
****************************************************************************Next, set the banner path in the /etc/ssh/sshd_config file: Banner /etc/ssh/bannerFinally, restart the SSH service, on my Ubuntu server I do with command: # service ssh restartNext time a login is completed the banner should be displayed