RSS

Category Archives: Apache2

How to enable GZip compression in XAMPP server

By: TarranJones

When we test our webiste by tools.pingdom.com and we get error:

The following publicly cacheable, compressible resources should have a “Vary: Accept-Encoding” header

 

Find apache\conf\httpd.conf

uncomment the following line(remove #)

LoadModule headers_module modules/mod_deflate.so

some versions may require you to comment out the following lines instead.

LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so

finally add this line to your .htaccess file.

SetOutputFilter DEFLATE

Copy from: http://stackoverflow.com/questions/6993320/how-to-enable-gzip-compression-in-xampp-server

Advertisements
 
Leave a comment

Posted by on August 1, 2016 in XAMPP

 

Install mod_deflate in Ubunut Apache 2.2

By: pontikis.net

Installation

In latest Debian version (Debian 6 or Squeeze), mod_deflate is installed and enabled. If not:

a2enmod deflate
service apache2 restart
Edit website configutation file, for example:
nano /etc/apache2/sites-available/www.pontikis.net
add the following lines:
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Explanation of above Apache directives:

  • Line 1: Enable gzip compression
  • Line 2: Do not compress images
  • Line 3: Do not compress already compressed files
  • Line 4: Do not compress pdf
  • Line 6-8: Some exceptions for old browsers

That’s all. Don’t forget to restart Apache.

As an alternative, you can use an .htaccess file in your webroot directory (with the same Apache directives).

 
Leave a comment

Posted by on July 30, 2015 in Apache2, Application Server

 

Change www path in Apache2 Ubuntu

By: Apache Ubuntu

To create a new site:

  • Copy the default website as a starting point. sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.conf 

  • Edit the new configuration file in a text editor “sudo nano” on the command line or “gksudo gedit”, for example:gksudo gedit /etc/apache2/sites-available/mysite.conf

  • Change the DocumentRoot to point to the new location. For example, /home/user/public_html/

  • In the file: /etc/apache2/apache2.conf, change the Directory directive, replace <Directory /var/www/> to<Directory /home/user/public_html/>

  • You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites

  • Save the file

Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enablesite) and a2dissite (apache2disable site).

$ sudo a2dissite 000-default && sudo a2ensite mysite

Finally, we restart Apache2:

$ sudo /etc/init.d/apache2 restart

If you have not created /home/user/public_html/, you will receive an warning message

Copy from: https://help.ubuntu.com/community/ApacheMySQLPHP

 
Leave a comment

Posted by on May 22, 2015 in Apache2, Linux, Ubuntu

 

Error 500 and 404 when using .htaccess for removing index.php

By: Sochinda

Enable mod_rewrite in apache

  1. Enable ReWrite mode in Apache2
    $ sudo a2enmod rewrite
    $ sudo service apache2 restart
  2. Edit site-enable configuration
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    </Directory>
    
  3. Add .htaccess
    Options +FollowSymLinks
    IndexIgnore */*
    
    <IfModule mod_rewrite.c>
     RewriteEngine on
    
     #RewriteBase /
    
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
    
     RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
    
    </IfModule>
  4. Restart Apache2 Service
 
Leave a comment

Posted by on May 19, 2015 in Apache2, Yii

 

Install Apache + PHP + MySQL in Ubunut

We can Install Apache, PHP and MySQL in Ubuntu 3 types as bellow:

  1. When install Ubuntu Screen, please select ( [x] LAMP SERVER)
  2. Go to terminal :
    sudo apt-get install lamp-server^
  3. Install all application one by one as:

 

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:

apt-get 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:

apt-get install apache2

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

Click to enlarge

 

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:

apt-get 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

<?php
phpinfo();
?>

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

Click to enlarge

 

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:

apt-cache search php5

Pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Now restart Apache2:

/etc/init.d/apache2 restart

Xcache is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It’s similar to other PHP opcode cachers, such as eAccelerator and APC. It is strongly recommended to have one of these installed to speed up your PHP page.

Xcache can be installed as follows:

apt-get install php5-xcache

Now restart Apache:

/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:

Click to enlarge

 

 

7 phpMyAdmin

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

apt-get 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/:

Reference by:

http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-ubuntu-13.04-lamp

http://www.liberiangeek.net/2013/05/want-lamp-linux-apache-mysql-in-ubuntu-13-04/

 
Leave a comment

Posted by on January 24, 2014 in Apache2, MySQL Server, PHP, Ubuntu

 

Config ISCSI Drive to Local Drive in Ubuntu for Fixed 403 when you change Document Root in Apache2

By Sochinda,

When you connect iscsi initiator that using open-iscsi already in to your server you will get drive as:

/media/root/drivename

***root: is a user name that you have connected to iscsi

and when you change Document Root in Apache2 to that drive, you will got 403 Error.

For fix this error:

sudo umount /dev/sda3
mkdir /media/DriveD
sudo ntfs-3g /dev/sda3 /media/DriveD

Finally, you can use /media/DriveD instead /media/root/drivename

 
Leave a comment

Posted by on January 15, 2014 in Apache2, Ubuntu

 

can’t open etc apache2 envvars ubuntu

run the following command first

sudo apt-get remove --purge apache2 apache2-utils

then run

sudo apt-get install apache2

it worked for me

 
Leave a comment

Posted by on January 13, 2014 in Apache2