— Summary —

Simple facts:

  • WordPress rewrite works well on hosting server but not works well on my home computer.
  • Ubuntu 12.04 LTS was released on 2012-04-26 and Apache httpd 2.4.2 was Released on 2012-04-17.
  • Check http://packages.ubuntu.com/precise/web/, you will see that Package: apache2 (2.2.22-1ubuntu1).
  • No available package for you to simply apt-get install yet.
  • To compile and install manually is fun and educational. To verify your knowledge on operation system. If you actually check source code and you will respect Open Source more.

What to achieve?

  • to compile and to install workable Apache httpd 2.4.2 to directory /usr/local/apache2.4.2
  • to have 2 Apache server, old one in version 2.2.22 listening to port 80, and new one in version 2.4.2 listening to port 8080

— Preparation —

Check list

  • to get source code of Apache at http://httpd.apache.org/docs/2.4
  • to get source code of Apr and Apr-Util at http://apr.apache.org
  • Put unpacked Apache source code under /home/mark/prja
  • Put unpacked Apr source code under /home/mark/prja/httpd-2.4.2/srclib/apr
  • Put unpacked Apr-Util source code under /home/mark/prja/httpd-2.4.2/srclib/apr-util

Check source code directory

mark@ubuntu:~$ pwd
/home/mark
mark@ubuntu:~$ cd prja
mark@ubuntu:~/prja$ ls
httpd-2.4.2
mark@ubuntu:~/prja$ cd httpd-2.4.2/
mark@ubuntu:~/prja/httpd-2.4.2$ ls
ABOUT_APACHE     buildmark.o    httpd           Makefile.in    README.platforms
acinclude.m4     CHANGES        httpd.dsp       Makefile.win   ROADMAP
Apache-apr2.dsw  config.layout  httpd.spec      modules        server
Apache.dsw       config.log     include         modules.c      srclib
apache_probes.d  config.nice    INSTALL         modules.lo     support
ap.d             config.status  InstallBin.dsp  modules.o      test
build            configure      LAYOUT          NOTICE         VERSIONING
BuildAll.dsp     configure.in   libhttpd.dsp    NWGNUmakefile
BuildBin.dsp     docs           LICENSE         os
buildconf        emacs-style    Makefile        README
mark@ubuntu:~/prja/httpd-2.4.2$ cd srclib
mark@ubuntu:~/prja/httpd-2.4.2/srclib$ ls
apr  apr-util  Makefile  Makefile.in
mark@ubuntu:~/prja/httpd-2.4.2/srclib$ cd ..
mark@ubuntu:~/prja/httpd-2.4.2$

— Step by Step —

1. Perform configure

mark@ubuntu:~/prja/httpd-2.4.2$ ./configure --prefix=/usr/local/apache2.4.2 --with-included-apr > ../prja-log1.txt
rm: cannot remove `conftest*': No such file or directory
rm: cannot remove `conftest*': No such file or directory
rm: cannot remove `libtoolT': No such file or directory
configure: WARNING: apr/apr-util is compiled without ldap support
configure: WARNING: apr/apr-util is compiled without ldap support
configure: WARNING: Your APR does not include SSL/EVP support.
mark@ubuntu:~/prja/httpd-2.4.2$

2. Perform make

mark@ubuntu:~/prja/httpd-2.4.2$ sudo make > ../prja-log2.txt
[sudo] password for mark: 
mark@ubuntu:~/prja/httpd-2.4.2$

Just in case, if you try more than one time, you might need to run “make clean” before “make” again.

3. Perform make install

mark@ubuntu:~/prja/httpd-2.4.2$ sudo make install> ../prja-log3.txt
libtool: install: warning: relinking `libaprutil-1.la'
mkdir /usr/local/apache2.4.2/modules
mkdir /usr/local/apache2.4.2/conf
mkdir /usr/local/apache2.4.2/conf/extra
mkdir /usr/local/apache2.4.2/conf/original
mkdir /usr/local/apache2.4.2/conf/original/extra
mkdir /usr/local/apache2.4.2/htdocs
mkdir /usr/local/apache2.4.2/error
mkdir /usr/local/apache2.4.2/icons
mkdir /usr/local/apache2.4.2/logs
mkdir /usr/local/apache2.4.2/cgi-bin
mkdir /usr/local/apache2.4.2/man
mkdir /usr/local/apache2.4.2/man/man1
mkdir /usr/local/apache2.4.2/man/man8
mkdir /usr/local/apache2.4.2/manual
mark@ubuntu:~/prja/httpd-2.4.2$

Several directories were created and we know where Apache was installed.

4. To start web server

