Support Online
Skip to main content

Installing WordPress with Git and SVN on CentOS 7

There are many ways to install WordPress.
However, using Git or SVN is a professional and safe approach.
With this method, update and rollback operations are done in seconds.

What Will You Learn in This Guide?

  • Installing WordPress with Git or SVN
  • Reverting to the old version after the update
  • Secure directories .git and .svn

Why Use Version Control?

  • Update and rollback are done with a single command
  • Only changed files are downloaded
  • Security risks arising from FTP are eliminated
  • Fast recovery is provided in case of faulty updates

Prerequisites

Before you start, you should have the following ready:

  • A server with CentOS 7 installed
  • Root or sudo access
  • Apache, MySQL and PHP (LAMP) installation

After LAMP installation, you can stop at the PHP step.


Method Choice: SVN or Git?

You can choose one of the following methods according to your need.

  • SVN: Uses WordPress' official repository
  • Git: Offers more advanced version control

Method 1: Installing WordPress with SVN

1. SVN Setup

yum install svn
  • This command installs the SVN tool on the system.

2. Downloading WordPress Files


svn co http://core.svn.wordpress.org/tags/6.4/ /var/www/html/
  • This command downloads the stable version of WordPress.

3. Setting File Permissions


chown -R apache:apache /var/www/html/*
  • This command allows Apache to access files.

4. Securing the .svn Directory


nano /var/www/html/.svn/.htaccess
  • This file blocks external access to SVN information.


order deny,allow
deny from all

  • Restart Apache:

service httpd restart

5. Update or Rollback


cd /var/www/html/
svn sw http://core.svn.wordpress.org/tags/6.4.1/ .
  • This command changes the WordPress version.

Method 2: Installing WordPress with Git

1. Git Setup


yum install git
  • This command installs Git on the system.

2. Cloning WordPress Repository


git clone https://github.com/WordPress/WordPress /var/www/html/
  • This command copies the WordPress repository to the server.

3. Switching to Stable Version


cd /var/www/html/
git checkout 6.4
  • This command pins WordPress to a specific version.

4. File Permissions


chown -R apache:apache /var/www/html/*
  • This command gives file ownership to Apache.

5. Protecting the .git Directory


nano /var/www/html/.git/.htaccess
  • This file prevents Git history from being exported.


order deny,allow
deny from all
  • Restart Apache:


service httpd restart

6. Update or Rollback


git fetch -p
git checkout 6.4.1
  • This command changes the WordPress version.

Database Update

  • Go to the following address from the browser:

http://alanadiniz.com/wp-admin/
  • Click on the Update WordPress Database button.

Frequently Asked Questions (FAQ)

  1. Can themes and plugins be deleted? No, only core files are updated.

  2. What happens if the site breaks after the update? You can revert to the previous version with a single command.

  3. Is it necessary to use FTP? No, with this method FTP is completely disabled.

  4. Is there a need to take a backup? Yes, it should be purchased before every update.


Result

WordPress management is faster and safer with Git and SVN. Updating and reverting with a single command provides a great advantage. This structure is ideal for production environments.

👉** You can try this system immediately on the GenixNode** infrastructure.