Author Archive

Time Settings on a Dual-Boot Computer

July 17th, 2016 No comments

When dual-booting Windows 7 and Ubuntu 16.04 on a computer, there is conflict in time settings because of the way the two operating systems set the hardware clock. By default Ubuntu uses UTC while Windows uses local time.

So when you shut down the computer, the hardware clock is set to, say, “13:00”. When you reboot, Windows sees “13:00” as local time but Ubuntu sees that as UTC and so converts the time back from UTC to local time. You can fix this by either asking windows to set the hardware clock with UTC, or Ubuntu to use local time.

To make the change in Ubuntu
You can set the hardware clock time standard through the command line. You can check what you have set to use by:

$ timedatectl | grep local

The hardware clock can be queried and set with the timedatectl command. To change the hardware clock time standard to local time, use:

# timedatectl set-local-rtc 1

If you want to revert to the hardware clock being in UTC, do:

# timedatectl set-local-rtc 0
Categories: Linux, Tips and Tricks, Windows Tags:

Windows 7 SP1 Windows Update Stuck

July 17th, 2016 No comments

Windows Update got stuck at “Check Windows Update …” on a freshly-installed Windows 7 SP1.


  1. Download Windows Update KB3020369 from Microsoft website.
  2. Download Windows Update KB3161608 from Microsoft website.
  3. Install KB3020369. This is required to install the next KB.
  4. Install KB3161608.
  5. Reboot. Run Windows Update again. This should solve the problem.

See this post for details.

Categories: Tips and Tricks, Windows Tags:

WordPress Permalinks Apache Setup

June 18th, 2016 No comments

This is a post copied from here. All the credits go to the original author of that post.

Thought I’d include some instructions for setting up “WordPress Permalinks” (which don’t work by default) which means you can get rid of those ugly WordPress URI’s and replace them with something more human readable.

Assuming you have inserted the runtime mod_rewrite DSO or complied Apache with —enable-rewrite then in order to get WordPress permalinks to function you need to include the following in your Apache config file (httpd.conf):

The quoted block below needs to go inside your virtual host section for your WordPress installation. Once Apache has been restarted your permalinks menu inside “Wordpress Admin” can be used and now your new URL’s should be functional.

<Directory "Directory_to_your_Wordpress">
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
Categories: Linux, Wordpress Tags:

How to Install Apache, MySQL, PHP, and phpMyAdmin on FreeBSD

June 18th, 2016 No comments

This is a post copied from here. All the credits go to the author, iceflatline.

This post will describe how to install and configure Apache, MySQL, PHP and phpMyAdmin on FreeBSD for basic local web development. Once set up, you’ll be able to use your “AMP” server to do web development, code testing, maintain local copies of your web sites, etc.

The software discussed in this post are available as free and open source under various licensing structures. The versions of software discussed in this post are as follows:

FreeBSD 10.3-RELEASE-p4
Virtual Box 5.0.20 r106931
WordPress 4.5.2

The following steps discussed in this post assume you have the FreeBSD Ports Collection installed. If not, you can install it using the following commands:

portsnap fetch
portsnap extract

If the Ports Collection is already installed, make sure to update it:

portsnap fetch update

Okay, let’s get started. All commands are issued as the root user or by simulating the root user by using the command su. While building the various ports you should accept all default configuration options unless otherwise instructed.

Install Apache

Navigate to the Apache server port and build it:

cd /usr/ports/www/apache24
make config-recursive install distclean

Once Apache has been successfully installed, add the following line to /etc/rc.conf so that the Apache server will start automatically at system boot.

sysrc apache24_enable=YES

Now let’s start Apache to make sure it works:

service apache24 start

Point your web browser to the host name or IP address of the FreeBSD host you’ve installed Apache on and you should see the venerable “It works!”

Install MySQL

Now let’s build the MySQL server:

cd /usr/ports/databases/mysql57-server
make config-recursive install distclean

Add the following line to /etc/rc.conf:

sysrc mysql_enable=YES

And start the mysql server:

service mysql-server start

Then set a password for the MySQL root user:

/usr/local/bin/mysql -u root -p

You’ll be requested to enter a password. Enter the password contained in /root/.mysql_secret. You’ll now be at the command prompt for the mysql server. Change your password using the following command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'your-new-password';

Enter ‘quit’ to exit the server. You may now delete /root/.mysql_secret.

Install PHP

Next, we’ll build PHP:

cd /usr/ports/lang/php70
make config-recursive install distclean

Then the module required to support PHP applications on Apache:

