Image

How to change Apache user and group

How to change Apache user and group

By  •  Apache

Apache normally runs as an unprivileged user without shell access in most platforms. This is for security reason as a poorly written script or configuration if exploited will not escalate and cause much harm to the system.

If you’re running a development environment and know exactly what you’re doing, you can change the user and group that the Apache process runs as with these simple steps;

  1. Find User and Group directives in Apache‘s configuration file.

  2. Set the user and group that you want Apache process to run as. The following example is to run it as root.

    User root
    Group root

    This could be a big security risk, especially to run it as root.

    Make sure the user and group has appropriate permission to DocumentRoot and related files and folders.

  3. Check if the changes was successful

    $ ps aux | grep apache2
    root      1188  0.0  0.1 162184  6664 ?        Ss   Mar29   0:02 /usr/sbin/apache2 -k start
    root  1197  0.0  0.1 162184  5668 ?        S    Mar29   0:00 /usr/sbin/apache2 -k start
    root  1198  0.0  0.1 162184  5916 ?        S    Mar29   0:00 /usr/sbin/apache2 -k start
    root  1200  0.0  0.1 162184  5684 ?        S    Mar29   0:00 /usr/sbin/apache2 -k start
    root  1201  0.0  0.1 162184  5684 ?        S    Mar29   0:00 /usr/sbin/apache2 -k start
    root  1202  0.0  0.1 162184  5684 ?        S    Mar29   0:00 /usr/sbin/apache2 -k start

    In some distributions the Apache binary could be named httpd instead of apache2.

How to fix CPU hog problem when plugging an iPhone to Ubuntu

By  •  Ubuntu

When plugging an iPhone to a Ubuntu machine for few times, the CPU becomes busy with 100% utilization.

This is due to some bugs which causes iphone-set-info and sometimes gvfs-afc-volume-monitor program to misbehave.

This is confirmed in Ubuntu 10.04

To fix this, run the following commands at the terminal

sudo killall -9 iphone-set-info
sudo killall -9 gvfs-afc-volume-monitor

This will only kill the programs, and will not affect the iPhone’s charging.

How to access guest VM in Virtualbox via port forwarding

You’ll not be able to directly access your guest virtual machine in Virtualbox via SSH or RDP if it’s under NAT network. For this you’ll have to configure port forwarding as detailed below;

  1. Go to Virtualbox‘s main interface and make sure the virtual machine that you want to configure is powered off.
  2. Select your virtual machine and click Settings icon on the top toolbar. Alternatively, right click on the virtual machine and click Settings.
  3. Click on the Network tab in Settings main interface.
  4. Look for and click on Advanced text at the bottom of the window.
  5. Click on Port Forwarding button.
  6. Click on the + icon on the upper right to add new port forwarding rule in Port Forwarding‘s main interface.
  7. Some of the fields are automatically filled up as the followings.
  8. Fill in the fields accordingly.

    In this example, port 2202 in the host machine will forward to port 22 of the guest machine whereby 10.0.2.15 is the default IP for guest VM under NAT network.

  9. Test the forwarding rule.

    $ ssh -p2022  [email protected]
    Warning: Permanently added '[127.0.0.1]:2022' (ECDSA) to the list of known hosts.
    [email protected]'s password:
    Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-83-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
    0 packages can be updated.
    0 updates are security updates.
    
    
    Last login: Fri Jul  7 09:29:30 2017
    [email protected]:~$

    SSH is used to test the forwarding rule as SSH is listening on port 22 of the guest VM.

How to display non-Javascript page for browser with no Javascript support

When a browser doesn’t support Javascript, or simply have it disabled, it’s best to include an alternative non-Javascript content for the page to remain functional.

This is made possible with the noscript tag, and the example below will pop up the alert if Javascript is enabled or supported, and display the text instead if it doesn’t.

<script type="text/javascript">
    window.alert("I support Javascript")
</script>
<noscript>
    I do not support Javascript
</noscript>

How to check hard-drive’s health status in Linux

By  •  Linux

SMART or Self-Monitoring, Analysis, and Reporting Technology is used to monitor the hard drives for reliability. Hard drive’s failure can be anticipated and appropriate action can be taken before the hard drive fail completely.

To check your hard drive’s health status in Linux, the tool smartctl can be used. It is available in the smartmontools package, and in Ubuntu running the command at the terminal will install the package

sudo apt-get install smartmontools

Assuming your hard drive is /dev/sda, running the following command will return the SMART’s health status of your hard drive

sudo smartctl -H /dev/sda

A healthy hard drive will return the following output

smartctl 5.40 2010-03-16 r3077 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

The following is an example output of a problematic hard drive

smartctl 5.40 2010-03-16 r3077 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

Log Sense failed, IE page [scsi response fails sanity test]

How to enable syntax highlighting in Vim

By  •  Vim

Vim can perform syntax highlighting for various file formats. You can enable it with these steps if it’s not currently enabled;

  1. Make sure full version of Vim with support for syntax highlighting is installed.

  2. Manually enable syntax highlighting while in Vim.
    1. Enter command mode by pressing Esc.
    2. Type :syntax on|off and press Enter.

      :syntax on
  3. Manually set syntax for file if required.
    1. Enter command mode by pressing Esc
    2. Type :set syntax=<filetype> and press Enter.

      :set syntax=php
    3. To view the list of supported file types, issue :echo getcompletion while also in the command mode.

      :echo getcompletion('' 'filetype')
  4. Permanently enable syntax highlighting by adding :syntax on in your ~/.vimrc file.

Hello world!

By  •  Uncategorized

Welcome to dirrtyremix.es. This is your first post. Edit or delete it, then start blogging!

How to track Google AdSense earnings in Google Analytics

Google Analytics is a great tool for web analytics. Its uses range from tracking the number of visitors to a site, to tracking effectiveness of online marketing campaign. One of the other feature of Google Analytics is to track earnings from Google AdSense program.

While Google AdSense has its own reporting tool, there are just things that Google Analytics can do better. This includes page-level details of earning tracking that is not available from the Google AdSense member page. Google AdSense reporting tools in the other hand has Custom channel and URL channel reporting option that’s not available in Google Analytics.

Both tools complement each other, and using them both would give better insight of your AdSense earnings and optimization strategy.

To start viewing Google AdSense data in Google Analytics, follow these steps.

Top