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

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/

Install JDK 6 update 23 in Ubuntu 10.10




JDK (Java Development Kit) is a software that provides development tools for creating Java programs.

Installation


First we must download the package from the java website, select your platform, in our case Linux:



http://www.oracle.com/technetwork/java/javase/downloads/index.html

Here we go down the file "jdk-6u21-linux-i586.bin" to any folder, then leave where appropriate.

Now we have to give execute permissions:
sudo chmod +x jdk-6u23-linux-i586.bin

and install:
sudo ./jdk-6u23-linux-i586.bin

Now move the generated folder to a more appropriate directory:
sudo mv jdk1.6.0_23/ /usr/local

We set the new Java as one of the alternatives "java"
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/jdk1.6.0_23/bin/java" 1

Now we set the "new alternative" as real Java. This step makes the sun is the version used by default:
sudo update-alternatives --set java /usr/local/jdk1.6.0_23/bin/java

Now we do the same steps above for javac:

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/jdk1.6.0_23/bin/javac" 1
sudo update-alternatives --set javac /usr/local/jdk1.6.0_23/bin/javac



Now verify that everything works properly. Open the console and type:
java -version

If all is well, you should return the following:

java version "1.6.0_23"
Java (TM) SE Runtime Environment (build 1.6.0_23-B06)
Java HotSpot (TM) Client VM (build 17.0-b16, mixed mode, sharing)


For javac:
javac -version

If all is well back:
javac 1.6.0_23

If you have other installations of java / javac can be configured using the following commands:
sudo update-alternatives --config java
sudo update-alternatives --config javac


Also if you want setear JRE_HOME JAVA_HOME or as environment variables, we must go to:
sudo gedit /etc/environment

Here we record the routes where we have installed Java, in our case is as follows:
JAVA_HOME = "/usr/local/jdk1.6.0_23/bin/" (add)
JRE_HOME = "/usr/local/jdk1.6.0_23/jre" (add)
PATH ="...(other routes):$JAVA_HOME:$JRE_HOME (edit)


With this we finish the installation.

Install PostgreSQL 8.4 on Ubuntu 10.10


PostgreSQL is a database management system relational database and object-oriented free, released under the BSD license.


Installation
To install from Ubuntu to run in console the following line:
sudo apt-get install postgresql postgresql-client pgadmin3
This installs the engine and pgadmin3 client, a graphical tool to manage databases.
The next thing is to change the administrator password system PostgreSQL:
sudo passwd postgres
Now we must change the password of "user postgres" on the engine, it first entered with the following line:
psql -h localhost -U postgres -W template1
and then enter the following command:
ALTER USER postgres WITH PASSWORD 'password';
Finally out of postgres, enter the following command:
\q
With this we have installed PostgreSQL. Settings
We set up remote access to our motor. This step is optional, only if you want to allow access to our server from other hosts.
First we edit the file postgresql.conf:
sudo gedit /etc/postgresql/8.4/main/postgresql.conf
Look for the line:
# Listen_addresses = 'localhost'
and change it to:
listen_addresses = '*'
We also look for the following line:
# Password_encryption = on
and change it to:
password_encryption = on
Now we edit the file "pg_hba.conf"
sudo gedit /etc/postgresql/8.4/main/pg_hba.conf
 
Modify the lines:

# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 remote connections:
host    all         all         194.116.73.46/0          md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

We do this to use MD5 authentication with the user postgres.

Finally sent to restart:
sudo /etc/init.d/postgresql-8.4 restart
More information about the configuration: http://www.linux-es.org/node/660

Pgadmin3
The following video shows how to connect to PostgreSQL pgadmin3 and how to use:

Install Tomcat 7 on Ubuntu 12.04




Apache has officially launched version 7.0 of the servlet container for Java applications, Tomcat. Major changes in this version, you can highlight support for Servlet 3.0 and JavaServer Pages 2.2.

Install JDK
See this post: Install JDK 6 update 23 in Ubuntu 10.10

Installation

The first thing to do is download the package "apache-tomcat-7.0.6.tar.gz" from the NEXT link
http://tomcat.apache.org/download-70.cgi [tar.gz]
Now unpack it with the following command:
tar xvzf apache-tomcat-7.0.8.tar.gz

Then we let in a more appropriate directory, in our case in / usr/share/tomcat7, but can be in any directory. We do this with the command:
sudo mv apache-tomcat-7.0.8/ /usr/share/tomcat7

Now we define the environment variables JAVA_HOME and JRE_HOME. This file is in the "environment" in / etc. Command to edit the file:
sudo gedit /etc/environment

Here we record the routes where we have installed Java in my case this is as follows:

JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
PATH="...(other path):$JAVA_HOME:$JRE_HOME"

IMPORTANT: Verify the routes where they have installed Java.

I have had some problems in defining these environment variables, as sometimes tomcat does not recognize, but a surefire way of recognizing that tomcat is to define the file paths inside "catalina.sh"located in tomcat7/bin. To modify this file use the command:
sudo gedit /usr/share/tomcat7/bin/catalina.sh

Now just insert the JAVA_HOME and JRE_HOME after the first line, so the file is as follows:
#!/bin/sh
JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
# Licensed to the Apache Software Foundation (ASF)...
#...
#...
....

Now let's configure Tomcat users, this is done in the file "tomcat-users.xml"directory tomcat7/conf. Command to edit the file:
sudo gedit /usr/share/tomcat7/conf/tomcat-users.xml

Unlike previous versions where the administrator should own role "manager" now it should be "manager-gui"to operate on the web administration tomcat7. The file would be as follows:


<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="admin"/>

<user username="usuario" password="contrasena" roles="manager-gui,admin-gui,manager,admin,manager-script,admin-script"/>
</tomcat-users>



Now you should be all ready to try tomcat7.

First we must lift the server with the following command:
sudo /usr/share/tomcat7/bin/startup.sh

With this we get the following output on console:
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using JRE_HOME: /usr/local/jdk1.6.0_20/jre
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

Verify that the JRE_HOME is where we define.

Now open your web browser and type the following url:
http://127.0.0.1:8080/

So we get the following page:

If we enter the administration Tomcat Manager we click on the menu or directly at URL:
http://127.0.0.1:8080/manager/html

Here we ask the user data from previous record in mind tomcat-users.xml.

I recommend testing the sample to make sure everything works ok, they are in the section "Miscellaneous" from the side menu or at the URL:
http://127.0.0.1:8080/examples/

Commands

Start server:
sudo /usr/share/tomcat7/bin/startup.sh

Stop server:
sudo /usr/share/tomcat7/bin/shutdown.sh

Automatic Starting

To make tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.


sudo gedit /etc/init.d/tomcat7

Now paste in the following:


# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

case $1 in
start)
sh /usr/share/tomcat7/bin/startup.sh
;;
stop)
sh /usr/share/tomcat7/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat7/bin/shutdown.sh
sh /usr/share/tomcat7/bin/startup.sh
;;
esac
exit 0

You’ll need to make the script executable by running the chmod command:


sudo chmod 755 /etc/init.d/tomcat7

The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.


sudo ln -s /etc/init.d/tomcat7 /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat7 /etc/rc2.d/S99tomcat

Tomcat should now be fully installed and operational. Enjoy!

sudo /etc/init.d/tomcat7 restart