• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for July 2016

How To Force Downloads

July 24, 2016

Browsers behave differently when it comes to linking media files. Sometimes it will play them directly on the browser. Sometimes it will download them. Each browser seems to have their own rules. So, how do we force all browsers to download media files with just a click of a link.

A simple link like the one below simply won’t work.

<a href="video.mp4">Download</a>

<a href="video.mp4">Download</a>

One way of forcing downloads is to use a PHP function called readfile.

We have a file below called dl.php. We pass the filename to it, as well as set the path and URL.

$filename = $_GET['file'];
$filepath = "http://domain.com/download/";
$url = $filepath.$filename;
header("Content-disposition: attachment; filename=".$filename."");
header("Content-type: application/octet-stream");
readfile("".$url."");

$filename = $_GET['file']; $filepath = "http://domain.com/download/"; $url = $filepath.$filename; header("Content-disposition: attachment; filename=".$filename.""); header("Content-type: application/octet-stream"); readfile("".$url."");

Our HTML download link will look like this.

<a href="dl.php?file=video.mp4">Download</a>

<a href="dl.php?file=video.mp4">Download</a>

It’s one way of forcing a download via the PHP route.

Filed Under: PHP Tagged With: browser, download, readfile

Install Exim4 On Ubuntu Server

July 22, 2016

Exim4 is a MTA or message transfer agent that runs on Linux systems. It’s freely available under GNU Linux. If you need to run mail from a server or send an email through an app, you’ll need to install Exim4. It can be installed in place of Sendmail or Postfix.

To install Exim4, open up your Terminal.

$ sudo apt install exim4

$ sudo apt install exim4

Configure Exim4.

$ sudo dpkg-reconfigure exim4-config

$ sudo dpkg-reconfigure exim4-config

You’ll be asked several questions.

  1. Select “internet site” for type of mail configuration.
  2. Enter your domain name when asked about system mail name.
  3. Answer “127.0.0.1 ; ::1” when asked about incoming SMTP connections
  4. Answer the default answers for the next 3 questions.
  5. Answer “No” for Dial on demand.
  6. Answer “mbox” for delivery method for local mail.
  7. Answer “yes” to split configuration into small files.

If you need to reconfigure Exim4, just re-run the reconfigure command.

Don’t try to edit the /var/lib/exim4/config.autogenerated file.

Test if Exim4 is sending out emails.

$ mail -s "Your Subject" recepient@email.com
$ Hello there. This is the body of the message.

$ mail -s "Your Subject" recepient@email.com $ Hello there. This is the body of the message.

Type Ctrl-D to send the message.

Another way to test if Exim4 is working is to use WordPress. There’s a lost password link below the login page. Click on that. Supply a valid user email address. You should received an email directly from WordPress.

Filed Under: Linux Tagged With: exim4, mail

Remove CleanMyMac

July 19, 2016

Several months ago, I’ve installed an app called CleanMyMac. Big mistake. I didn’t like it much. I deleted it shortly after. The uninstall didn’t quite exactly remove everything. This morning, I updated my computer with the latest Mac updates. It required a reboot. Sure enough, the CleanMyMac notifications came back. Apparently, there’s some pieces of the app that are still running on my machine.

The only way I was able to delete anything related to the CleanMyMac app was to use a couple of tools. One is called Find Any File, a handy utility for finding obscure files in your OS. The other is the handy tool called the Terminal. Start with the Find Any File app and search for files that contain the words “CleanMyMac” and “macaw.” The Find Any File app will show you a list of files and their locations. You should be able to delete the files directly from the app. However, there are some files that are write-protected. They can be deleted using a sudo account on the Terminal.

Open up your Terminal and start deleting the files using “sudo rm” command. You’ll be ask to provide the admin password. Don’t forget to empty the Trash.

That should do the trick.

Filed Under: Mac, Misc Tagged With: cleanmymac, find any file, terminal

The Return of the Linux Desktop

July 19, 2016

I’m thinking about using the Linux desktop again after 4 years of inactivity. The MacOS was the desktop of choice. I’ve been happy with the switch. I don’t anticipate abandoning it any time soon. Lately I thought about sharpening up my Linux skills after having been dormant for years. I need a Linux platform that I can work with. Ubuntu is my default, but there are other distros equally interesting. Mint, Debian and Fedora come to mind. Instead of having multiple boot partitions, I might install Ubuntu as the base distro and install Virtualbox. Other distros can be fired up as virtual machines. In that way, it’s simple to manage. I just need a heftier machine that can handle several VMs running at the same time. That’s the plan for the next several weeks.

Filed Under: Linux Tagged With: debian, fedora, mac os, mint, ubuntu, virtualbox

Change WordPress Password

July 18, 2016

One of the worst things that could happen to your blog is losing your login credentials. It’s a rare event, but it does happen occasionally. This is particularly true if you run hundreds of blogs and websites. Keeping track of all usernames and passwords can be a bit of a challenge.

If you have forgotten your WordPress password, you can quickly recover it, by using the “Lost your password” link underneath the login form. In my case, WordPress mail was not working. So, not only I can’t remember my password, but I also can’t send out lost passwords via email.

Thankfully, I had access to PHPMyadmin, a MySQL database administration tool.

Log in to PHPMyadmin. Access the WordPress database and look for the wp_users table. Edit the admin user and change the “user_pass” field. The WordPress password field uses the MD5 encryption instead of being in the clear.

password

Save your changes. Log in to WordPress.

Filed Under: WP Tagged With: admin, md5, password, phpmyadmin

Upgrading Icecast2

July 13, 2016

The following instructions will perform the latest Icecast2 server upgrade on your Ubuntu Server via the PPA route.

1. Login to your Ubuntu Server via SSH. Substitute your own username and server.

$ ssh ulysses@server.com

$ ssh ulysses@server.com

2. Add Icecast2 PPA to your sources list. Since I’m running Ubuntu 12.04, I’ll use the 12.04 repository here.

$ sudo sh -c "echo deb http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04 ./ > /etc/apt/sources.list.d/icecast.list"

$ sudo sh -c "echo deb http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04 ./ > /etc/apt/sources.list.d/icecast.list"

3. Add the GPG key to the apt sources keyring. I’ll use the 12.04 release key here as well.

$ wget -qO - http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04/Release.key | sudo apt-key add -

$ wget -qO - http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04/Release.key | sudo apt-key add -

4. Run Update to begin the upgrade process to the latest version of Icecast2.

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

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

5. The Icecast2 install script will run and ask you to overwrite your previous configuration. It’s up to you to keep or overwrite the file.

6. If you’re using your previous configuration file, it may throw out some errors and warnings, which you will probably need to fix.

7. Finally, test your Icecast2 server by sending a stream to it.

Filed Under: Linux Tagged With: icecast, ppa, ssh

Restarting Nginx

July 1, 2016

Niginx is primarily a web server, but it can also run as a proxy server, load balancer and a HTTP cache.

If you’re running on Debian, Ubuntu, Red Hat or CentOS, the following are several ways of restarting Nginx.

# /etc/init.d/nginx restart
# /etc/init.d/nginx reload
# service nginx restart
# service nginx reload
# nginx -s reload

# /etc/init.d/nginx restart # /etc/init.d/nginx reload # service nginx restart # service nginx reload # nginx -s reload

The last example is more universal and will run in any Linux flavor.

Filed Under: Linux Tagged With: nginx, web server

  • Home
  • About
  • Archives

Copyright © 2023