cd /usr/ports/www/mod_php70
make config-recursive install distclean

Now let’s add the extensions to PHP to round out its capabilities. Before we build this port though we’ll want to add support for MySQLi (an improved interface to MySQL) in order to communicate with the MySQL server.

cd /usr/ports/lang/php70-extensions/
make config-recursive

In the corresponding menu you should select “MYSQLI”, then proceed with building the port:

make install distclean

Install phpMyAdmin

phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL from your web browser. phpMyAdmin supports a wide range of operations with MySQL, including managing databases, tables, fields, relations, indexes, users, permissions, etc., from an easy-to-use web page, while you still have the ability to directly execute any SQL statement from the command line if you prefer. Installing phpMyAdmin is optional but it’s nice tool to have:

cd /usr/ports/databases/phpmyadmin/
make config-recursive install distclean


Now that we have the requisite ports built and installed it’s time to configure them. First, let’s create the file /usr/local/etc/php.ini to hold our PHP options. The simpliest way to do this is to copy the file /usr/local/etc/php.ini-development which will add the default settings for new PHP installations. This configuration is suitable for development purposes, but NOT necessarily for production purposes. If your plans include a production server, then among other things, and before going online with your site, you should consider copying /usr/local/etc/php.ini-production instead and consult the recommendations at

cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini

Now let’s configure Apache. Open the file /usr/local/etc/apache24/httpd.conf and look for the following line:

DirectoryIndex index.html

And change it so it reads as follows:

DirectoryIndex index.html index.php

Then append the following lines to the end of the file in order to support PHP files as well as phpMyAdmin, which normally lives outside of the Apache document root. Note: if you elected not to install phpMyAdmin, then you need only add the FilesMatch directives.

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
Alias /phpmyadmin "/usr/local/www/phpMyAdmin"
<Directory "/usr/local/www/phpMyAdmin">
Options None
AllowOverride None
Require all granted

Now restart Apache:

service apache24 restart

That’s it for our Apache configuration. Now let’s configure phpMyAdmin. We’ll do this by creating the file /usr/local/www/phpMyAdmin/, the basic configuration file for phpMyAdmin. Traditionally, users have manually created or modified /usr/local/www/phpMyAdmin/, but now phpMyAdmin includes a nice setup script, making it much easier to create this file with the settings you want. Start by creating the directory /usr/local/www/phpMyAdmin/config and make it writable by the phpMyAdmin setup script:

mkdir /usr/local/www/phpMyAdmin/config && chmod o+w /usr/local/www/phpMyAdmin/config

Then make /usr/local/www/phpMyAdmin/ readable by the phpMyAdmin setup script:

chmod o+r /usr/local/www/phpMyAdmin/

Now open your web browser and navigate to http://your-hostname-or-IP-address/phpmyadmin/setup where you will see the phpMyAdmin setup Overview page. Select “New server” and then select the “Authentication” tab. Under the “Authentication type” choose “http” from the drop-down list (using HTTP-Auth to sign-in into phpMyAdmin will avoid storing login/password credentials directly in and remove “root” from the “User for config auth”(See Figure 1).

phpMyAdmin setup page
Figure 1. Screenshot of the phpMyAdmin setup page.

Now select “Apply” and you will be returned you to the Overview page where you should see a new server listed. Select “Save” in the Overview page to save your configuration as /usr/local/www/phpMyAdmin/config/ Now let’s move that file up one directory to /usr/local/www/phpMyAdmin where phpMyAdmin can make use of it.

mv /usr/local/www/phpMyAdmin/config/ /usr/local/www/phpMyAdmin

Now let’s try out phpMyAdmin to make sure it works. Point your web browser to http://your-hostname-or-IP-address/phpmyadmin where you will be presented with a pop-up box requesting you to log in. Use “root” and the MySQL password you set up previously, then you should be directed to the phpMyAdmin administration page. We no longer need the /usr/local/www/phpMyAdmin/config directory so let’s remove it, as well as the read permission we added previously to /usr/local/www/phpMyAdmin/

rm -r /usr/local/www/phpMyAdmin/config
chmod o-r /usr/local/www/phpMyAdmin/

And wrap up by restarting the Apache and MySQL servers:

service apache24 restart
service mysql-server restart

Testing our installation using WordPress

WordPress is a full-featured website/blog platform that makes heavy use of Apache, MySQL and PHP. We’ll install it on our newly created implementation to ensure we have these packages installed and working correctly. Once again, all commands are issued as the root user or by simulating the root user using the command su. Let’s start by downloading the latest WordPress directly from the developers site to your home directory and untarring the package:

