Finding Apache httpd.conf file location

It’s been quite sometime since i’ve used apache, I’ve been enjoying nginx so far but had to switch back to apache for a project. just a quick tip for those who are working with Apache. Sometimes we are forced to work with a server that we are unfamiliar of interms of configuration/settings/installation and asked where to find the Apache configuration file is on a given server. so I usually do:

$ ps -ef | grep apache

which will give me the list of process like this

coolguy@mbpro:/$ ps -ef | grep apache

apache 14305 22691 11 21:22 ? 00:00:00 /usr/local/httpd-2.2.4/bin/httpd -k start
apache 14341 22691 0 21:22 ? 00:00:00 /usr/local/httpd-2.2.4/bin/httpd -k start
apache 14374 22691 1 21:22 ? 00:00:00 /usr/local/httpd-2.2.4/bin/httpd -k start

or in other linux flavor / installation path

root 4053 1 0 02:34 ? 00:00:04 /usr/sbin/apache2 -k start
www 6789 14053 0 12:00 ? 00:00:00 /usr/sbin/apache2 -k start
www 6790 14053 0 12:00 ? 00:00:00 /usr/sbin/apache2 -k start

...

after seeing the list you can have a clue now ūüôā Then simply run


$ /usr/local/httpd-2.2.4/bin/httpd -V
or
$ /usr/sbin/apache2 -V

and then you will get the details you need…

Server compiled with....
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

There you go. Do you have another faster method? Please do let me know.

Viewing a .gz file directly using Less

one way to view a file in Linux is via Less, but what if you want to less a .gz file?

one way to do it is to extract the gz file then execute a Less on the extracted file,

however another method i would like to share is the LESSOPEN env variable.

Less will auto detect if the environment variable is present then uses it.

try executing in your command line.

export LESSOPEN="|gzip -cdfq %s"

then less a .gz file.

You wounldnt want to exec the export again again, you may automate this by including this in your bash profile

Enjoy the power of LESSOPEN!

svn: Can’t open file ‘.svn/text-base/.svn-base’: No such file or directory

Having problem with the above svn issue when you do an svn update? check my solution below.

[user1@host production]$ svn update common.php
svn: Can't open file '.svn/text-base/common.php.svn-base': No such file or directory
[user1@host production]$
[user1@host production]$ touch .svn/text-base/common.php.svn-base
[user1@host production]$ chmod 777 .svn/text-base/common.php.svn-base
[user1@host production]$
[user1@host production]$ svn update common.php
Restored 'common.php'
E common.php
Updated to revision 2288.

Enable (.srt) on Samsung TV from Linkstation NAS

I’ve recently bought a 2TB Buffalo NAS – Linkstation Pro Duo. Loving it so far until I ran into a problem on streaming mp4 videos to my Samsung TV Series 6. I had no issues playing the mp4 video however I was so disappointed I couldn’t enable the subtitle (.srt). I’ve googled around and i kept reading solution to make the mp4 and srt filename identical or omit space on the filenames. i’ve followed the suggestions but still … the subtitle wouldn’t come out on the screen. I’m beginning to feel pissed and after a few more hours luckily a friend from Facebook advised me to try renaming the mp4 to “mpg”. and to my surprised it worked!!! If you are reading this post, you might be in the same boat as me. Try it now!

Map Network Drive in Linux

Are you wondering how to do a Map Network Drive in Linux?

It’s called “mount”ing in Linux. There’s a command called mount in linux that helps you maps a network drive to your machine.

if the server you need to mount is also a linux server. try this command

mount -t cifs -o username=UsernameHere,password='PasswordHere' //server-name or ip/Path /your/directory/in/current/dir/

“/your/directory/in/current/dir/” – can be an ln or a directory and has to be present, this is called the mount point on your current server

Refer to the mount.cifs manual page for more info ( man mount.cifs )

Enjoy!

Vanilla Forum 2.1 Nginx Configuration

Are you already loosing you hair trying to configure your vanilla forum url-rewrite on NGINX?

If your forum is installed on a main¬†domain not a subdomain I might have the solution for you. here’s what got, please let me know if it works for you…

server {
    listen       80;
    server_name  yourdomain.com;
    root   /usr/share/nginx/youvanilladirectory/;
    #access_log /usr/share/nginx/youvanilladirectory/access.log;
    access_log off;
    #error_log /usr/share/nginx/youvanilladirectory/error.log;
    error_log off;
    index  index.php index.html index.htm;
    #Root location
    location ^~ /discussion/download/ { rewrite ^/(.+)$ /index.php?p=$1 last;}
    location ^~ /utility/thumbnail/ { rewrite ^/(.+)$ /index.php?p=$1 last;}
    location / {
        try_files $uri $uri/ @forum;
    }
    # Rewrite to prettify the URL and hide the ugly PHP stuff
    # Start with this commented out until you configure it in Vanilla!
    location @forum {
        rewrite ^/(.+)$ /index.php?p=$1 last;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)(\?ver=[0-9.]+)?$ {
        expires 1y;
    }
}

Setup vsftpd user default dir (CentOS)

Hi,

Today, I’m sharing how to simply setup the default directory of your vsftpd user on CentOS.

1. Edit vsftpd.conf

vi /etc/vsftpd/vsftpd.conf

2. Add the line

user_config_dir=/etc/vsftpd/vsftpd_user_conf

3. Create a dir, and change directory to the created dir

mkdir /etc/vsftpd/vsftpd_user_conf; cd /etc/vsftpd/vsftpd_user_conf/

4. Create a file with the username as filename of the vsftpd user

vi username

5. Add the line

local_root=/var/www/html

You’re done! Once the user logs in, the file you’ve just created will be used to read as config parameter. I believe it should also work with other flavour of Linux, only the vsftpd installation are different.

(for more info just man vsftpd.conf)

Cheers!

phpMyAdmin can’t login

One of the common issue of phpMyAdmin  is getting the error on cookie or sometimes no matter how many times you login you keep getting redirected to login page.

Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.

Screen Shot 2014-10-06 at 11.17.33 pm

At first i thought clearing the cookie will help solve the issue¬†but in my case, I previously had a ¬†apache webserver installed before i switched to nginx therefore the ownership of session folder was still under apache. All i had to do was to switch the folder ownership¬†to nginx, but please note the effect of this incase you are still using apache user. On the¬†command below i changed the ownership including the files inside the session folder because i know I’m not using apache user anymore. There are setup where by apache and nginx exists therefore both users are still valid and might be using¬†the session folder.

 

[root@server1 php]# pwd
/var/lib/php
[root@server1 php]# ls -l
total 8
drwxrwx— 2 root apache 4096 Oct¬† 5 15:54 session
drwxrwx— 2 root nginx¬† 4096 Sep 20 15:16 wsdlcache
[root@server1 php]# chown root.nginx session -R
[root@server1 php]# ls -l
total 8
drwxrwx— 2 root nginx 4096 Oct¬† 5 15:54 session
drwxrwx— 2 root nginx 4096 Sep 20 15:16 wsdlcache