Pages

Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Saturday, April 4, 2015

Apache2-Forbidden You don't have permission to access /dir/ on this server

Recently on restarting my Apache Server on Ubuntu I came across following error

Forbidden You don't have permission to access /dir/ on this server

After a bit of google I solved this by granting permissions to my server directory and resetting my httpd.conf directory access levels as follows

Since I am working on Ubuntu I will be using Ubuntu locations your locations can very depending upon your linux distribution

In Ubuntu httpd.conf file is place under
/etc/apache2/sites-available directory

if you list directory contents you will find files like

000-default.conf   000-default.old   example.com~
000-default.conf~  default-ssl.conf

Out of these first one is the httpd.conf file in concern(this is how Ubuntu stores it)

First make a copy of the same as you can see I have made a copy of the same 000-default.old using following command

sudo cp 000-default.conf 000-default.old

Now Alter the 000-default.conf as follows

 <VirtualHost *:80>  
   ServerAdmin webmaster@localhost  
   DocumentRoot /var/www  
   <Directory />  
     Options FollowSymLinks  
     AllowOverride None  
   </Directory>  
   <Directory /var/www>  
     Options Indexes FollowSymLinks MultiViews  
     AllowOverride All  
     Order allow,deny  
     allow from all  
   </Directory>  
   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  
   <Directory "/usr/lib/cgi-bin">  
     AllowOverride None  
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch  
     Order allow,deny  
     Allow from all  
   </Directory>  
   ErrorLog ${APACHE_LOG_DIR}/error.log  
   # Possible values include: debug, info, notice, warn, error, crit,  
   # alert, emerg.  
   LogLevel warn  
   CustomLog ${APACHE_LOG_DIR}/access.log combined  
 </VirtualHost>  

Next grant permissions to your directory as

sudo chown -R $USER:$USER /var/www
sudo chmod -R g+rw /var/www
 
You will now be able to access your localhost directory 
 

Wednesday, March 25, 2015

Configuring External Apache Tomcat in Netbeans/Ubuntu or error : specify the server location (Catalina Home)) and error : could not read server-config.xml

Hi This posts counters the problem of configuration of external Apache Tomcat Server to Ubuntu..

It also deals with the errors
1. specify the server location (Catalina Home))
2. could not read server-config.xml

To Counter all this we need to do as follows

For First Problem create and link directories as follows.This will only occur if Netbeans thinks if you are using and older version of Tomcat Server.

cd /usr/share/tomcat7
sudo mkdir common
cd common
sudo ln -s ../lib lib

For Second Problem create and link directories as follows

cd /usr/share/tomcat7
sudo mkdir conf 
cd conf
sudo ln -s /etc/tomcat7/server.xml server.xml
sudo chmod o+rx /usr/share/tomcat7/conf 
 
Thats it give a username and Password and Apache server is configured on your Netbeans  


Saturday, March 30, 2013

Recover Lost WAMP Databases

Sometimes we are messed up tinkering with WAMP vanilla package.And all we end up is fatal errors that either restrict us to use PHP MyAdmin or let us forget the fact of importance of an Database Backup.

We take the backup of WWW/our Important Projects but are hopeless when we find no database for the same.

Here is a way to resolve the problem.First and Important step Backup of whatever you are left with

If you have the the following folder intact with you

"D:\wamp\bin\mysql\mysql5.5.24\data".(You may find a change in version of your Mysql Folder.)

You can bring back the Data out from ashes.

This folder remains even if you uninstall wamp.Its ur Mysql Data Dump.Unless and untill you have tempered with this area you can get your databases back.

Now That's the ingredients we need

1. The folder in bold above
2. A Wamp setup(we will be going for a fresh installation)

 If you have them in hand let's startoff with recovery process then

1. Rename this folder to something other than "wamp".Let's say "wamp_bak"
2. Reinstall wamp to your favorite location.
3. Under your wamp installation you will find a file with path and name as follows

"D:\wamp\bin\mysql\mysql5.5.24\my.ini"

You may see only "my" as file name in case your extension types are hidden.Again your mysql version may differ.

Open this file in your favorite text editor.I prefer using "notepad","notepad++" in order to preserve their encodings.

Search for a line like as follows

"datadir=d:/wamp/bin/mysql/mysql5.5.24/data"

It was 39th line I am using notepad++. 

copy this line and place a hash before the same.

"#datadir=d:/wamp/bin/mysql/mysql5.5.24/data"

We have commented this line here....

paste the uncommented  exactly same line just below this commented line.

"datadir=d:/wamp/bin/mysql/mysql5.5.24/data"

We will be playing with Path's now

In windows explorer navigate to your old wamp backup till the data folder and copy its path. Considering you are following the same directory and naming conventions as me you would get a path like this one

"D:\wamp_bak\bin\mysql\mysql5.5.24\data"

(I suppose you have copied it from window's explorer's address bar like any smart freak does )


paste the path in my.ini and replace it with the path in our copied uncommented text.We will get sth like this


"#datadir=d:/wamp/bin/mysql/mysql5.5.24/data" (commented line)
"datadir=D:\wamp_bak\bin\mysql\mysql5.5.24\data" (uncommented line)

In the uncommented line change the copied path as follows

"d:/wamp_bak/bin/mysql/mysql5.5.24/data"

Restart Wamp if you get a green signal everything went well if not check path again.

Open phpmyadmin in browser

http://localhost/phpmyadmin

You will find a list of databases from your previous installations.

Next Step: Exporting Databases

Select Export

Under "Export Method" select "Custom"

Select All Databases Except/Excluding

1. mysql
2. performace_schema
3. information_schema
4. test

Scroll Down Select Go soon you will be told to save an sql file containg sql dump of all your previous databases.

Save it....That's your Magic Wand in Hand to bring up Databases from Ashes.

Change the Path in "my.ini" back to

"datadir=d:/wamp/bin/mysql/mysql5.5.24/data"

(remove the copied line and uncomment the orignal one to get a line sth as above)

Restart Wamp and open 

http://localhost/phpmyadmin in browser 

You should be back with your original setup by now

Now all you need to do is Import SQL File

You may need to modify the sql file again open the same in your favorite editor

remove following lines from top

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
 


remove following lines from bottom

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


Also you might need to modify some Referential Integrity Constraints if you are facing importing error's.

If it imports successfully you are back with original databases.If not let me know the error's.I would with glad to assist you in recovery.

PS:In case you fail even after this do follow our important comments too

Saturday, August 25, 2012

SESSION DATA LOST PHP IIS SERVER

Session Data loses while making an ajax call to a file on IIS server hosting PHP. A very common issue stated on the PHP session_start page as well

http://php.net/manual/en/function.session-start.php

/***** sess1.php *****/
session_start();
$_SESSION["key1"] = "testvalue";
header("Location: sess2.php");

/***** sess2.php *****/
session_start();
echo "key1 = '".$_SESSION["key1"]."'";

PROBLEM:
All session data is lost after a header redirect from the first page on which the session is initialized. The problem is, the PHPSESSID cookie is not being sent to the browser (ANY browser, IE or Mozilla) on the initial session page with the header("Location: ...") redirect. This is unrelated to client cookie settings - the set-cookie: header just isn't sent.

SOLUTION:
I was able to remedy the problem by switching to the ISAPI DLL version. This seems to be an MS/IIS bug, NOT a PHP bug - go figure. I hope this saves you some headaches especially with your user authentication scripts!!


*same case happens if we make an ajax request to a file 

I am still looking for a way to switch to ISAPI dll version though?

Best way I could get was to use cookies in such case scenario if possible.
Things work well on Apache server though but I am still looking for a solution to this....?