• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for January 2017

Fix WordPress Permissions

January 25, 2017

Here’s the recommended permissions for WordPress.

Permissions

Directories = 755
Files = 644

Install From Scratch

If you’re starting from scratch, follow the instructions below.

Assuming you’re logged in as normal user. Use sudo to execute commands as superuser.

cd /var/www/
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo chown -R www-data:www-data wordpress

cd /var/www/ sudo wget https://wordpress.org/latest.tar.gz sudo tar -xzvf latest.tar.gz sudo chown -R www-data:www-data wordpress

Fix Current

If your permissions are wrong, then perform the following.

sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \

sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \ sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \

Filed Under: WP Tagged With: chown, permissions

Nextcloud

January 24, 2017

Nextcloud is the next generation open source file storage and file synching platform. It’s similar to Dropbox, Google Drive and Microsoft OneDrive. The main difference is that you run the software on your own server. This is a perfect solution if you’re worried about mass surveillance. It’s safe enough to place on the cloud. Better yet, you can run it on your local network at home. It behaves somewhat similar to a NAS (Network Attached Storage) but with a better web interface, and a few more apps.

In addition, you can install the client software on your Desktop (PC, MAC and Linux) or to any mobile device (iOS, Android and Windows). The clients automatically sync data to the server software that’s installed on a Linux server. Files can also be accessed using WebDav as well. It has an online office, a video chat feature and Outlook email integration, but I’m not really interested with those additional features. I use it primarily for storage and file synching only. It works great by the way.

Give Nextcloud a try.

Filed Under: Cloud, Linux Tagged With: nextcloud

Packages Have Been Kept Back

January 24, 2017

What do you do when you get this message “the following packages are being kept back.” And what exactly does it mean?

When performing updates in Ubuntu, you typically run these two commands from the command line.

$ sudo apt-get update
$ sudo apt-get upgrade

$ sudo apt-get update $ sudo apt-get upgrade

If there are updates, it will sometimes ask you to type “Y” or “yes.”

Sometimes you get this message.

$ sudo apt-get upgrade                                                                                                
Reading package lists... Done                                                                                                          
Building dependency tree                                                                                                               
Reading state information... Done                                                                                                      
The following packages have been kept back:                                                                                            
  linux-headers-server linux-image-server linux-server                                                                                 
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

$ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done The following packages have been kept back: linux-headers-server linux-image-server linux-server 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

This means that these packages were not installed or kept back because they have additional packages that are introduced, and the upgrades depend on them.

You can fix this by running:

$ sudo apt-get dist-upgrade

$ sudo apt-get dist-upgrade

Or you can individually install the packages you want instead of globally.

$ sudo apt-get install package-name

$ sudo apt-get install package-name

Filed Under: Linux Tagged With: updates

How to Live Stream Using FFmpeg

January 9, 2017

FFmpeg is a complete cross-platform command-line tool for recording, converting and streaming audio and video files. FFmpeg is widely used for converting files from one format to another. It also used by some to record videos from the screen or camera. It’s also used by others to live stream a recorded file or camera to a RTMP streaming server such as Wowza, YouTube or Facebook Live.

How to record your camera to a video file.

$ ffmpeg -f avfoundation -i "1:0" -t 00:00:15 -s 1280x720 -r 30 -b:v 3500k -b:a 128k out.mpg
$ ffmpeg -f avfoundation -i "2:0" -t 00:00:15 -s 1280x720 -r 30 -b:v 3500k -b:a 128k out.mpg

$ ffmpeg -f avfoundation -i "1:0" -t 00:00:15 -s 1280x720 -r 30 -b:v 3500k -b:a 128k out.mpg $ ffmpeg -f avfoundation -i "2:0" -t 00:00:15 -s 1280x720 -r 30 -b:v 3500k -b:a 128k out.mpg

-i = “video:audio”
-t = duration
-r = fps
-b:v = video bitrate
-b:a = audio bitrate

How to stream a video file to a RTMP server

$ ffmpeg -re -i input.mp4 -vcodec libx264 -preset veryfast -maxrate 1500k 
  -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream

$ ffmpeg -re -i input.mp4 -vcodec libx264 -preset veryfast -maxrate 1500k -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream

How to live stream your screen monitor to a RTMP server

$ ffmpeg -f avfoundation -i "2:0" -vcodec libx264 -preset ultrafast 
  -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k 
  -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream

$ ffmpeg -f avfoundation -i "2:0" -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream

How to stream your camera to a RTMP server

$ ffmpeg -f avfoundation -i "1:0" -vcodec libx264 -preset ultrafast 
  -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k 
  -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream

$ ffmpeg -f avfoundation -i "1:0" -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream

To learn details of FFmpeg options, read the documentation.

If you need assistance with the install, please see my previous post.

Filed Under: Linux Tagged With: ffmpeg, rtmp, streaming

Homebrew

January 8, 2017

Homebrew is the missing package manager for the Mac OS. It’s missing because the MacOS doesn’t have one. Homebrew is the MacOS equivalent of apt-get or aptitude in Ubuntu Linux. With Homebrew installed on your MacOS, you can easily install and uninstall programs, packages, and utilities via the command line. For example, to install the wget, apache, git and ffmpeg, you can run the following commands from the Terminal.

$ brew install wget
$ brew install apache
$ brew install git
$ brew install ffmpeg

$ brew install wget $ brew install apache $ brew install git $ brew install ffmpeg

If you don’t have Homebrew installed, run the following command from the Terminal.

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If for some unexplained reason you’re having problems with Homebrew, you can uninstall and reinstall it.

$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Filed Under: Linux, Mac Tagged With: brew, homebrew, package manager

The In_Category Function

January 8, 2017

If you’re looking for a simple way to detect if a WordPress page belongs to a certain category, you can use a WordPress function called in_category(). In this example code below, the script will detect if a post belongs to the “news” category. If it does, it will send an output to the WordPress header. If it isn’t, it will send an alternate output.

function urr_add_to_header() 
{
  if ( in_category( 'news' )) 
  {
    echo '<script>Add your news Javascript here</script>';
  } else {
    echo '<script>Add your alternate Javascript here</script>';
  }
}
add_action( 'wp_head', 'urr_add_to_header', 100 );

function urr_add_to_header() { if ( in_category( 'news' )) { echo '<script>Add your news Javascript here</script>'; } else { echo '<script>Add your alternate Javascript here</script>'; } } add_action( 'wp_head', 'urr_add_to_header', 100 );

It’s a simple function that has many uses. You can accomplish quite a bit with the in_category() function along with a few WordPress hooks.

Filed Under: PHP, WP Tagged With: category, header, in_category

  • Home
  • About
  • Archives

Copyright © 2023