After Redhat/Centos come to Debian, hey where are all my known commands,apps and files ….. Round2

Round 2, need to be install ngix and apache together and side effects (sorry this is very long article,pls do not lost inside)

Need to be check the apt index means repository update, second one show the which software have a update

apt-get update

apt-get upgrade –show-upgraded

apt-get -u upgrade (this command also have same result like –show-upgraded)

To see whats inside repository pls execute such command like below with what you would like to search

apt-cache search apache | less

Now switch to better command then apt-get🙂 its another api use apt-get http://wiki.debian.org/Aptitude

root@WebApp02:~# aptitude search apache2-mpm

v apache2-mpm –
p apache2-mpm-event – Apache HTTP Server – event driven model
p apache2-mpm-itk – multiuser MPM for Apache 2.2
p apache2-mpm-prefork – Apache HTTP Server – traditional non-threaded model
p apache2-mpm-worker – Apache HTTP Server – high speed threaded model

if you see any <i< on first column instead of <p< then its means that related software already installed

apache2ctl -l

the command on the top is another way to understand core files which apache compiled

I’m installing apache-mpm-event software, for worker or pre fork replace after mpm- with required one …
Be aware that if you are using event or worker you can not install php5 later🙂 heheh you should install php fast cgi because of compatibility between php5 software and apache-mpm, actually  you can install but package manager apt will remove event or worker one and install pre fork when you install the php5 not php fast cgi

root@WebApp02:~# aptitude install apache2-mpm-event

The following NEW packages will be installed:

apache2-mpm-event apache2-utils{a} apache2.2-bin{a} apache2.2-common{a} libapr1{a} libaprutil1{a}

libaprutil1-dbd-sqlite3{a} libaprutil1-ldap{a} ssl-cert{a}

0 packages upgraded, 9 newly installed, 0 to remove and 0 not upgraded.

Need to get 2,170 kB of archives. After unpacking 7,385 kB will be used.

Do you want to continue? [Y/n/?] y

installed and running, very fast to me😀

Apache config files are under /etc/apache2, very interesting for me because i’m very familiar apache on redhat/centos almost one file and go but okay, go
i found some new folders like site-enabled or site-available, meanings ? find good explanation from this link http://www.debian-administration.org/articles/207

This is from end of the apache2.conf

# Include the virtual host configurations: Include sites-enabled/

This is the folder inside, all request redirected to default site , but we will change it shortly

root@WebApp02:/etc/apache2# cd sites-enabled/
root@WebApp02:/etc/apache2/sites-enabled# ls -al total
8 drwxr-xr-x 2 root root 4096 Sep 3 00:25 .
drwxr-xr-x 7 root root 4096 Sep 3 00:34 ..
lrwxrwxrwx 1 root root 26 Sep 3 00:25 000-default -> ../sites-available/default

Before installation of ngix i went to ports.conf and 000-default files , on ports.conf changed listen and NameVirtualHost to 8080, and same on 000-default
Restarted apache2 with /etc/init.d/apache2 stop and /etc/init.d/apache2 start and i can access the working page with server ip and port 8080

For nginx, no any result when i search it

root@WebApp02:~# aptitude search ngix
root@WebApp02:~#

i need to learn Debian version, pls expect that i don’t know what version of installed, very closer file on Debain like Redhat heheheh

root@WebApp02:~# cat /etc/debian_version
6.0.5

Add such lines in apt repo source file , first edit it

root@WebApp02:~# vi /etc/apt/sources.list

second add such lines and save the file

## For Ngix
deb http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx

Related Nginx repo need to be update with apt-get update but you will get an error to fix it do like below

root@WebApp02:~# gpg –keyserver keyserver.ubuntu.com –recv-key ABF5BD827BD9BF62
gpg: requesting key 7BD9BF62 from hkp server keyserver.ubuntu.com
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 7BD9BF62: public key “nginx signing key <signing-key@nginx.com>” imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)

root@WebApp02:~# gpg -a –export ABF5BD827BD9BF62 | apt-key add – OK

if you don’t know what is gig pls read this http://www.gnupg.org/

You got it !

root@WebApp02:~# aptitude search nginx p nginx – HTTP and reverse proxy server, as well as a mail proxy server p nginx-common – small, powerful, scalable web/proxy server – common files p nginx-dbg – Debugging symbols for nginx p nginx-debug – not stripped version of nginx build with the debugging log p nginx-doc – small, powerful, scalable web/proxy server – documentation p nginx-extras – nginx web/proxy server (extended version) p nginx-extras-dbg – nginx web/proxy server (extended version) – debugging symbols p nginx-full – nginx web/proxy server (standard version) p nginx-full-dbg – nginx web/proxy server (standard version) – debugging symbols p nginx-light – nginx web/proxy server (basic version) p nginx-light-dbg – nginx web/proxy server (basic version) – debugging symbols p nginx-naxsi – nginx web/proxy server (version with naxsi) p nginx-naxsi-dbg – nginx web/proxy server (version with naxsi) – debugging symbols p nginx-naxsi-ui – nginx web/proxy server – naxsi configuration front-end

You will see that nginx is on list🙂, go install it, after install nginx will run with default configuration

root@WebApp02:~# apt-get install nginx

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following NEW packages will be installed:

nginx

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 483 kB of archives.

After this operation, 1,061 kB of additional disk space will be used.

Get:1 http://nginx.org/packages/debian/ squeeze/nginx nginx amd64 1.2.3-1~squeeze [483 kB]

Fetched 483 kB in 2s (177 kB/s)

Selecting previously deselected package nginx.

(Reading database … 34219 files and directories currently installed.)

Unpacking nginx (from …/nginx_1.2.3-1~squeeze_amd64.deb) …

———————————————————————-

Thanks for using NGINX!

Check out our community web site:

* http://nginx.org/en/support.html

If you have questions about commercial support for NGINX please visit:

* http://www.nginx.com/support.html

———————————————————————-

Setting up nginx (1.2.3-1~squeeze) …

Check the processes, you should see the nginx processes

root@WebApp02:~# ps -fe

root 12253 1 0 01:12 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 12254 12253 0 01:12 ? 00:00:00 nginx: worker process
root 12255 10647 0 01:14 pts/3 00:00:00 ps -fe

See whats listening

root@WebApp02:~# netstat -an

Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:54476 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 213.155.101.195:22 212.58.13.11:59474 ESTABLISHED tcp 0 0 213.155.101.195:22 212.58.13.11:60528 ESTABLISHED tcp 0 0 213.155.101.195:22 212.58.13.11:64825 ESTABLISHED tcp6 0 0 :::8080 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN udp 0 0 0.0.0.0:38324 0.0.0.0:* udp 0 0 0.0.0.0:111 0.0.0.0:* udp 0 0 0.0.0.0:654 0.0.0.0:*

After request you will see that nginx is working , okay back to the apache again

Install php scripting language and module for apache2 modules(do not execute something before read next paragraph )

root@WebApp02:~# aptitude install php5 libapache2-mod-php5

This installation will inform you to remove mpm-event and install mpm-prefork, if you want to use mpm-event use fastcgi instead of mod-php5

After i install all i saw that i need more new version php then installed , on centos we generally use atomic, need to be learn same thing available on debian or not. Of course, some guys working on it for example i used http://www.dotdeb.org/

From this link you can get related lines need to be added apt source list http://www.dotdeb.org/instructions/
Very import an pls read the dot deb before install because maybe you should not install php5 before add dot deb repo, on my installation i do not have a chance but its worked.
My colleague Salih said that another possibility too, maybe you can need https://launchpad.net/~ondrej/+archive/php5

How i told you if you installed php5 before add dot deb to source list debian package manager do not upgrade the php5 to last version or what dot deb provide
Here need to be use different command which is below . Read the change log installation time very important for developers of site also because of compatibility issue  read what will be removed. From change log you can quit with type <q< key (hope i remember well,sorry)

root@WebApp02:~# apt-get dist-upgrade

Reading package lists… Done

Building dependency tree

Reading state information… Done

Calculating upgrade… Done

The following packages will be REMOVED:

php5-suhosin

The following packages will be upgraded:

libapache2-mod-php5 php5 php5-cli php5-common php5-mysql

5 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.

Need to get 6,158 kB of archives.

After this operation, 1,079 kB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://packages.dotdeb.org/ squeeze-php54/all php5-cli amd64 5.4.6-1~dotdeb.0 [2,695 kB]

Get:2 http://packages.dotdeb.org/ squeeze-php54/all php5-mysql amd64 5.4.6-1~dotdeb.0 [79.6 kB]

Get:3 http://packages.dotdeb.org/ squeeze-php54/all libapache2-mod-php5 amd64 5.4.6-1~dotdeb.0 [2,802 kB]

Get:4 http://packages.dotdeb.org/ squeeze-php54/all php5-common amd64 5.4.6-1~dotdeb.0 [580 kB]

Get:5 http://packages.dotdeb.org/ squeeze-php54/all php5 all 5.4.6-1~dotdeb.0 [1,012 B]

Fetched 6,158 kB in 8s (716 kB/s)

Reading changelogs… Done

You can add mysql client support on php5

root@WebApp02:~# apt-get install php5-mysql

Now,remove the old default redirection

root@WebApp02:~# a2dissite default
Site default disabled.
Run ‘/etc/init.d/apache2 reload’ to activate new configuration!

root@WebApp02:~# /etc/init.d/apache2 reload
Reloading web server config: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName
[Mon Sep 03 17:55:55 2012] [warn] NameVirtualHost *:8080 has no VirtualHosts
.

Do you remember default000, its gone

root@WebApp02:/etc/apache2/sites-enabled# ls -al
total 8
drwxr-xr-x 2 root root 4096 Sep 3 17:55 .
drwxr-xr-x 7 root root 4096 Sep 3 00:51 ..

Go to /etc/apache2/sites-available folder and create a file name with what domain you will host, for example example.net

<VirtualHost *:8080>

ServerAdmin webmaster@example.net

ServerName example.net

ServerAlias http://www.example.net

DocumentRoot /srv/www/example.net/public_html/

ErrorLog /srv/www/example.net/logs/error.log

CustomLog /srv/www/example.net/logs/access.log combined

</VirtualHost>

Create related folders

mkdir -p /srv/www/example.net/public_html

mkdir /srv/www/example.net/logs

Enable domain for hosting , execute such line on console

a2ensite example.net

and restart apache , for test upload your test content in related folder

One note to you, i couldn’t find out module and php handlers informations, i feel like junior , go to /etc/apache2/mods-enabled folder , .load files what red hat/centos users familiar in httpd.conf module loads rows , confs are again configs for such modules for example after install php5.conf you will see the handlers.

root@WebApp02:/etc/apache2# cd mods-enabled/

root@WebApp02:/etc/apache2/mods-enabled# ls -al

total 8

drwxr-xr-x 2 root root 4096 Sep  3 22:55 .

drwxr-xr-x 7 root root 4096 Sep  3 23:23 ..

lrwxrwxrwx 1 root root   28 Sep  3 00:25 alias.conf -> ../mods-available/alias.conf

lrwxrwxrwx 1 root root   28 Sep  3 00:25 alias.load -> ../mods-available/alias.load

lrwxrwxrwx 1 root root   33 Sep  3 00:25 auth_basic.load -> ../mods-available/auth_basic.load

lrwxrwxrwx 1 root root   33 Sep  3 00:25 authn_file.load -> ../mods-available/authn_file.load

lrwxrwxrwx 1 root root   36 Sep  3 00:25 authz_default.load -> ../mods-available/authz_default.load

lrwxrwxrwx 1 root root   38 Sep  3 00:25 authz_groupfile.load -> ../mods-available/authz_groupfile.load

Last thing, configure nginx quickly and without complex config , go to /etc/nginx/conf.d , copy the content of default somewhere and replace it with below and restart nginx service , thats it everything should be work

server {

listen 80;

server_name _;

proxy_set_header Host $http_host;

proxy_set_header  X-Real-IP  $remote_addr;

proxy_connect_timeout 6000;

location ~ .+$ {

proxy_set_header  X-Real-IP  $remote_addr;

proxy_set_header Host $http_host;

proxy_pass   http://127.0.0.1:8080;

}

}

Good Links

http://articles.slicehost.com/2010/5/20/configuring-the-apache-mpm-on-debian
http://kb.parallels.com/en/113007
http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-debian-lenny-lamp (LAMP)
http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-lenny (Fast-Cgi)
http://www.hardened-php.net/suhosin/

Posted on 05/09/2012, in Linux and tagged , , , , , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: