2010~ ubuntu的源码搭建lamp

设置root密码
#sudo passwd root

编译更新源列表
#vi /etc/apt/sources.list

#apt-get update

#apt-get install build-essential   //安装GCC
搭建lamp


1.mysql的安装

//先安装库libncurses5-dev
#apt-get install libncurses5-dev

# groupadd mysql
#useradd -s /sbin/nologin -g mysql mysql

#tar -zxvf mysql-5.1.44
# cd mysql-5.1.44
# ./configure --prefix=/usr/local/mysql   /指定安装目录
--with-charset=utf8  
--with-collation=utf8_general_ci
--with-extra-charsets=gbk,gb2312,binary  /添加gbk,gb2312中文字符支持
--without-debug /去除debug模式
--with-pthread  /强制使用pthread库(posix线程库)
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
--enable-assembler   /使用一些字符函数的汇编版本
--enable-thread-safe-client    /以线程方式编译客户端
--with-client-ldflags=-all-static    /以纯静态方式编译客户端
--with-mysqld-ldflags=-all-static      /以纯静态方式编译服务端


# make
# make install
# cp support-files/my-medium.cnf /etc/my.cnf    //这个没拷进去 会导致mysql不支持socket
# cd /usr/local/mysql
# chown -R mysql .
# chgrp -R mysql .
# bin/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql var
# bin/mysqld_safe --user=mysql &

设置mysql开机启动
#cp support-files/mysql.server /etc/init.d/mysqld
#chmod 700 /etc/init.d/mysqld         //注意启动脚本的值必须设成700
#apt-get install sysv-rc-conf

#sysv-rc-conf                   //进行设置

#/usr/local/mysql/bin/mysqladmin -u root password ******//给root用户添加密码

 

 

2.安装zlib-1.2.3

#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure --prefix=/usr
#make
#make install

 

3.安装openssl-0.9.8l

#tar zxvf openssl-0.9.8l.tar.gz
#cd openssl-0.9.8l
#./config shared zlib
#make
#make test
#make install
#mkdir -p /usr/local/bin/lib
#mkdir -p /usr/local/bin/include
#ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl   //设置openssl为程序
#ln -s /usr/local/ssl/include/openssl /usr/include/openssl
#rm /usr/lib/libcrypto.so.0.9.8
#rm /usr/lib/libssl.so.0.9.8
#cp /usr/local/ssl/lib/libssl.so.0.9.8  /usr/lib
#cp /usr/local/ssl/lib/libcrypto.so.0.9.8 /usr/lib

配置库文件搜索路径


#echo "/usr/local/ssl/lib" >> /etc/ld.so.conf.d/openssl.conf
#ldconfig -v


4.安装apache
# tar zxvf httpd-2.2.14.tar.gz   //解压缩安装包
# cd httpd-2.2.14   //进入安装目录
# ./configure
--enable-module=so //配置Apache支持Dynamic Shared Objects (DSO)模式
--enable-dav //添加mod_dav.so模块
--enable-mime-magic
--sysconfdir=/etc/httpd  //指定apache配置文档的目录
--enable-dav-fs  //添加mod_dav_fs.so模块
--enable-so
--prefix=/usr/local/apache2  //apache需要安装到的目录位置
--enable-ssl
--with-ssl=/usr/local/ssl
--enable-track-vars
--enable-rewrite //添加rewrite模块
--with-z=/usr
--enable-mods-shared=most


#make
#make install

 


设置apache开机启动

#vim /etc/init.d/httpd  //编写启动脚本
 
脚本如下:
    #!/bin/sh

    # description:Apache auto start-stop script.

    # chkconfig: - 85 15
    APACHE_HOME=/usr/local/apache2
    APACHE_OWNER=root
    if [ ! -f "$APACHE_HOME/bin/apachectl" ]
    then
    echo "Apache startup: cannot start"
    exit
    fi
    case "$1" in
    'start')
    su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl start"
    ;;
    'stop')
    su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl stop"
    ;;
    'restart')
    su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl restart"
    ;;
    esac

 

#chmod 700 /etc/init.d/httpd
#sysv-rc-conf   //设置httpd开机启动

 


5.安装libpng-1.4.0

#tar zxvf libpng-1.4.0.tar.gz
# cd libpng-1.4.0
# cp scripts/makefile.linux makefile
#vi makefile
(指定zlib的库文件路径到/usr/lib和/usr/include,编辑makefile文件实现)
# make
# make install


6.安装freetype-2.3.12
# tar -zvxf freetype-2.3.12.tar.gz
# cd freetype-2.3.12
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make;make install

7.安装jpegsrc.v6b