mark@ubuntu:~/prja/httpd-2.4.2$ cd /usr/local/apache2.4.2
mark@ubuntu:/usr/local/apache2.4.2$ ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
mark@ubuntu:/usr/local/apache2.4.2$ cd bin
mark@ubuntu:/usr/local/apache2.4.2/bin$ ls
ab            apu-1-config  dbmmanage    fcgistarter   htdigest  httxt2dbm
apachectl     apxs          envvars      htcacheclean  htpasswd  logresolve
apr-1-config  checkgid      envvars-std  htdbm         httpd     rotatelogs
mark@ubuntu:/usr/local/apache2.4.2/bin$ ./apachectl -v
Server version: Apache/2.4.2 (Unix)
Server built:   Jun 25 2012 10:27:49
mark@ubuntu:/usr/local/apache2.4.2/bin$

Now, this new Apache 2.4.2 is ready to tune up.
You might want to try to start it, to expect error message and to study it accordingly.

mark@ubuntu:/usr/local/apache2.4.2/bin$ ./apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
mark@ubuntu:/usr/local/apache2.4.2/bin$

Permission problem. So we should add sudo and try it again.

mark@ubuntu:/usr/local/apache2.4.2/bin$ sudo ./apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
mark@ubuntu:/usr/local/apache2.4.2/bin$

Now, we have option, either to stop current running Apache or to let new Apache listen to alternative port. Stick to our plan, carry out the second solution.

Change directory to locate configuration file and make a backup first

mark@ubuntu:/usr/local/apache2.4.2/bin$ cd ..
mark@ubuntu:/usr/local/apache2.4.2$ ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
mark@ubuntu:/usr/local/apache2.4.2$ cd conf
mark@ubuntu:/usr/local/apache2.4.2/conf$ ls
extra  httpd.conf  magic  mime.types  original
mark@ubuntu:/usr/local/apache2.4.2/conf$ sudo cp httpd.conf httpd.conf.backup
mark@ubuntu:/usr/local/apache2.4.2/conf$ ls
extra  httpd.conf  httpd.conf.backup  magic  mime.types  original
mark@ubuntu:/usr/local/apache2.4.2/conf$

Then, to use default text editor to modify configuration file,

mark@ubuntu:/usr/local/apache2.4.2/conf$ sudo gedit httpd.conf

You will see something like this,
gedit httpd.conf

Ctrl+F to Find the lines

#Listen 12.34.56.78:80
Listen 80

And change it to be

Listen 127.0.0.1:8080
#Listen 80

Save and exit editor. Run command to start it again

mark@ubuntu:/usr/local/apache2.4.2/conf$ sudo /usr/local/apache2.4.2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
mark@ubuntu:/usr/local/apache2.4.2/conf$

Ignore warning message for a while.

5. Check result and it’s done

It works!

— Further Study —

  • Log files are here for future reference: prja-log1.txt,prja-log2.txt and prja-log3.txt.
  • You may compile and install Apr and Apr-Util first. However it’s easier to put them to proper location and to have configuration option –with-included-apr.

— Useful Command —

/usr/local/apache2.4.2/bin/apachectl -v
sudo /usr/local/apache2.4.2/bin/apachectl start
sudo /usr/local/apache2.4.2/bin/apachectl stop
sudo gedit /usr/local/apache2.4.2/conf/httpd.conf


http://shonm.tistory.com/entry/%EC%95%84%ED%8C%8C%EC%B9%98-%EC%84%A4%EC%B9%98%EC%8B%9C-ssl-%EC%84%A4%EC%B9%98-https-%EC%A0%91%EC%86%8D


ssl 설치

http://www.openssl.org

//32BIT 일때

./config --prefix=/usr/local/ssl

make

make install

 

//./config --prefix=/usr/local/ssl -fPIC 이렇게 실행 해야 할 때도 있음

//우분투에선 -fPIC 옵션 안먹는데..(32bit ㅜ.ㅜ)

 

 


apache 설치

http://httpd.apache.org/


./configure --prefix=/usr/local/apache2.4 \
--enable-mods-shared=most \
--enable-module=so \
--enable-so \
--enable-rewrite \
--enable-mods-shared=ssl \
--with-ssl=/usr/local/ssl \
--enable-ssl \
--with-mpm=worker \
--enable-cache \
--enable-file-cache \
--enable-charset-lite


make

make install

 

 

//apache 설치시에
//configure: error: ... Error, SSL/TLS libraries were missing or unusable

//export LIBS=-ldl

//export LD_LIBRARY_PATH="/usr/local/openssl/"
//export LIBS="-L/usr/local/openssl"
//export CPPFLAGS="-I/usr/local/openssl/include/openssl" 

//이라고 쉘상에 쳐주고 다시 configure 할 것 (64bit 일 때 발생)

 

//configure: error: APR not found.  Please read the documentation. 오류 발생시
//우분투
sudo apt-get install libapreq2-dev
sudo apt-get install libaprutil1.dev

 


openssl 생성

cd /usr/local/apache2.4/conf
mkdir sslkeys
cd sslkeys

//key 파일 생성
openssl genrsa -des3 -out 211.63.6.184.key 2048
//csr 파일 생성 (서명 정보가 들어 있는 파일)
openssl req -new -key 211.63.6.184.key -out 211.63.6.184.csr

