Project

General

Profile

Library req » History » Version 29

Refik Hadzialic, 11/16/2011 02:18 PM

1 1 Triatmoko -
h1. Library requirement
2 1 Triatmoko -
3 1 Triatmoko -
h2. Python Library
4 1 Triatmoko -
5 2 Triatmoko -
h3. PJSUA Library
6 1 Triatmoko -
7 1 Triatmoko -
pjsua is an open source command line SIP user agent (softphone) that is used as the reference implementation for PJSIP, PJNATH, and PJMEDIA. Despite its simple command line appearance, it does pack many features!
8 1 Triatmoko -
9 29 Refik Hadzialic
This library is used for the SIP handler. More information about this library can be found on this web site http://www.pjsip.org/pjsua.htm
10 1 Triatmoko -
11 29 Refik Hadzialic
How to use the SIP library and how to install it will be explain here: [[SIP| SIP Handler]]
12 3 Triatmoko -
13 3 Triatmoko -
h3. SSH
14 6 Triatmoko -
15 29 Refik Hadzialic
Secure Shell (SSH) is a network protocol for secure data communication, remote shell services or command execution and other secure network services between two networked computers that it connects via a secure channel over an insecure network: a server (running an SSH server program) and a client (running an SSH client program).[1].
16 6 Triatmoko -
17 29 Refik Hadzialic
Type the following to install it:
18 1 Triatmoko -
<pre>
19 1 Triatmoko -
sudo apt-get install ssh
20 1 Triatmoko -
</pre>
21 1 Triatmoko -
22 29 Refik Hadzialic
We need to configure the ssh connections to the nanoBTS controller boxes without typing the password. We can achieve this by copying the public key to the nanoBTS boxes.
23 29 Refik Hadzialic
24 29 Refik Hadzialic
One has to create first the private and public keys on the local machine(i.e. server computer, where the test software runs):
25 29 Refik Hadzialic
<pre>
26 29 Refik Hadzialic
refik@ubuntu:$ [Note: You are on local-host here]
27 29 Refik Hadzialic
28 29 Refik Hadzialic
refik@ubuntu:$ ssh-keygen
29 29 Refik Hadzialic
Generating public/private rsa key pair.
30 29 Refik Hadzialic
Enter file in which to save the key (/home/refik/.ssh/id_rsa):[Enter key]
31 29 Refik Hadzialic
Enter passphrase (empty for no passphrase): [Press enter key]
32 29 Refik Hadzialic
Enter same passphrase again: [Press enter key]
33 29 Refik Hadzialic
Your identification has been saved in /home/refik/.ssh/id_rsa.
34 29 Refik Hadzialic
Your public key has been saved in /home/refik/.ssh/id_rsa.pub.
35 29 Refik Hadzialic
The key fingerprint is:
36 29 Refik Hadzialic
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 refik@ubuntu
37 29 Refik Hadzialic
</pre>
38 29 Refik Hadzialic
39 29 Refik Hadzialic
Then one needs to copy the public key to the remote machine (nanoBTS controller, i.e. BeagleBoard) using ssh-copy-id:
40 29 Refik Hadzialic
41 29 Refik Hadzialic
<pre>
42 29 Refik Hadzialic
refik@ubuntu:$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
43 29 Refik Hadzialic
refik@remote-host's password:
44 29 Refik Hadzialic
Now try logging into the machine, with "ssh 'remote-host'", and check in:
45 29 Refik Hadzialic
46 29 Refik Hadzialic
.ssh/authorized_keys
47 29 Refik Hadzialic
48 29 Refik Hadzialic
to make sure we haven't added extra keys that you weren't expecting. 
49 29 Refik Hadzialic
</pre>
50 29 Refik Hadzialic
51 29 Refik Hadzialic
After we have created the public and private keys, and coppied the public key on the machine to which we want to connect, we can test if we can make an SSH connection to the remote machine:
52 29 Refik Hadzialic
<pre>
53 29 Refik Hadzialic
refik@ubuntu:$ ssh remote-host
54 29 Refik Hadzialic
[Note: SSH did not ask for password.]
55 29 Refik Hadzialic
56 29 Refik Hadzialic
refik@remote-host:$ [Note: You are on remote-host here]
57 29 Refik Hadzialic
</pre>
58 29 Refik Hadzialic
59 29 Refik Hadzialic
60 29 Refik Hadzialic
61 29 Refik Hadzialic
 by RAMESH NATARAJAN http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/
62 6 Triatmoko -
63 13 Konrad Meier
h3. install easy_install
64 13 Konrad Meier
65 13 Konrad Meier
<pre>
66 13 Konrad Meier
sudo apt-get install python-setuptools python-dev build-essential
67 13 Konrad Meier
</pre>
68 13 Konrad Meier
69 13 Konrad Meier
h3. Setproctitle 
70 3 Triatmoko -
71 5 Triatmoko -
The library allows a process to change its title (as displayed by system tools such as ps and top).
72 5 Triatmoko -
73 5 Triatmoko -
Changing the title is mostly useful in multi-process systems, for example when a master process is forked: changing the children's title allows to identify the task each process is busy with. The technique is used by PostgreSQL and the OpenSSH Server for example.
74 5 Triatmoko -
75 5 Triatmoko -
The procedure is hardly portable across different systems. PostgreSQL provides a good multi-platform implementation: this module is a Python wrapper around PostgreSQL code.
76 5 Triatmoko -
Installation
77 5 Triatmoko -
78 5 Triatmoko -
You can use easy_install to install the module: to perform a system-wide installation use:
79 5 Triatmoko -
80 5 Triatmoko -
<pre>
81 5 Triatmoko -
sudo easy_install setproctitle
82 5 Triatmoko -
</pre>
83 5 Triatmoko -
84 5 Triatmoko -
If you are an unprivileged user or you want to limit installation to a local environment, you can use the command:
85 5 Triatmoko -
86 5 Triatmoko -
<pre>
87 5 Triatmoko -
easy_install -d /target/path setproctitle
88 5 Triatmoko -
</pre>
89 5 Triatmoko -
90 5 Triatmoko -
Notice that easy_install requires /target/path to be in your PYTHONPATH.
91 5 Triatmoko -
92 5 Triatmoko -
Module content
93 5 Triatmoko -
94 5 Triatmoko -
The module exports the following functions:
95 5 Triatmoko -
96 5 Triatmoko -
<pre>
97 5 Triatmoko -
setproctitle(title)
98 5 Triatmoko -
</pre>
99 5 Triatmoko -
100 5 Triatmoko -
Set title as the title for the current process.
101 5 Triatmoko -
102 5 Triatmoko -
<pre>
103 5 Triatmoko -
getproctitle()
104 5 Triatmoko -
</pre>
105 5 Triatmoko -
106 5 Triatmoko -
Return the current process title.
107 5 Triatmoko -
108 5 Triatmoko -
More information about this library. http://pypi.python.org/pypi/setproctitle
109 5 Triatmoko -
110 10 Triatmoko -
h3. Serial port library
111 10 Triatmoko -
112 10 Triatmoko -
The serial port library is required for the cell phones to communicate with the server
113 10 Triatmoko -
computer and the BeagleBoards. The required library for Python can be installed by typing the following command:
114 10 Triatmoko -
115 10 Triatmoko -
<pre>
116 10 Triatmoko -
sudo apt-get install python-serial
117 10 Triatmoko -
</pre>
118 10 Triatmoko -
119 3 Triatmoko -
h3. MySQLdb
120 5 Triatmoko -
121 5 Triatmoko -
MySQLdb is an thread-compatible interface to the popular MySQL database server that provides the Python database API.
122 5 Triatmoko -
 _mysql is a low-level API similiar to the MySQL C API. ZMySQLDA is a Database Adapter for Zope2.
123 5 Triatmoko -
124 5 Triatmoko -
If you want to write applications which are portable across databases, use MySQLdb, and avoid using this module directly. _mysql provides an interface which mostly implements the MySQL C API. For more information, see the MySQL documentation. The documentation for this module is intentionally weak because you probably should use the higher-level MySQLdb module. If you really need it, use the standard MySQL docs and transliterate as necessary.
125 3 Triatmoko -
126 12 Triatmoko -
h3. pChart library
127 12 Triatmoko -
128 12 Triatmoko -
The pChart library is within our installation les and does not require to be installed individually. The library is only required if one uses the web interface and requires the generated resulting image. The library is open source and does not require any licensing. However, if one needs to learn how the library works, information can be found on the pChart web page http://www.pchart.net/
129 12 Triatmoko -
130 3 Triatmoko -
h2. PhpMyadmin
131 4 Triatmoko -
132 7 Triatmoko -
phpMyAdmin is a very famous MySQL mangement software package. To use it you should install and configure PHP, Apache and php mysql.
133 7 Triatmoko -
The easy way to install PhpMyadmin is installing from package using Apt-get command.
134 7 Triatmoko -
<pre>
135 7 Triatmoko -
sudo apt-get install phpmyadmin
136 7 Triatmoko -
</pre>
137 7 Triatmoko -
138 9 Triatmoko -
For detailed instructions on using repositories and package managers, please go to the site: https://help.ubuntu.com/community/phpMyAdmin
139 7 Triatmoko -
140 4 Triatmoko -
h2. MySQL Server
141 8 Triatmoko -
142 8 Triatmoko -
MySQL is a fast, multi-threaded, multi-user, and robust SQL database server. It is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.
143 8 Triatmoko -
144 8 Triatmoko -
h3. Installation
145 11 Triatmoko -
146 8 Triatmoko -
To install MySQL, run the following command from a terminal prompt:
147 8 Triatmoko -
<pre>
148 8 Triatmoko -
sudo apt-get install mysql-server
149 8 Triatmoko -
</pre>
150 8 Triatmoko -
151 8 Triatmoko -
During the installation process you will be prompted to enter a password for the MySQL root user.
152 8 Triatmoko -
153 9 Triatmoko -
Once the installation is complete, the MySQL server should be started automatically. More information, please see: https://help.ubuntu.com/11.04/serverguide/C/mysql.html
154 14 Konrad Meier
155 14 Konrad Meier
156 14 Konrad Meier
h1. Installation guide from Konrad
157 14 Konrad Meier
158 14 Konrad Meier
SSH
159 14 Konrad Meier
<pre>
160 14 Konrad Meier
apt-get install apache
161 14 Konrad Meier
</pre>
162 14 Konrad Meier
163 14 Konrad Meier
Python:
164 14 Konrad Meier
<pre>
165 14 Konrad Meier
apt-get install python python-serial python-setuptools python-dev build-essential
166 14 Konrad Meier
easy_install setproctitle
167 14 Konrad Meier
</pre>
168 14 Konrad Meier
169 16 Konrad Meier
Apache + php:
170 1 Triatmoko -
<pre>
171 16 Konrad Meier
apt-get install apache2 
172 16 Konrad Meier
apt-get install libapache2-mod-php5
173 17 Konrad Meier
a2enmod php5
174 17 Konrad Meier
/etc/init.d/apache2 restart
175 14 Konrad Meier
</pre>
176 14 Konrad Meier
177 14 Konrad Meier
MySQL:
178 14 Konrad Meier
<pre>
179 21 Konrad Meier
apt-get install mysql-server python-mysqldb php5-mysql php5-gd
180 14 Konrad Meier
</pre>
181 15 Konrad Meier
182 15 Konrad Meier
PJSUA
183 15 Konrad Meier
<pre>
184 15 Konrad Meier
wget http://www.pjsip.org/release/1.12/pjproject-1.12.tar.bz2
185 15 Konrad Meier
tar --bzip2 -xvf pjproject-1.12.tar.bz2
186 15 Konrad Meier
./configure && make dep && make
187 15 Konrad Meier
cd pjsip-apps/src/python/
188 15 Konrad Meier
make 
189 1 Triatmoko -
sudo make install
190 18 Konrad Meier
</pre>
191 18 Konrad Meier
192 18 Konrad Meier
193 18 Konrad Meier
Webserver-Config: 
194 18 Konrad Meier
(TODO)
195 18 Konrad Meier
see Report page 30 ff.
196 18 Konrad Meier
197 18 Konrad Meier
Database preparation:
198 18 Konrad Meier
<pre>
199 18 Konrad Meier
mysql -u root -p -h localhost
200 18 Konrad Meier
create databas gsmselftesting;
201 18 Konrad Meier
use mysql;
202 18 Konrad Meier
GRANT ALL PRIVILEGES ON gsmselftesting.* TO 'selftest'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
203 18 Konrad Meier
204 18 Konrad Meier
mysql -u selftest -p -h localhost -D gsmselftesting < gsmselftesting.sql
205 18 Konrad Meier
mysql -u selftest -p -h localhost -D gsmselftesting < InsertData.sql
206 18 Konrad Meier
</pre>
207 18 Konrad Meier
208 19 Konrad Meier
Change mysql login credentials in the code:
209 18 Konrad Meier
<pre>
210 1 Triatmoko -
vim Code/Server-Code/DbClass.py
211 19 Konrad Meier
</pre>
212 19 Konrad Meier
213 19 Konrad Meier
Chnage mysql login credentials in the website:
214 19 Konrad Meier
<pre>
215 19 Konrad Meier
vim /var/www-ssl/gsm-selftest/dbconnection.php
216 15 Konrad Meier
</pre>
217 20 Konrad Meier
218 20 Konrad Meier
219 20 Konrad Meier
220 20 Konrad Meier
Running the System:
221 20 Konrad Meier
<pre>
222 20 Konrad Meier
export DISPLAY=:0.0
223 20 Konrad Meier
./startSoftware.py
224 20 Konrad Meier
</pre>
225 20 Konrad Meier
226 20 Konrad Meier
<pre>
227 20 Konrad Meier
https://132.230.8.115
228 20 Konrad Meier
</pre>
229 22 Refik Hadzialic
230 22 Refik Hadzialic
231 22 Refik Hadzialic
h1. Configuring the web server to handle https and .htaccess files
232 22 Refik Hadzialic
233 22 Refik Hadzialic
h2. HTTPS
234 23 Refik Hadzialic
235 22 Refik Hadzialic
First we want to generate a server key by typing the following command:
236 22 Refik Hadzialic
<pre>
237 22 Refik Hadzialic
openssl genrsa −des3 −out server.key 4096
238 23 Refik Hadzialic
</pre>
239 23 Refik Hadzialic
240 23 Refik Hadzialic
241 23 Refik Hadzialic
This will generate a 4096 bit long private server key, one is asked to enter two times a password for the _server.key_. Using the generated private server key, we will create a certificate signing request, _server.csr_. We were prompted with a series of questions like country, state, organization name and etc which we had to enter to resume.
242 23 Refik Hadzialic
243 23 Refik Hadzialic
<pre>
244 23 Refik Hadzialic
openssl req -new -key server.key -out server.csr 
245 22 Refik Hadzialic
</pre>
246 24 Refik Hadzialic
247 24 Refik Hadzialic
In the next step we had to sign the certificate signing request and enter the amount of days for how long it should be valid. In our case we entered the duration of one year, one can make it for longer periods as well (i.e. the amount of 365 has to be changed).
248 24 Refik Hadzialic
249 24 Refik Hadzialic
<pre>
250 24 Refik Hadzialic
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
251 24 Refik Hadzialic
</pre>
252 24 Refik Hadzialic
253 24 Refik Hadzialic
We were asked to enter the password again for _server.key_. After we have completed this step we had to make a version of the _server.key_ which did not require a password, _server.key.insecure_ and we will rename the files appropriately. 
254 24 Refik Hadzialic
255 24 Refik Hadzialic
<pre>
256 24 Refik Hadzialic
openssl rsa -in server.key -out server.key.insecure
257 24 Refik Hadzialic
mv server.key server.key.secure
258 24 Refik Hadzialic
mv server.key.insecure server.key
259 24 Refik Hadzialic
</pre>
260 24 Refik Hadzialic
261 24 Refik Hadzialic
The generated files are very sensitive, since they are our keys. After these steps were completed, we had generated 4 files: _server.crt_, _server.csr_, _server.key_ and _server.key.secure_. Now we need to enable the SSL engine on the Apache web server. We copied _server.key_ and _server.crt_ into _/etc/appache2/ssl_. 
262 25 Refik Hadzialic
263 25 Refik Hadzialic
<pre>
264 25 Refik Hadzialic
refik@ubuntu:/etc/apache2$ sudo mkdir ssl
265 25 Refik Hadzialic
cp server.key /etc/apache2/ssl
266 25 Refik Hadzialic
cp server.crt /etc/apache2/ssl
267 25 Refik Hadzialic
</pre>
268 25 Refik Hadzialic
269 25 Refik Hadzialic
Then we enabled SSL by typing in _a2enmod ssl_, "it is simply a general purpose utility to establish a symlink between a module in _/etc/apache2/mods-available_ to _/etc/apache2/mods-enabled_ (or give a message to the effect that a given module does not exist or that it is already symlink-ed for loading)".
270 25 Refik Hadzialic
271 25 Refik Hadzialic
<pre>
272 25 Refik Hadzialic
refik@ubuntu:/etc/apache2/ssl$ sudo a2enmod ssl
273 25 Refik Hadzialic
Enabling module ssl.
274 25 Refik Hadzialic
See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
275 25 Refik Hadzialic
Run '/etc/init.d/apache2 restart' to activate new configuration!
276 25 Refik Hadzialic
</pre>
277 26 Refik Hadzialic
278 26 Refik Hadzialic
In the next procedure we had to establish a symlink from the 'available' default-ssl file to the 'enabled' file. Then we created a folder where our secured PHP files will be located (e.g. https://some-domain-name.com/test-software).
279 26 Refik Hadzialic
280 26 Refik Hadzialic
<pre>
281 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/ssl$ sudo ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl 
282 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/ssl$ cd /var/
283 26 Refik Hadzialic
refik@ubuntu:/var$ sudo mkdir www-ssl
284 26 Refik Hadzialic
</pre>
285 26 Refik Hadzialic
286 26 Refik Hadzialic
We had backed up our old configuration files for the virtual hosts, for the case if we damage the Apache configuration files. Then we edited the _default-ssl_ file.
287 26 Refik Hadzialic
288 26 Refik Hadzialic
<pre>
289 26 Refik Hadzialic
refik@ubuntu:/var$ cd /etc/apache2/sites-available
290 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo cp default default_original
291 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo cp default-ssl default-ssl_original
292 26 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo vim default-ssl
293 26 Refik Hadzialic
</pre>
294 26 Refik Hadzialic
295 26 Refik Hadzialic
Only the beginning of the file is listed here and we have modified the line starting with _DocumentRoot_ and _<Directory /var/www/>_ from _DocumentRoot /var/www_ to _DocumentRoot /var/www-ssl_ and from _<Directory /var/www/>_ to _<Directory /var/www-ssl/>_ (i.e. we had to redefine the location of our SSL directory).
296 26 Refik Hadzialic
297 26 Refik Hadzialic
<pre>
298 26 Refik Hadzialic
<IfModule mod_ssl.c>
299 26 Refik Hadzialic
<VirtualHost _default_:443>
300 26 Refik Hadzialic
        ServerAdmin webmaster@localhost
301 26 Refik Hadzialic
302 26 Refik Hadzialic
        DocumentRoot /var/www-ssl
303 26 Refik Hadzialic
        <Directory />
304 26 Refik Hadzialic
                Options FollowSymLinks
305 26 Refik Hadzialic
                AllowOverride None
306 26 Refik Hadzialic
        </Directory>
307 26 Refik Hadzialic
        <Directory /var/www-ssl/>
308 26 Refik Hadzialic
                Options Indexes FollowSymLinks MultiViews
309 26 Refik Hadzialic
                AllowOverride None
310 26 Refik Hadzialic
                Order allow,deny
311 26 Refik Hadzialic
                allow from all
312 26 Refik Hadzialic
        </Directory>
313 26 Refik Hadzialic
</pre>
314 27 Refik Hadzialic
315 27 Refik Hadzialic
One should keep in mind that the port 443 should be free for Apache to use it. In the proceeding step we had to ensure that Apache listens on the given port for a _https_ connection. One could test that by going into the _/etc/apache2/ports.conf_.
316 27 Refik Hadzialic
317 27 Refik Hadzialic
<pre>
318 28 Refik Hadzialic
<IfModule mod_ssl.c>
319 27 Refik Hadzialic
    # If you add NameVirtualHost *:443 here, you will also have to change
320 27 Refik Hadzialic
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
321 27 Refik Hadzialic
    # to <VirtualHost *:443>
322 27 Refik Hadzialic
    # Server Name Indication for SSL named virtual hosts is currently not
323 27 Refik Hadzialic
    # supported by MSIE on Windows XP.
324 27 Refik Hadzialic
    Listen 443
325 28 Refik Hadzialic
</IfModule>
326 27 Refik Hadzialic
</pre>
327 27 Refik Hadzialic
328 27 Refik Hadzialic
In our case it was set up correctly, since the command: _Listen 443_ was present. In our last configuration step we had to edit _default-ssl_ file to define the correct locations of our keys and to ensure the SSL engine was turned on.
329 27 Refik Hadzialic
330 27 Refik Hadzialic
<pre>
331 27 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo vim default-ssl
332 27 Refik Hadzialic
</pre>
333 27 Refik Hadzialic
334 27 Refik Hadzialic
The following part of the file had to be found and modified according to our key path locations:
335 27 Refik Hadzialic
<pre>
336 27 Refik Hadzialic
SSLEngine on
337 27 Refik Hadzialic
338 27 Refik Hadzialic
       #   A self-signed (snakeoil) certificate can be created by installing
339 27 Refik Hadzialic
       #   the ssl-cert package. See
340 27 Refik Hadzialic
       #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
341 27 Refik Hadzialic
       #   If both key and certificate are stored in the same file, only the
342 27 Refik Hadzialic
       #   SSLCertificateFile directive is needed.
343 27 Refik Hadzialic
       SSLCertificateFile    /etc/apache2/ssl/server.crt
344 27 Refik Hadzialic
       SSLCertificateKeyFile /etc/apache2/ssl/server.key
345 27 Refik Hadzialic
346 27 Refik Hadzialic
       #   Server Certificate Chain:
347 27 Refik Hadzialic
       #   Point SSLCertificateChainFile at a file containing the
348 27 Refik Hadzialic
</pre>
349 27 Refik Hadzialic
350 27 Refik Hadzialic
Finally we had configured our server and can proceed with the restart of the apache web server. We created a test web site _/var/www-ssl/index.php_ and navigated our browser to _https://localhost_. The test was successful! 
351 28 Refik Hadzialic
352 28 Refik Hadzialic
<pre>
353 28 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$ sudo /etc/init.d/apache2 restart
354 28 Refik Hadzialic
 * Restarting web server apache2                                                                                                                                        [Sat Oct 08 21:52:51 2011] [warn] _default_ VirtualHost overlap on port 443, the first has precedence
355 28 Refik Hadzialic
 ... waiting [Sat Oct 08 21:52:52 2011] [warn] _default_ VirtualHost overlap on port 443, the first has precedence [ OK ]
356 28 Refik Hadzialic
refik@ubuntu:/etc/apache2/sites-available$
357 28 Refik Hadzialic
</pre>
358 28 Refik Hadzialic
359 28 Refik Hadzialic
h2. Configuring the password protection for the web site (using .htaccess)
360 28 Refik Hadzialic
361 28 Refik Hadzialic
However, to enable the use of Apache _.htaccess_ files, we will have to reconfigure the Apache configuration files again. _root_ access will be required. First we have to edit the _/etc/apache2/sites-available/default-ssl_ file. Find the following lines and modify the _AllowOverride None_ to _AllowOverride All_
362 28 Refik Hadzialic
like in the given configuration segment:
363 28 Refik Hadzialic
364 28 Refik Hadzialic
<pre>
365 28 Refik Hadzialic
        <Directory /var/www-ssl/>
366 28 Refik Hadzialic
                Options Indexes FollowSymLinks MultiViews
367 28 Refik Hadzialic
                AllowOverride All
368 28 Refik Hadzialic
                Order allow,deny
369 28 Refik Hadzialic
                allow from all
370 28 Refik Hadzialic
        </Directory>
371 28 Refik Hadzialic
</pre>
372 28 Refik Hadzialic
373 28 Refik Hadzialic
This will tell Apache web server that it is okay to allow _.htaccess_ files to over-ride previous directives. We must reload the Apache web server before the changes can take effect. We can do it by typing:
374 28 Refik Hadzialic
375 28 Refik Hadzialic
<pre>
376 28 Refik Hadzialic
sudo /etc/init.d/apache2 reload
377 28 Refik Hadzialic
</pre>
378 28 Refik Hadzialic
379 28 Refik Hadzialic
The next step is to go to the directory where our test software web page is located (e.g. _/var/www-ssl/testsoftware_) and to create a file called _.htaccess_.
380 28 Refik Hadzialic
Please insert the following code segment inside the created _.htaccess_ file where _/var/www-ssl/testsoftware/.htpasswd_ is your full path address to _.htpasswd_:
381 28 Refik Hadzialic
382 28 Refik Hadzialic
<pre>
383 28 Refik Hadzialic
AuthUserFile /var/www-ssl/testsoftware/.htpasswd
384 28 Refik Hadzialic
AuthName "Authorization Required"
385 28 Refik Hadzialic
AuthType Basic
386 28 Refik Hadzialic
require valid-user 
387 28 Refik Hadzialic
</pre>
388 28 Refik Hadzialic
389 28 Refik Hadzialic
Then in the next step, create another file called _.htpasswd_. After you have created it, we will add the usernames that should have access to the web site. We do that by typing the following command, where you can replace _konrad_ with any other combination of letters which will represent your username:
390 28 Refik Hadzialic
391 28 Refik Hadzialic
<pre>
392 28 Refik Hadzialic
refik@ubuntu:/var/www-ssl/testsoftware$ sudo htpasswd -c .htpasswd konrad
393 28 Refik Hadzialic
</pre>
394 28 Refik Hadzialic
395 28 Refik Hadzialic
Afterwards, you will be required to type twice the same password for the username you want to create, in this case _konrad_. "The -c flag is used only when you 
396 28 Refik Hadzialic
are creating a new file. After the first time, you will omit the -c flag, when you are adding new users to an already-existing password file. Otherwise you will overwrite the file!". You can add as many users as you wish, do not forget to remove the -c flag when you do it. In the last step, we have to modify the _/etc/apache2/apache2.conf_ file and to add at the end of it the following code segment where _/vaw/www-ssl/testsoftware_ is the full path to your web page directory where you put the _.htpasswd_ file:
397 28 Refik Hadzialic
398 28 Refik Hadzialic
<pre>
399 28 Refik Hadzialic
<Directory /vaw/www-ssl/testsoftware>
400 28 Refik Hadzialic
AllowOverride All
401 28 Refik Hadzialic
</Directory>
402 28 Refik Hadzialic
</pre>
403 28 Refik Hadzialic
404 28 Refik Hadzialic
We are done with editing. All we have to do now is to restart the Apache web server. We
405 28 Refik Hadzialic
can do that by typing:
406 28 Refik Hadzialic
407 28 Refik Hadzialic
<pre>
408 28 Refik Hadzialic
sudo /etc/init.d/apache2 restart
409 28 Refik Hadzialic
</pre>
410 28 Refik Hadzialic
411 28 Refik Hadzialic
You can test it now by opening a new browser tab and navigating to _https://localhost/testsoftware_ (keep in mind to replace _testsoftware_ with your name of the folder where the web page is located). If you configured everything properly, you should get a dialog where you can enter your created username and password and try to login.