The instructions below are a basic skeleton for creating a get started style guide for your wordpress repository. Feel free to use this as a base for your project, adding custom content as you need for your project.
Use the following as a guide on how to get started setting up your new development environment.
Navigate to your your local apache server files, often located at /var/www/html/
on standard linux servers.
cd /your/local/server/directory/
git clone https://github.com/companyX/projectX.git
Use the following MySQL command to create a backup of the database. This command will dump the SQL file into your current directory, so make sure to navigate to where you want the backup file to be located before using the folling command.
mysqldump -u user_name --password='my_password' database_name | mysql -u user_name -p database_name;
After that, use the terminal on your Mac to download the file from the server.
scp user@serverIP:/path/to/remotefile.zip /Local/Target/Destination
After you have a local copy of the database ready to go, it's time to actually import the database. Use the comman below, replacing the bold items with your details.
mysql -u username -p database_name < file.sql
After cloning the database, you will need to update the URL values that are stored in the WP Options table to match your new site's URL.
UPDATE wp_options SET option_value = 'http://yoursite.com' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://yoursite.com' WHERE option_name = 'home';
Copy the WP Config file from the root directory of your WordPress installation.
cp wp-config-sample.php wp-config.php
After creating a copy of this file, you will need to open it so that you can update the following lines in the file:
sudo nano wp-config.php
/** The name of the database for WordPress */ define( 'DB_NAME', 'database_name_here' ); /** MySQL database username */ define( 'DB_USER', 'username_here' ); /** MySQL database password */ define( 'DB_PASSWORD', 'password_here' );
To complete the setup of the WP Config by adding hashes for the salts. Visit the link below to generate unique salts, then copy and paste these values back into the WP Config file, replacing the default ones that are there.
Navigate to the root directory of your WordPress installation and run the following command to create an .htaccess
file.
touch .htaccess
The Uploads folder is not stored in the Git Repo due to the size and types of content, so you will need to synchronize your installation with the files from the server. Synchronize the files in your uploads folder using Rsync for the most efficient method.
rsync -azP --delete username@remote_host_ip:/source/ /destination
rsync -azP --delete username@55.555.5.5:/var/www/html/public/wp-content/uploads/ ~/Documents/GitHub/my-project/wp-content/uploads/
Set all files to 644
sudo find . -type f -exec chmod 644 {} +
Set all folders to 755
sudo find . -type d -exec chmod 755 {} +
Set WP Config to 600
sudo chmod 600 wp-config.php
Ensure that the Apache user, typically www-data
, is part of the owner group for the files. Run the following command from the root directory of your WordPress installation, replacing myuser
with your username.
sudo find . -exec chown myuser:www-data {} +
At this point, you should be able to log into your WordPress installation. Once you are at the WordPress dashboard (yourwebsite.com/admin/) you should be able to navigate to Settings > Permalinks
. Once here, scroll to the bottom of the page and click the blue save button. This will flush your permalinks and ensure that your .htaccess file is up to date to handle any redirects.
At this point you should be all good to start developing!