twitter
    Find out what I'm doing, Follow Me :)
Showing posts with label Apache2. Show all posts
Showing posts with label Apache2. Show all posts

Enable htaccess Apache in Ubuntu


Enable htacces for directories

we know that htaccess permission must on apache web server like making SEF urls, directory permissions..etc.here we discuss about how to check .htaccess enabled.
Before we begin this tutorial, please make sure you make a backup copy of the originalhttpd.conf apache configuration file located in apache installation folder in case we make a mistake, this way we can always go back to the original configuration file
Now open
httpd.conf
file with note pad and find the below text
<directory />
Options FollowSymLinks
AllowOverride none
Order deny,allow
Deny from all
Satisfy all
</directory>
Then replace AllowOverride none to AllowOverride All. Modified version looks as below
<directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all
Satisfy all
</directory>
Above change tells the apache to use .htaccess as per directory bases.
Now we can use .htaccess files .

Remember

Remember while uploading .htaccess file to remote server make sure the file transfer in ASCII mode, generally with windows operating system FTP programs use binary mode.
Generally FTP programs doesn’t display the .htaccess files by default ,we must force the FTP program to show hidden files like .htaccess files.
When you save .htaccess file with note pad it saves as .htaccess.txt .Make sure .htaccess is a file extension not a file name with empty name.

Connect Tomcat 7 with Apache2 (mod_jk) and install Virtual Host

Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. This allows one machine to share its resources, such as memory and processor cycles, to use its resources more efficiently.

One widely used application is shared web hosting. Shared web hosting prices are lower than a dedicated web server because many customers can be hosted on a single server.

Installa Apache Tomcat 7:
http://diegobenna.blogspot.com/2011/01/install-tomcat-7-in-ubuntu-1010.html

and install Apache2:
http://diegobenna.blogspot.com/2011/01/install-apache2-with-php5-and-mysql.html

Install the connector:
sudo apt-get install libapache2-mod-jk

Now we move on to configure it to communicate with Apache Tomcat.
The first step is to create a file folder worker.properties apache like this:
sudo gedit /etc/apache2/workers.properties

End insert this text:
# Define 1 real worker using ajp13
worker.list=worker
# Set properties for worker (ajp13)
worker.worker.type=ajp13
worker.worker.host=localhost
worker.worker.port=8009

If you want add a new application in Virtual Web Host is not necessary to add a new workerX

Edit this file for connect tomcat's application with apache2:
sudo gedit /etc/apache2/httpd.conf

Past and copy this text:

ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

Now we just have to disable the default configuration file for apache with:
sudo a2dissite default

We must also remove the line NameVirtualHost *: 80 as follows:
sudo gedit /etc/apache2/ports.conf

Reload e restart apache2
sudo /etc/init.d/apache2 reload
sudo /etc/init.d/apache2 restart

Edit file jk.load for load tomcat webapps in apache2 avaible web site

cd /etc/apache2/mods-available
sudo gedit jk.load

Past and copy this text:


LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile     /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile     /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

And now edit proxy.conf


sudo gedit proxy.conf

This is new text:

<IfModule mod_proxy.c>
#turning ProxyRequests on and allowing proxying from all may allow
#spammers to use your proxy to send email.

ProxyRequests Off

<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
#Deny from all
#Allow from .example.com
</Proxy>

# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block

ProxyVia On
</IfModule>

Create the symbolik link in apache web site avaible:
cd /etc/apache2/mods-enabled 
sudo ln -s ../mods-available/jk.load ./jk.lo

We add in mods-enabled also links to the following modules
rewrite.load
proxy.load
proxy.conf
proxy_ajp.load


sudo ln -s ../mods-available/rewrite.load ./rewrite.load
sudo ln -s ../mods-available/proxy.load ./proxy.load
sudo ln -s ../mods-available/proxy.conf ./proxy.conf
sudo ln -s ../mods-available/proxy_ajp.load ./proxy_ajp.load


Create and edit the application's file (genetic is my web application name):
sudo gedit /etc/apache2/sites-available/genetic

Copy and past this text:

NameVirtualHost www.genetic.it:80
<VirtualHost www.genetic.it:80>
ServerName www.genetic.it
JKMount /genetic/* worker
JKMount /genetic worker

  RewriteEngine on
  RewriteRule ^/$ /genetic/ [R=permanent]
  RewriteRule ^/genetic/(.*)$ ajp://localhost:8009/genetic/$1 [P]
</VirtualHost>

Create a symbolic link in enabled directory:

cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/genetic ./001-genetic

Let's create an application to be addressed
sudo gedit /usr/share/tomcat7/conf/server.xml

Add this text to hosts:

...
<Host name="www.genetic.it" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="true" xmlNamespaceAware="false">
<Context path="" docBase="genetic/" reloadable="true" privileged="true" antiResourceLocking="false" anitJARLocking="false">
</Context>
</Host>
...

I create the folder for the application if the application does not exist

sudo mkdir /usr/share/tomcat7/webapps/genetic
cd /usr/share/tomcat7/webapps/genetic

Install application
sudo jar xvf genetic.war

Now your virtualhost in internet is actived. If you want virtualhost in localhost, edit hosts file:

sudo gedit /etc/hosts

Add in the line starting with 127.0.0.1

www.genetic.it

Install module rewrite
sudo a2enmod rewrite

Restart tomcat and reload Apache2

sudo /etc/init.d/apache2 reload
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/tomcat7 restart

Write in your browser:
www.genetic.it
and see your tomcat webapp in apache

Install Apache2 with PHP5 and MySQL support on Ubuntu 10.10 (LAMP)

LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can install an Apache2 webserver on an Ubuntu 10.10 server with PHP5 support (mod_php) and MySQL support.


1. Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

sudo su


2. Installing MySQL 5

First we install MySQL 5 like this:

aptitude install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:


New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword

3. Installing Apache2

Apache2 is available as an Ubuntu package, therefore we can install it like this:

aptitude install apache2

Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder page (It works!):



Apache's default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.


4. Installing PHP5

We can install PHP5 and the Apache PHP5 module as follows:

aptitude install php5 libapache2-mod-php5

We must restart Apache afterwards:

/etc/init.d/apache2 restart


5. Testing PHP5
Getting details about your PHP5 installation

The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/info.php

Insert this code in info.php:


<?php
phpinfo();
?>



Now we call that file in a browser (e.g. http://192.168.0.100/info.php):



As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.


6. Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

aptitude search php5

Pick the ones you need and install them like this:

aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-p7s php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:



7. phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it:

aptitude install phpmyadmin

You will see the following questions:

Web server to reconfigure automatically: <-- apache2
Configure database for phpmyadmin with dbconfig-common? <-- No

Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:



8 Links:

Apache: http://httpd.apache.org/
PHP: http://www.php.net/
MySQL: http://www.mysql.com/
Ubuntu: http://www.ubuntu.com/
phpMyAdmin: http://www.phpmyadmin.net/