cd ~
tar -zxvf latest.tar.gz

You should now see the new directory wordpress in your home directory. Next we need to create the file ~/wordpress/wp-config.php and make some changes to it so WordPress can access the MySQL server. First, let’s copy the file ~/wordpress/wp-config-sample.php to use as a template:

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

Open ~/wordpress/wp-config.php in your favorite editor and enter the database name as well as your MySQL login and password in the appropriate lines. When complete, it should look like the following:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'your-mysql-password');

Now move the wordpress directory to Apache’s document root:

mv ~/wordpress/ /usr/local/www/apache24/data/

Next, let’s create an MySQL database for our WordPress installation. Open phpMyAdmin in your browser and create a database by selecting the “Databases” tab at the top. Enter a name for it in the “Create database” field. For purposes of our example, I’ll use “wordpress” as the database name. You’re free to use a different database name, just make sure to use the same name in the define(‘DB_NAME’, ‘your-DB-name’); line in ~/wordpress/wp-config.php as described above. Then select “Create.”

Now let’s run the WordPress script that will populate its database with the requisite tables. Open your web browser and navigate to http://your-hostname-or-IP-address/wordpress/wp-admin/install.php. If everything is configured correctly you should see the WordPress installation wizard page (See Figure 2). Enter a title for your site, username, password, and an e-mail, then select “Install WordPress.” Then login with your newly created WordPress credentials and you should be presented with the default WordPress administration page.

WordPress installation page
Figure 2. Screenshot of WordPress installation page.

Common problems

An error that occasionally pops up when attempting to start the Apache server is the following:

httpd: apr_sockaddr_info_get() failed for <some-host-name>
httpd: Could not reliably determine the server's fully qualified domain name, using for ServerName
/usr/local/etc/rc.d/apache24: WARNING: failed to start apache24

This can be fixed by adding the following line to /usr/local/etc/apache24/httpd.conf:

ServerName localhost:80

HTTP 403 permission problems when trying to access phpMyAdmin is another area that seems to sometimes trip people up. This is usually caused by errors in the way either the Alias or Directory Apache directives for phpMyAdmin have been written in /usr/local/etc/apache24/httpd.conf. As an example, a missing “/” in the Alias statement cost me two hours of troubleshooting time!


Well, that’s it. A few hours of your time with the FreeBSD Ports Collection and you can a get a fully configured “FAMP” web development server up and running on your FreeBSD box.

Categories: Linux, Wordpress Tags:

TMobile Prepaid 用 OpenVPN 翻墙简单笔记

April 25th, 2013 No comments

OpenVPN 服务器搭建:

  1. 把自己的 Linksys E3000 路由器刷成带 OpenVPN 的 TomatoUSB 固件。
  2. 下载 OpenVPN 软件到电脑。在电脑上生成证书、密码和客户端配置文件。
  3. 在 Linksys E3000 路由器上配置 OpenVPN 服务器 (需要将上一步生成的服务器端的证书和密码上传到路由器上)。OpenVPN 的端口使用默认的 1194 号端口。
  4. 我将在客户端使用 53 号端口连接自己的 OpenVPN 服务器。所以在 Linksys E3000 路由器上设置 将 TCP 53 号端口映射到路由器上的 1194 号端口。这里提一句,之所以我不直接使用 53 号端口作为 OpenVPN 的服务器端口的原因是因为 53 号端口已经被 DNS 服务占用了。
  5. 因为我要从外网连自己的路由器上的 OpenVPN 服务器,而我的 IP 地址又不是静态 IP,所以需要在 FreeDNS 网站上注册一个二级域名然后把这个二级域名指向你自己的外网 IP。

Android 手机设置:

  1. 确认手机的 APN 是:。如果使用 的话会出现连接错误。
  2. 在 Google Play 上下载 OpenVPN for Android。
  3. 将前面生成的客户端的证书、密码和配置文件上传到手机。
  4. 在 OpenVPN for Android 里面导入客户端配置文件。
  5. 现在就可以测试 OpenVPN 连接了。
Categories: Tips and Tricks Tags:

Do Not Open PDF in Firefox

April 13th, 2013 No comments

I don’t like opening pdf files in Firefox so I’d like to disable this feature. To do this, you need to configure both Acrobat and Firefox:

  1. In Firefox, go to Tools -> Options -> Applications. Define the default action for the Portable Document Format (PDF) as “Always Ask”.
  2. In Acrobat, go to Edit -> Preferences. In the “Internet” tab, uncheck “Display PDF in browser”.

