THE IT IDEAS

  • Home
Showing posts with label apache2. Show all posts
Showing posts with label apache2. Show all posts

Thursday, 30 April 2015

How to run a simple PHP web server

 THE IT IDEAS     13:12     apache2, php   

# php -S localhost:8000 -t /path/to/folder/directory

Above command give output like below

PHP 5.6.4-4ubuntu6 Development Server started at Thu Apr 30 15:10:00 2015
Listening on http://localhost:8000
Document root is /var/www/html
Press Ctrl-C to quit.


Now you can open the localhost:8000 in your browser to check the webpage.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Tuesday, 21 April 2015

Use PHP5-FPM with Apache 2 on Ubuntu 14.04

 THE IT IDEAS     17:27     apache2, php5-fpm   

Install Apache by following command

    #sudo apt-get update
    #sudo apt-get install apache2-mpm-event

To use PHP5-FPM with Apache, we need to install libapache2-mod-fastcgi module. The libapache2-mod-fastcgi module is not available in the Ubuntu package. Therefore, we need to update the apt sources. Follow these steps.

    Run the following command to edit the source list:

    #sudo nano /etc/apt/sources.list

    Add the following lines at the end of the file:

    deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

   
    Save and Close this file.


Install libapache2-mod-fastcgi Module


    #sudo apt-get update
    #sudo apt-get install libapache2-mod-fastcgi

 

Install PHP5-FPM with the following command

    #sudo apt-get install php5-fpm


Create the PHP5-FPM configuration file for Apache

    #sudo nano /etc/apache2/conf-available/php5-fpm.conf

... then add the following lines

    <IfModule mod_fastcgi.c>
    AddHandler php5-fcgi .php
    Action php5-fcgi /php5-fcgi
    Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
    FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -idle-timeout 900 -socket /var/run/php5-fpm.sock -pass-header Authorization
    <Directory /usr/lib/cgi-bin>
        Require all granted
    </Directory>

    </IfModule>

Save and Close this file.


Enable the new modules and configuration for Apache

    #sudo a2enmod actions fastcgi alias
    #sudo a2enconf php5-fpm

Finally, restart Apache

    #sudo service apache2 restart

 


Use PHP5-FPM with Apache 2 on Ubuntu 14.04

    #sudo nano /var/www/html/info.php

Add the following content to the file

    <?php phpinfo(); ?>

Save and Close this file.

Now open the http://localhost/info.php in browser. Upon success, you will see information about PHP and your server. Your setup is now complete.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Tuesday, 9 December 2014

Install MongoDB php driver in XAMPP/LAMPP

 THE IT IDEAS     15:57     apache2, mongodb   

To install the php driver for MongoDB

Prerequisite ::

#sudo apt-get install autoconf
#export PHP_AUTOCONF=/usr/bin/autoconf
#sudo apt-get install gcc
#sudo apt-get install make

Installing mondodb phpdriver

#sudo /opt/lampp/bin/pecl install mongo
It will download and installing mongo php driver and given message as below


Build process completed successfully
Installing '/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/mongo.so'
install ok: channel://pecl.php.net/mongo-1.5.8
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini


Now, Just add below mentioned line into php.ini file.

extension=mongo.so

and restart the lampp

#sudo /opt/lampp/lampp restart
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Wednesday, 3 December 2014

How to redirect HTTP to HTTPS

 THE IT IDEAS     11:50     apache2   

First you need to install SSL Certificate Successfully. Once your done that choose any of example to do redirect url.

Example : 1

In this example you don't need mod rewrite module to be enabled.

Open your apache configuration file 

#nano /etc/apache2/sites-enabled/000-default.conf

Modify your VirtualHost Tag as followed 

<VirtualHost *:80>
    ServerName www.example.com (your domain name)
    Redirect / https://www.example.com/
</VirtualHost>

Save and exit. Restart apache service once
#service apache2 restart

Check your domain url with http it will redirect automatically on HTTPS.


Example : 2

In this Example you have to enable mod rewrite module first with below command

#a2enmod rewrite

Now, Copy below code in your .htaccess file without any changes on beginning of .htaccess file.


# BEGIN REWRITE SITEWIDE HTTP TO HTTPS

# This will enable the Rewrite capabilities
RewriteEngine On

# This checks to make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on

# This rule will redirect users from their original location, to the same location but using HTTPS.
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

# END REWRITE SITEWIDE HTTP TO HTTPS

Save and exit from file.

Now open your apache configuration file and make mentioned changes in your file.

1) "AccessFileName .htaccess" tag should be open.

2) Check Directory tag and change "AllowOverride None" to "AllowOverride All"

e.g.

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Save and exit the file.

Restart Apache service once

#service apache2 restart


All Done Check now !!!




Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to Create VirtualHost in Apache 2.4

 THE IT IDEAS     10:53     apache2   

Install Apache2 with below command.

#sudo apt-get install Apache2

Create Demo VirtualHost Directory

#sudo mkdir -p /var/www/html/example.com
#sudo mkdir -p /var/www/html/theitideas.com

Create Demo Pages for Each Virtual Host