jpeg默认不会自建目录,因此需手动建立目录:
# mkdir -pv /usr/local/jpeg6/{,bin,lib,include,man/{,man1},man1}

#tar zxvf jpegsrc.v6b.tar.gz
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
# make install-lib

8.安装t1lib-5.1.2
#tar -zxvf t1lib-5.1.2.tar.gz
#cd t1lib-5.1.2
#./configure --prefix=/usr/local/t1lib
#make
#make install


9.安装libiconv
#tar -zxvf libiconv-1.13.1
#cd libiconv-1.13.1
#./configure --prefix=/usr/local
#make
#make install

 

 

 

10.安装GD库
#tar -zxvf gd-2.0.35.tar.gz
#cd gd-2.0.35
#mkdir -p /usr/local/gd2


(插曲:#vi gd_png.c  
   将if (!png_check_sig (sig, 8)) { /* bad signature */
  换成
  if (png_sig_cmp (sig, 0, 8)) { /* bad signature */
 )

#./configure  --prefix=/usr/local/gd2
--with-png=/usr/local/lib
--with-jpeg=/usr/local/jpeg6/
--with-freetype=/usr/local/freetype/
--with-zlib=/usr
--with-libiconv-prefix=/usr/local
#make
#make install

 

11.安装curl
#tar -zxvf curl-7.20.0.tar.gz
#cd curl-7.20.0
#./configure --prefix=/usr/local/curl --with-ssl
#make
#make install


12.安装expat
cd /usr/local/src
tar -zxvf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/usr/local/expat
make && make install

 

 

 

 


13.安装libmcrypt

#tar -zxvf libmcrypt-2.5.8.tar.gz

   #cd libmcrypt-2.5.8

   #./configure --prefix=/usr

   #make

   #make install

   #ldconfig

14. 安装libltdl
   
   #cd  /.../libmcrypt-2.5.8/libltdl

   #./configure  –enable-ltdl-install

  #make

  #make install
.
15.安装mhash

   #tar -zxvf mhash-0.9.9.9.tar.gz

   #cd mhash-0.9.9.9

   #./configure prefix=/usr

   #make

   #make install


16.安装mcrypt

 #tar -zxvf mcrypt-2.6.8.tar.gz

   #cd mcrypt-2.6.8

   #LD_LIBRARY_PATH=/usr ./configure --prefix=/usr

   #make

   #make install


17.安装pspell
#tar -zvxf aspell-0.60.6.tar.gz
#cd aspell-0.60.6
#./configure --prefix=/usr
#make 
#make install


18.安装DB4
#tar -zxvf db-4.8.26.tar.gz
#cd db-4.8.26
#cd build_unix
#../dist/configure --prefix=/usr/local/bekeleydb
#make
#make install


19.安装GDBM
#tar -zxvf gdbm-1.8.3.tar.gz
#./configure --prefix=/usr
#make
#make install
#make install-compat (如果不执行此步,无法编译出ndbm.h头文件)


20.安装bz2
#tar -zxvf bzip2-1.0.5.tar.gz
安装前的准备

#make -f Makefile-libbz2_so
# make clean

#make
#make install

把共享的bzip2二进制文件拷贝到 /bin 目录,创建必要的符号链接,作一些清理工作.

cp bzip2-shared /bin/bzip2
cp -a libbz2.so* /lib
ln -s ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
rm /usr/bin/{bunzip2,bzcat,bzip2}
mv /usr/bin/{bzip2recover,bzless,bzmore} /bin
ln -s bzip2 /bin/bunzip2
ln -s bzip2 /bin/bzcat
 

 


21.安装libxml2
# tar -zxf libxml2-2.7.6.tar.gz
# cd libxml2-2.7.6
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make
#make install
#cp xml2-config /usr/bin          //不做这步,编译php会报错

 

22.安装XSL
#cd libxslt-1.1.26
#./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
#make
#make install

 

 

 

22.安装php
#tar -zxvf php-5.2.12.tar.gz
#cd php-5.2.12
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/lib --with-jpeg-dir=/usr/local/jpeg6 --with-zlib=/usr --with-t1lib=/usr/local/t1lib --with-openssl --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd2 --enable-mbstring=all --disable-debug --with-mcrypt=/usr/local/include --with-mhash=/usr --enable-ftp --with-curl=/usr/local/curl --enable-sockets --enable-calendar --enable-bcmath --enable-shmop --enable-zip --enable-sqlite-utf8  --enable-soap  --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-bz2=/usr --enable-mbregex --without-snmp --enable-exif --enable-gd-jis-conv --with-curlwrappers --enable-dba --with-gdbm=/usr --with-pspell=/usr --enable-wddx --with-cdb --with-gettext --with-iconv-dir=/usr/local --with-libexpat-dir=/usr/local/expat --with-ncurses  --with-xsl=/usr/local/libxslt/ --with-xmlrpc

#make
#make install


#cp php.ini-dist /usr/local/php/lib/php.ini

#vi /etc/httpd/httpd.conf
  添加
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps  //可不加,加了只是在浏览器里显示php源代码
还有找到DirectoryIndex index.html
加上 index.php 让它把index.php做为默认页

 

23.安装ZendOptimizer-3.3.9-linux-glibc21-i386
#tar -zxvf  ZendOptimizer-3.3.9-linux-glibc21-i386.tar.gz

#mv ZendOptimizer-3.3.9-linux-glibc21-i386 /usr/local/zend
#cd /usr/local/zend
# cp data/5_2_x_comp/ZendOptimizer.so /usr/local/zend

#vi /usr/local/php/lib/php.ini
在php.ini文件中加入如下两行,不要包含任何空格:
zend_optimizer.optimization_level=7
zend_extension="/usr/local/Zend/lib/ZendOptimizer.so"

#/usr/local/apache2/bin/apachectl restart  //重启服务器

 

24.启用ssl

(1)下载ssl.ca-0.1.tar.gz(适合新手使用)到/etc/httpd(Apache2.2.14安装时指定的配置文件目录)
#tar zxvf ssl.ca-0.1.tar.gz
#cd ssl.ca-0.1

生成根证书
#./new-root-ca.sh
No Root CA key round. Generating one
Generating RSA private key, 1024 bit long modulus
...............................++++++
.......++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key: (此处要输入一个密码,至少四位)
Verifying - Enter pass phrase for ca.key: (重复以上密码)
Self-sign the root CA...
Enter pass phrase for ca.key: (刚刚输过的密码)
You are about to be asked to enter information
that will be incorporated
into your certificate request.
What you are about to enter is what is called a
Distinguished Name or a DN.
There are quite a few fields but you can leave
some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:HeNan
Locality Name (eg, city) [Sitiawan]:Zhengzhou
Organization Name (eg, company) [My Directory Sdn
Bhd]:Benet Ltd
Organizational Unit Name (eg, section)
[Certification Services Division]:Marion
Common Name (eg, MD Root CA) []:Benet CA
Email Address []:knightma@yeah.net
如此可以生成ca.key和ca.crt两个文件;其中的省份、公司等内容可以按照你自己的想法来设定。

接下来要为服务器生成一个证书:
# ./new-server-cert.sh server (这个证书的名字是server)
No server.key round. Generating one
Generating RSA private key, 1024 bit long modulus
....++++++
.............++++++
e is 65537 (0x10001)
Fill in certificate data
You are about to be asked to enter information
that will be incorporated
into your certificate request.
What you are about to enter is what is called a
Distinguished Name or a DN.
There are quite a few fields but you can leave
some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:HeNan
Locality Name (eg, city) [Sitiawan]:Zhengzhou
Organization Name (eg, company) [My Directory Sdn
Bhd]:Benet Ltd
Organizational Unit Name (eg, section) [Secure Web
Server]:Marion
Common Name (eg, www.domain.com) []:localhost
Email Address []:knightma@yeah.net
You may now run ./sign-server-cert.sh to get it
signed
执行结束后生成了server.csr和server.key这两个文件。但它们还需要签署一下才能使用。

# ./sign-server-cert.sh server
CA signing: server.csr -> server.crt:
Using configuration from ca.config
Enter pass phrase for ./ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'CN'
stateOrProvinceName :PRINTABLE:'HeNan'
localityName :PRINTABLE:'Zhengzhou'
organizationName :PRINTABLE:'Benet Ltd'
organizationalUnitName:PRINTABLE:'Marion'
commonName :PRINTABLE:'localhost'
emailAddress
:IA5STRING:'knightma@yeah.net'
Certificate is to be certified until Nov 21
11:58:38 2007 GMT (365 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit?
[y/n]y
Write out database with 1 new entries
Data Base Updated
CA verifying: server.crt <-> CA cert
server.crt: OK

(2)接下来要按照/etc/httpd/extra/httpd-ssl.conf里面的设置,将证书放在适当的位置。
#cp ./server.key /etc/httpd
#cp ./server.crt /etc/httpd
#cd ..
#chmod 400 server.key

(3)编辑/etc/httpd/httpd.conf
找到如下一句,将前面的注释#去掉
#Include /etc/httpd/extra/httpd-ssl.conf
而后重启apache即可
#killall -9 httpd
#/usr/local/apache/bin/apachectl start

(4)查看监听端口,确认里面有:443端口
#netstat -tnl

(5)https://你的主机IP地址

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值