Linux Tutorial | Matt Cooper - Open Source Support
Linux Tutorial | Matt Cooper - Open Source Support
Wordpress Troubleshooting

WordPress – home page only issue

Either you have just installed WordPress or have moved your website to a new server/domain and you are now only able to see the homepage of you site. When clicking on a link on the nav you get a 404 error.

Don’t worry the fix will be simple. From previous experience it will be one of the following:

1. .htaccess – this hasn’t copied over to your new directory. Check for the .htaccess file just inside your parent directory and check its contents. If missing recover from your previous directory.

2. Permissions – when setting up a new site the director permissions are normally set quite low. Change them to 755 (WordPress standard)

chown -R 755 webdir

3. Ownership – again check the ownership of the directory and update recursively if necessary:

ls -lh webdir

chown -R user.group webdir

4. Hardcoded urls – depending on how your website has been coded it may contain hardcoded urls in the database. Run a find/replace on your sql dump before importing into its new home. Notepad++ is the lazy-mans way or else run from commandline.

July 12, 2013by Matt Cooper
FacebookTwitterPinterestGoogle +Stumbleupon
Backup Tutorial, CPanel Tutorial

CPanel – filesystem backup

Following on from our previous post (https://www.linuxtutorial.co.uk/cpanel-mysql-backup-script/) there is another script for the full backup of CPanel web directories.

The original post is taken from http://r00t3r.com/cpanel-full-backup-cron-script-for-automated-backups/ which contains a link to download the PHP files.

The main file to worry about is the config.php which contains a cpanel section:

// CPANEL ACCOUNT TO BACKUP
define( 'CPANEL_SERVER_ADDRESS',		'abc.def.ghj.mnp' );	// IP address or domain name for the server with the cPanel account
define( 'CPANEL_PORT_NUM',				'2083' );	// The port number for the cPanel. If you have problems, try 2082
define( 'CPANEL_ADMIN_USERNAME',		'admin-username' );	// the admin username for your cPanel account
define( 'CPANEL_ADMIN_PASSWORD',		'veryStrongPassword' ); // the admin password for your cPanel account

and the FTP server section:

define( 'FTP_SERVER_ADDRESS',			'npq.rst.uvw.xyz' );     // IP address or URL of the FTP server
define( 'FTP_SERVER_PORT',			'21' );			 // FTP(S) Port. Default is 21.
define( 'FTP_USERNAME',				'ftp-username' );	 // FTP Username
define( 'FTP_PASSWORD',				'ftp-password' );	 // FTP Password
define( 'FTP_PATH_TO_COPY',			'/ftp/path/to/copy/' );	 // FTP Path (where do you want to copy the files?)

Simply enter in your CPanel and FTP server account details to this PHP script.

Once in place setup the cron job to run on a regular basis e.g.

1 1 * * * php -q /home/user/path_to_phpscript/cpanelbackup.php
July 10, 2013by Matt Cooper
FacebookTwitterPinterestGoogle +Stumbleupon
Backup Tutorial, CPanel Tutorial

CPanel – mysql backup script (PHP)

Simple PHP MySQL backup script for CPanel. Create a php file and insert the following code:


<?
$datestamp = date("Y-m-d");// Current date to append to filename of backup file in format of YYYY-MM-DD

/* CONFIGURE THE FOLLOWING THREE VARIABLES TO MATCH YOUR SETUP */
$dbuser = "username";// Database username
$dbpwd = "password";// Database password
$dbname = "database";// Database name. Use --all-databases if you have more than one
$filename= "backup-$datestamp.sql.gz";// The name (and optionally path) of the dump file

$command = "mysqldump -u $dbuser --password=$dbpwd $dbname | gzip > $filename";
$result = passthru($command);

/* CONFIGURE THE FOLLOWING FOUR VARIABLES TO MATCH YOUR FTP SETUP */
$ftp_server = "hostname";// Shouldn't have any trailing slashes and shouldn't be prefixed with ftp://
$ftp_port = "21";// FTP port - blank defaults to port 21
$ftp_username = "username";// FTP account username
$ftp_password = "password";// FTP account password - blank for anonymous

// set up basic connection
$ftp_conn = ftp_connect($ftp_server);

// Turn PASV mode on or off
ftp_pasv($ftp_conn, false);

// login with username and password
$login_result = ftp_login($ftp_conn, $ftp_username, $ftp_password);

// check connection
if ((!$ftp_conn) || (!$login_result))
{
echo "FTP connection has failed.";
echo "Attempted to connect to $ftp_server for user $ftp_username";
exit;
}
else
{
echo "Connected to $ftp_server, for user $ftp_username";
}

// upload the file
$upload = ftp_put($ftp_conn, $filename, $filename, FTP_BINARY);

// check upload status
if (!$upload)
{
echo "FTP upload has failed.";
}
else
{
echo "Uploaded $filename to $ftp_server.";
}

// close the FTP stream
ftp_close($ftp_conn);

unlink($filename);   //delete the backup file from the server
?>

Now add a cron job to trigger the backup script when required:


1 1 * * * php -q /home/user/path_to_phpscript/sqlbackup.php

The above code will trigger the backup to run at 1:01 a every day of the year.

Use a cron calculator to sepcify the time and days you would like your cron to run: http://www.csgnetwork.com/crongen.html

July 10, 2013by Matt Cooper
FacebookTwitterPinterestGoogle +Stumbleupon
ISPConfig3 Tutorial, Nginx Troubleshooting, Wordpress Troubleshooting

ISPConfig3 + Nginx – WordPress issue

Following on from the ISPConfig3 running on nginx tutorial I then came to installing a WordPress site within ISPConfig. Piece of cake, right?

So I went about the usual process of setting up a new site and database within the ISPConfig interface. Then I grabbed the latest WordPress (wget http://wordpress.org/latest.tar.gz), placing it in the correct location inside the “web” directory for this particular site. Ownership/permissions were then updated – everything as per normal in this environment.

I then enter the URL into my browser and low and behold the WordPress home page appeared. Great! Until I browsed to any other page within the test site:

ERROR 404 – Not Found!

From a considerable bit of Googling I found the following piece of code needs to be appended to your nginx Directives (ISPConfig > Website > Options)

location / {
try_files $uri $uri/ /index.php?$args;
}

Restarted nginx and we’re back in business. All pages loading as they should.

 

July 3, 2013by Matt Cooper
FacebookTwitterPinterestGoogle +Stumbleupon
Page 35 of 35« First...102030«3132333435

About me

Hi, I'm Matt Cooper. I started this blog to pretty much act as a brain dump area for things I learn from day to day. You can contact me at: matt@linuxtutorial.co.uk

Recent Comments

  • Andrew on Export list of Amazon EC2 Instances to CSV
  • Matt Cooper on Proxmox – add a second hard drive to node for Backups
  • karis on Proxmox – add a second hard drive to node for Backups
  • Matt Cooper on Remote MySQL Database – Slow Connection
  • Matt Cooper on Bash script to send public IP address to Email

Categories

  • AdvancedTomato
  • Amazon AWS
  • Amazon Linux
  • Amazon S3
  • Apache
  • Apache Kafka
  • Backup Tutorial
  • Bash Scripting
  • Centos Tutorial
  • CloudFlare
  • Command line Tutorial
  • CPanel Troubleshooting
  • CPanel Tutorial
  • Debian Troubleshooting
  • Debian Tutorial
  • DKIM
  • Docker
  • EC2
  • ESXi
  • Faildows
  • Google Adwords
  • Google Analytics
  • Google Chromebook
  • Google Mail
  • graylog
  • IAM
  • imapsync
  • iRedmail Tutorial
  • ISPConfig3 Tutorial
  • Java
  • ldap
  • letsencrypt
  • MyDNS
  • MySQL Troubleshooting
  • MySQL Tutorial
  • Nest Install
  • Netbeans
  • Nginx
  • Nginx Troubleshooting
  • openssl
  • PCI Compliance
  • Percona
  • PHP
  • Plex Media Server Tutorial
  • Postfix
  • Proxmox Tutorial
  • Pure FTPd
  • Resourcespace Tutorial
  • Route 53
  • Rsync Tutorial
  • Security
  • Smoothwall Troubleshooting
  • Smoothwall Tutorial
  • SSH
  • tcpdump
  • Thunderbird
  • Tomcat Troubleshooting
  • Ubuntu Tutorial
  • Uncategorized
  • Unison
  • vmware
  • vzdump
  • WHM
  • Wireshark
  • Wordpress Troubleshooting
  • WordPress Tutorial

“See, you not only have to be a good coder to create a system like Linux, you have to be a sneaky bastard too." Linus Torvalds

© 2017 copyright www.linuxtutorial.co.uk // All rights reserved