#nano /var/www/html/example.com/index.html

Paste Below code in index.html file

<html>
  <head>
    <title>Welcome to Example.com!</title>
  </head>
  <body>
    <h1>It works!  Example.com</h1>
  </body>
</html>

Save the file and exit.

Now for theitideas.com

#nano /var/www/html/theitideas.com/index.html

Paste Below code in index.html file

<html>
  <head>
    <title>Welcome to theitideas.com!</title>
  </head>
  <body>
    <h1>It works!  theitideas.com</h1>
  </body>
</html>

Save the file and exit.



Now Create the First Virtual Host File

#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

Edit the file with below command and edit file as mentioned below.

#sudo nano /etc/apache2/sites-available/example.com.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/html/example.com
</VirtualHost>

Again to the same process for theitideas.com VH.

#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/theitideas.com.conf

Edit the file with below command and edit file as mentioned below.

#sudo nano /etc/apache2/sites-available/theitideas.com.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName theitideas.com
        ServerAlias www.theitideas.com
        DocumentRoot /var/www/html/theitideas.com
</VirtualHost>


Now Turn to enable both Virtual Host 

#sudo a2ensite theitideas.com.conf
#sudo a2ensite theitideas.com.conf

Restart Apache Service

#sudo service apache2 restart
or
#sudo /etc/init.d/apache2 restart

Virtual Host is set in apache server. Now you have to make changes in your machine to check Virtual Machine.

#sudo nano /etc/hosts

Add line in you hosts file.

your IP example.com
your IP theitideas.com

e.g. 
192.168.0.101  example.com
192.168.0.101  theitideas.com


Save and exit. Now Open your browser and open example.com and theitideas.com

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Monday, 24 November 2014

How to change DocumentRoot path in Apache Ubuntu 14.04 LTS

 THE IT IDEAS     11:21     apache2, DocumentRoot change, ubuntu   

Make backup copy of Apache default file with below command

#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf.bak

Edit 000-default.conf file to give DocumentRoot path

#sudo nano /etc/apache2/sites-available/000-default.conf

and change the following line with you new path:

DocumentRoot /var/www/html    (Default Line)


To


DocumentRoot /mywebsite   (Your website path)

after make changes in this file. Save and Close 000-default.conf file.

Now, Open apache.conf file and change the DocumentRoot path here as well.

#sudo nano /etc/apache2/apache2.conf

and find this

<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

and change /var/www/html to your preferred directory and save it.

After made changes in both files, just restart the apache2 webserver.

Use below command to restart apache server.
#sudo service apache2 restart
OR
#sudo /etc/init.d/apache2 restart



If you will receive permission error check the user of apache and give the permission.

To check user of apache run below command.

#ps aux | grep apache

Above command will show like this.





Then run below command to give permission.

#sudo chown -R $USER:$USER /mywebsite             

The $USER variable will take the value of the user you are currently logged in

Give permission to folder with below command
#sudo chmod -R 755 /mywebsite
Now restart the webserver.

#sudo service apache2 restart
OR
#sudo /etc/init.d/apache2 restart


Check Now !!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Older Posts Home

Like Us !!!

Recent Posts

Blog Archive

  • ▼  2016 (1)
    • ▼  April (1)
      • How to Install PHP 7.0, Apache 2.4.18, & MySQL 5.7...
  • ►  2015 (12)
    • ►  August (1)
    • ►  May (2)
    • ►  April (8)
    • ►  March (1)
  • ►  2014 (23)
    • ►  December (8)
    • ►  November (12)
    • ►  April (2)
    • ►  March (1)
  • ►  2013 (7)
    • ►  December (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (3)
  • ►  2012 (15)
    • ►  December (6)
    • ►  November (9)

Categories

apache2 EC2 error mysql php ubuntu aws aws rds browser github installation linux mount s3 AWS Bucket CentOS Computer DocumentRoot change How to Benchmarking Webserver IP LAMP Restart Computer SCP command SQL SERVER XRDP administrator amazon rds backup basic commands chat command line disable download drupal ec2.chroot environment external storage device fstab functions geoip gmail google home page iis instance internet java mod rewrite mongodb multiple login network password one password php5 php5-fpm php7 private browsing python repair filesystem repo reset password rhel sa password same computer script sftp share skype ssh tomcat ubuntu 16.04 ubuntu16 visudo windows 8 youtube
JobsMagBlogJobsMag.InThingsGuide

Popular Posts

  • PDOException: SQLSTATE[42000]: 1148 The used command is not allowed with this MySQL version in AWS RDS
    To Resolve this error you have to connect mysql with below command then you can able to run LOCAL INFILE command in mysql console or drupal...
  • How to make Google Chrome Theme
    Open Google Chrome and open Chrome web store and search my chrome theme Click on Add to Chrome     Click on Add to downloadi...
  • How to disable Username and Password in Network pc
    1. Click Start 2. Control Panel 3. Network and Internet 4. Network and Sharing Center 5. Click Choose homegroup and sharing options...

Copyright © THE IT IDEAS | Powered by Blogger