This should disable opening PDF files in Firefox. Next time when you click a link to a PDF file, a window will pop up and ask what you want to do with the PDF file.

Categories: Tips and Tricks Tags:

Debian – Some Upgrades Show Packages Being Kept Back

December 13th, 2012 No comments

This is a post copied from here. All the credits go to the author, Steve.

Sometimes when you go to upgrade your machine with apt-get you will see that a package is being “kept back”.

Normally to upgrade a machine you would run:

apt-get update
apt-get upgrade

This should upgrade all the installed packages upon your machine (well at least all those packages which you have installed that have a newer version available), but it doesn’t always do that.

If the dependencies have changed on one of the packages you have installed so that a new package must be installed to perform the upgrade then that will be listed as “kept-back”.

For example my apt-get upgrade today showed this:

root@sun:~# apt-get upgrade
Building Dependency Tree... Done
The following packages have been kept back:
  bind9-host dnsutils imagemagick libmagick6
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

There we can see four packages haven’t been upgraded, even though newer packages are available. This is because two new packages were introduced, and these upgrades depend upon it.

To fix this you must run :

apt-get dist-upgrade

This will upgrade the packages that have newer versions available, and install any new dependencies which are required to do that.

root@sun:~# apt-get dist-upgrade 
Reading Package Lists... Done
Building Dependency Tree... Done
Calculating Upgrade... Done
The following NEW packages will be installed:
  libdns16 libdps1
The following packages will be upgraded:
  bind9-host dnsutils imagemagick libmagick6
4 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3697kB of archives.
After unpacking 1860kB of additional disk space will be used.
Do you want to continue? [Y/n]

Here we can see the two new packages which are required to satisfy the dependencies of the upgrades, libdns16 and libdps1.

Categories: Linux, Tips and Tricks Tags:

Mountain Lion – Finder Windows Not Re-Open on Login

December 4th, 2012 No comments

I just installed Mountain Lion OS X 10.8.2 on my PC. I have got this problem: Finder windows did not re-open when I logged back into the system.

I like having a few Finder windows always open. When I shut down and then start up my computer the next day, all the windows I had opened in the Finder are closed. The windows won’t stay opened on restart.

I googled around and the following terminal command that I found in this post seems to have resolved my problem.

defaults write NSQuitAlwaysKeepsWindows -bool true
Categories: OS X Tags:

Logitech Performance MX Mouse under Xubuntu

November 15th, 2012 No comments

If you Logitech Performance MX Mouse doesn’t work out of box under Xubuntu, there is an easy fix.

Edit the file: /lib/udev/rules.d/97-bluetooth-hid2hci.rules. Change this line:

    # Logitech devices
    KERNEL=="hiddev*", ATTRS{idVendor} =="046d" , ATTRS{idProduct }=="c70[ 345abce] |c71[34bc] ", \
    RUN+="hid2hci --method= logitech- hid --devpath=%p"


    # Logitech devices
    KERNEL=="hidraw*", ATTRS{idVendor} =="046d" , ATTRS{idProduct }=="c70[ 345abce] |c71[34bc] ", \
    RUN+="hid2hci --method= logitech- hid --devpath=%p"

Note that you only need to change “hiddev*” to “hidraw*“.

Restart the machine and your Performance MX Mouse should work now.

Categories: Linux, Tips and Tricks Tags:

Restore Grub 2 Using LiveCD

October 21st, 2012 No comments

Restore Grub 2 Using LiveCD
Grub 2 typically gets overridden when you install Windows or another operating system. To make Grub 2 control the boot process, you need to reinstall (repair/restore) Grub 2 using a Ubuntu live CD.

Boot the computer using live CD. Open the Terminal. Using the following commands to mount the partition your Ubuntu Installation is on. If you are not sure which it is, launch GParted (included in the Live CD) and find out. Replace the XY in the command with your drive letter and partition number.

sudo mount /dev/sdXY /mnt
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys

Now you need to change root using chroot command.

sudo chroot /mnt

Now install and Grub 2. This time you only need to add the partition letter (no number) to replace X.

grub-install /dev/sdX
grub-install --recheck /dev/sdX

Now you can exit you mounted hard disk and unmount.

sudo umount /mnt/sys
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt

Shut down and turn your computer back on, and you will be met with the default Grub2 screen. You may want to update or re-configure Grub 2 using the method mentioned in Grub 2 Configuration to the way you like it.

How to Repair/Restore/Reinstall Grub 2 with a Ubuntu Live CD.

Categories: Linux Tags: