[WebServer] Install Webserver Apache in Linux (Debian)

Description
        this tutorial i will teach you how to install webserver (apache) , mysql & postgresql, and php5 in linux (in case i use debian)


HowTo
 1. Before install we must think, how to get all package we need. in linux you can download it (by clicking in web) or use command. but this case we use command (because it's simple).

now get all package by type this command :

apt-get update     // get list all repository

php5 package :
apt-get install php5   
apt-get install libapache2-mod-php5
apt-get install php5-mcrypt
apt-get install php-pear
apt-get install php5-mysql      //ext for mysql
apt-get install php5-pgsql       //ext for postgresql

apache2 package
apt-get install apache2

postgresql package
apt-get install postgresql

postgresql GUI package
apt-get install phppgadmin
// you can access : http://localhost/phppgadmin 

mysql package
apt-get install mysql-server

phpmyadmin package
apt-get install phpmyadmin
// you can access : http://localhost/phpmyadmin  



2. Assume all package already installed, now you can setup them.

Apache2 :
control path : /etc/init.d/apache2 [start/stop]    // for start/stop service
setting conf : /etc/apache2/apache2.conf 

add this line in setting conf : 
Include /etc/phpmyadmin/apache.conf
Include /etc/apache2/mods-enabled/*.load 
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/ports.conf 
Include /etc/apache2/conf.d/[^.#]* 
Include /etc/apache2/sites-enabled/[^.#]*

php5 :
setting conf : /etc/php5/apache2/php.ini

Postgresql :
control path : /etc/init.d/postgresql [start/stop]   // for start/stop service
first time run :
 > su postgres
 > createuser -P // root must be the first user
 > role name : root
 > password : yourpassword
 > superuser : yes
after finish , you can create another use.
for access you can goto : http://localhost/phppgadmin 

Mysql :
control path : /etc/init.d/mysql [start/stop]   // for start/stop service
for access you can goto : http://localhost/pupmyadmin 

if you have another method or other configuration , just comment it. if it's important i will update this article.

hope this solve your problem.

[WebServer] Enable SSL on Apache - Self Signed

Description
i am not the author of this article, but it's important that web not only develop develop and develop, but we must thinking about security.

Original Author : Bob Silverberg

Original Articel : Enable SSL

How to 

Step 1 - What You Need

  • A copy of Apache that includes SSL support.
  • A copy of OpenSSL.
  • An openssl.cnf file.
The copy of Apache that I had installed on my machine did not include SSL support, so I moseyed on down to the Apache download page. You'll notice on that page that there are files named something like apache_2.2.11-win32-x86-openssl-0.9.8i.msi, as well as files named something likeapache_2.2.11-win32-x86-no_ssl.msi. You need to have the openssl version installed, not the no_sslversion (duh). I couldn't find any reliable info on manually adding SSL support to a no_ssl install, so I simply downloaded the most up-to-date version of the openssl installer and ran it. It successfully upgraded my version of Apache without overwriting any of my existing config files.
The nice thing about that installer is that it includes a copy of OpenSSL, so you don't need to download that separately.
Finally, you need an openssl.cnf file, which doesn't come with the package. I downloaded one that works from Neil's site. If that link is broken you can find a copy attached to this blog post. I have Apache installed in C:\Apache\, which means that I can find OpenSSL in C:\Apache\bin\, so I copied the openssl.cnf file into that directory.

Step 2 - Create a Self-Signed Certificate

This step will create a number of files related to your certificate. Each of those files has the same name, with a different extension. In the example commands below I've used the name bob. Feel free to replace that with anything you like.
Open a command prompt and switch to the directory that contains OpenSSL (C:\Apache\bin\, in my case). To create a new certificate request type the following:

1openssl req -config openssl.cnf -new -out bob.csr -keyout bob.pem
You'll be prompted to answer a bunch of questions, the answers to which can all be left blank except for:
  • PEM pass phrase: This is the password associated with the private key (bob.pem) that you're generating. This will only be used in the next step, so make it anything you like, but don't forget it.
  • Common Name: This should be the fully-qualified domain name associated with this certificate. I was creating a certificate for a site on my local machine which I browsed to via http://savacms/, so I just entered savacms. If I was creating a cert for my blog I would have entered www.silverwareconsulting.com.
When the command completes you should have a two files called bob.csr and bob.pem in your folder.
Now we need to create a non-password protected key for Apache to use:

1openssl rsa -in bob.pem -out bob.key
You'll be prompted for the password that you created above, after which a file called bob.key should appear in your folder.
Finally, we need to create an X.509 certificate, which Apache also requires:

1openssl x509 -in bob.csr -out bob.cert -req -signkey bob.key -days 365
And that's it - you now have a self-signed certificate that Apache can use to enable SSL. I chose to move the required files from C:\Apache\bin\ to C:\Apache\conf\ssl\, but you can put them anywhere as you'll be pointing to them in your Apache config files.

Step 3 - Enable SSL on Apache

Open your httpd.conf file (which for me is in C:\Apache\conf\) and uncomment (remove the # sign) the following lines:
  • #LoadModule ssl_module modules/mod_ssl.so
  • #Include conf/extra/httpd-ssl.conf
Open your httpd-ssl.conf file (which for me is in C:\Apache\conf\extra\) and update the section entitled <VirtualHost _default_:443>. You'll need to update the values of ServerAdmin,DocumentRootServerNameErrorLog and CustomLog to match your environment. You'll also need to point SSLCertificateFile to your .cert file and SSLCertificateKeyFile to your .key file.
Restart Apache and browse to https://localhost/. You're now accessing your Apache server over SSL!

Step 4 - Create a VirtualHost Entry for Your Site

If you're like me, you're running Apache because you want to run multiple sites on your local machine. In that case you undoubtedly have multiple <VirtualHost> entries in your httpd-vhosts.conf file. In order to access a particular site via SSL, you need to add an additional <VirtualHost> entry for it. To illustrate I'll show you an existing <VirtualHost> entry that I have, and then the new <VirtualHost> that I created to allow me to access that site via SSL. Here's the original entry:

1<VirtualHost *:80>
2ServerAdmin bob.silverberg@gmail.com
3DocumentRoot C:/wwwroot/savaCMS
4ServerName savaCMS
5DirectoryIndex index.html, index.cfm
6ErrorLog logs/savaCMS-error_log
7CustomLog logs/savaCMS-access_log common
8<Directory C:/wwwroot/savaCMS>
9Options All
10AllowOverride All
11</Directory>
12</VirtualHost>
And here's the additional entry that I added:

1<VirtualHost *:443>
2SSLEngine on
3SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
4SSLCertificateFile "C:/Apache/conf/ssl/savacms.cert"
5SSLCertificateKeyFile "C:/Apache/conf/ssl/savacms.key"
6ServerAdmin bob.silverberg@gmail.com
7DocumentRoot C:/wwwroot/savaCMS
8ServerName savaCMS
9DirectoryIndex index.html, index.cfm
10ErrorLog logs/savaCMS-error_log
11CustomLog logs/savaCMS-access_log common
12<Directory C:/wwwroot/savaCMS>
13Options All
14AllowOverride All
15</Directory>
16</VirtualHost>
I can now browse to http://savaCMS/ as well as https://savaCMS/! Hopefully these instructions will be found by the next person who chooses to attempt this.

my comment : Holy shittttt great article saving my hours, thanks bob :D

if you need another reference here's the link


[WebServer][Apache] Understanding Virtual Host

Deskripsi
      Virtual Host dalam webserver apache merupakan suatu metode agar dalam satu host mampu melayani penggunaan banyak nama domain. sebagai contoh :

anda punya server host dengan IP : 192.168.0.2

system operasi win / linux dengan lokasi home dir : htdocs/myweb (windows) atau  /var/www/myweb (linux)
domain anda : keren.com (contoh doank, bukan punya gw)

kemudian teman anda menyewa home dir anda : htdocs/myfriend(windows) atau  /var/www/myfriend (linux)

domain teman anda : teman.com  (contoh doank, bukan punya gw)

bagaimana dalam 1 IP bisa dibinding oleh 2 domain yang berbeda dan mampu mengenali masing-masing folder ? itulah gunanya virtual host


caranya ?? tinggal tambahkan settingan pada confignya , untuk kali ini saya menggunakan apache.


HowTo


1. temukan file httpd.conf, dalam direktory webserver anda

2. hapus tanda '#' pada "Include conf/extra/httpd-vhosts.conf'
3. temukan file httpd-vhosts.conf
4. tambahkan line baru seperti dibawah ini (terserah mau ditaruh di-line mana aja bebas kok)

# Ensure that Apache listens on port 80

Listen 80

# Listen for virtual host requests on all IP addresses

NameVirtualHost *:80

<VirtualHost *:80>                             

    ServerName localhost                       
    DocumentRoot "C:\wamp\www"                 
</VirtualHost>                                 

# Setup "helloworld" Virtual Host              

<VirtualHost *:80>                             
    ServerName "infophpku.xla"                 
    DocumentRoot "C:\wamp\VirtualFolder"       

    <Directory "C:\wamp\VirtualFolder">        

        Options Indexes FollowSymLinks Includes
        AllowOverride All                      
        Order allow,deny                       
        Allow from all                         
    </Directory>                               
</VirtualHost>                                 

5. buat folder baru (untuk virtual host, contoh nama foldernya VirtualFolder) pada path , hasilnya nanti seperti ini : "C:\wamp\VirtualFolder"

6. konfigurasikan file hosts, untuk windows lokasi file host di c:\windows\system32\drivers\etc\
7. buka file tersebut maka anda akan melihat format seperti ini :
    127.0.0.1       localhost
8. fungsinya mapping IP address secara lokal, jadi jika tcp ip mendapatkan masukan nama domain 'localhost' maka akan didirect IP : 127.0.0.1, nama domain 'localhost' akan tersimpan dalam header protokol http yang berguna bagi apache dalam penggunaan virtualhost.
9. pada file host tambahkan line :
    127.0.0.1      infophpku.xla 
    artinya jika kita mengakses nama domain infophpku.xla maka akan didirect ke ip 127.0.0.1 , berarti masuk localhost ? iya memang masuk localhost tapi mempunyai header yang beda yang nanti akan diproses otomatis oleh apache.
10. Restar apache, dan ketikan URL infophpku.xla  pada browser, tapi settingan browser jangan dimasukan ke proxy :)

-- Fix and Test by me --