Country Name : 국가 => KR
State or province Name : 시/도/군 => Seoul
Locality Name : 구/군 => Seocho
Organization Name : 회사 => Incross
Organization Utin Name : 부서 => System2
Common Name : 이름 중 성 : Jung

Email Address : 메일주소 => shonm@incorsss.com
A Challenge password : ~~~~
An optional company name : ~~~

//crt 파일 생성 (인증서 생성)
openssl x509 -in 211.63.6.184.csr -out 211.63.6.184.crt -req -signkey 211.63.6.184.key -days 365

 

//아파치 구동시
//Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
cd /usr/local/apache2.4/conf
vi httpd.conf
ServerName:80 => ServerName ip(서버아이피):80
이렇게 되어 있는 곳을 고친다.


//httpd-ssl.conf 추가
cd /usr/local/apache2.4/conf
vi /usr/local/apache2.4/conf/httpd.conf

include conf/extra/httpd-ssl.conf
//주석 부분 주석 #삭제


//httpd-ssl.conf 수정
cd /usr/local/apache2.4/conf/extra
vi /usr/local/apache2.4/conf/extra/httpd-ssl.conf

#Listen 443 밑부분에 virtualhost 태그 들어가기 전에
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
추가

<VirtualHost _default_:443> => <VirtualHost 서버IP:443>
=>ex) <VirtualHost 211.63.6.184:443>

#SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5을 주석 처리(#을 앞에 붙임)
#<VirtualHost _default_:443> 태그 안에
#SSLCertificateFile "/usr/local/apache2.4/conf/server.crt" 주석 처리
#SSLCertificateKeyFile "/usr/local/apache2.4/conf/server.key" 주석 처리


#SSLEngine on 하단에

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile "/usr/local/apache2.4/conf/sslkeys/211.63.6.184.crt"

SSLCertificateKeyFile "/usr/local/apache2.4/conf/sslkeys/211.63.6.184.key"
추가


#특정 디렉토리로 alias 걸어주고 싶다면 아래와 같이 하면 됨 </VirtualHost> 앞에

JkMount /cms_shop/* cms
JkMount /cms_shop/*.jsp cms


Alias /cms_admin_poc "/home/smadeco_cms/cms_admin_poc"
<Directory "/home/smadeco_cms/cms_admin_poc">
Options Indexes FollowSymLinks
</Directory>
추가

//Invalid command 'SSLPassPhraseDialog', perhaps misspelled or defined by a module not included in the server configuration
//에러 발생시
//httpd.conf 의 LoadModule ssl_module modules/mod_ssl.so 부분 주석 풀어줌
//비슷한 로그들이 발생시 LoadModule 쪽에서 so 파일들 주석을 푸는 것으로 해결해야 함

 

//http://211.63.6.184 로 들어오면 자동으로 https://211.63.6.184 이렇게 바꿔주고 싶다면
//httpd.conf 에 맨 하단에 아래의 문구를 첨가해주면 됨
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [C]

</IfModule>

 

 

 

#https://서버IP   이렇게 브라우저로 접근시 It works 가 나오면 성공임


Time Scheduler

http://www.sourcecodesworld.com/source/show.asp?ScriptID=1231


Graphics Eight Queen (Mini Project)

http://www.sourcecodesworld.com/source/show.asp?ScriptID=966


File Splitting & Merging Utility

http://www.sourcecodesworld.com/source/show.asp?ScriptID=925


Data Encryption Program which can encrypt any file (Mini Project)

http://www.sourcecodesworld.com/source/show.asp?ScriptID=904


Simulating a preprocessor using files

http://www.sourcecodesworld.com/source/show.asp?ScriptID=673


File Copy Program in C

http://www.sourcecodesworld.com/source/show.asp?ScriptID=488


Program to write even and odd integers into different files.

http://www.sourcecodesworld.com/source/show.asp?ScriptID=466



http://wiki.kldp.org/wiki.php/PackageMgmt#s-3.9

http://wiki.kldp.org/wiki.php/PackageMgmt#s-2.5

1. 우선 해당 파일이 속한 패키지를 검색해 봅니다.

$ dpkg --search /bin/ls
coreutils: /bin/ls


이렇게 해서 /bin/ls가 coreutils라는 패키지 소속이라는 걸 알아냅니다.

2. apt-get 으로 해당 패키지의 소스를 내려받습니다.
$ apt-get source coreutils
이렇게 하면 파일 세개를 내려받을 겁니다. 하나는 패키지 설명 파일, 또하나는 원래 소스 파일, 마지막 하나는 우분투용 패키지를 만들 때 적용시킨 패치파일입니다.

3. tar로 소스 압축 파일을 풀고 분석합니다.

 

 

개인적으로는..
http://www.busybox.net/screenshot.html
명령어 같은 것들을 분석하시려면 busybox를 분석해보시는 걸 추천합니다.