[兄弟连]LAMP环境编译中的脚本

在编译这些源码包之前,我们需要确认系统中有gcc,gcc-c++,make编译器,一般系统都自带了gcc和make编译器,所以我们只要安装gcc.

Shell> sudo apt-get installbuild-essentia ;

 

一般安装一个源码包的过程是:

1.解压源码包的tar.gz文件,如 tar -xvf mysql.tar.gz -C /opt/lamp,其中tar命令中的-C是指定解压路径.其实我们完全可以写一个shell脚本进行解压.

2.配置源码,使用命令 ./configure

3.编译源码,使用命令 make

4.安装,使用 make install

 

现在我们开始安装lamp环境,在此之前,我们需要安装一系列的必须库.

 

安装libxml2

1.进入libxml2源码包目录,进行配置设置安装的路径

Shell> ./configure--prefix=/usr/local/libxml2

2.使用make编译

3.使用makeinstall 安装

:在编译libxml2,由于nanohttp.c中的open函数有问题,所以我们需要修改nanohttp.c的源代码,1588行给open加上第三个参数0777就行了.

 

安装libmcrypt

1.进入libmcrypt源码包目录,进行配置设置安装

Shell> ./configure--prefix=/usr/local/libmcrypt

2.使用make编译

3.使用makeinstall安装

4.但是需要注意的是在此目录下还有一个libltdl目录,里面的源码也需要进行编译.执行如下命令 ./configure --enable-ltdl-install ; make ; make install.

 

安装zlib

因为这个库是很多库安装必须要的,所以建议安装这个库的时候,按照默认的安装路径即可.执行如下命令 ./configure ; make ; make install

 

安装libpng

因为前面我们安装的zlib使用的是默认路径安装,所以这个配置就不需要指定zlib目录了,直接执行如下命令  ./configure--prefix=/usr/local/libpng ; make ; make install

 

 

安装jpeg-6b

因为这个在安装的过程中不能自动创建目录,所以我们必须提给它安装好必须的目录.

Shell> mkdir /usr/local/jpeg6

Shell> mkdir/usr/local/jpeg6/bin

Shell> mkdir/usr/local/jpeg6/lib

Shell> mkdir/usr/local/jpeg6/include

Shell> mkdir -p/usr/local/jpeg6/man/man1  这里-p表示递归创建man目录后再创建man1目录

然后开始配置,编译,安装命令如下 ./configure --prefix=/usr/local/jpeg6 --enable-shared--enable-static ; make ; make install

安装freetype

按顺序配置,编译和安装:./configure --prefix=/usr/local/freetype ; make ;make install

 

安装autoconf

同zlib一样,建议按默认安装路径执行.命令如下:  ./configure ;make ; make install

 

安装gd

在安装这个库的时候,我们需要指定前面的3个库jpeg6,freetype和zlib.但是由于zlib是默认路径,就不需要特指出来.命令如下

./configure--prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6--with-freetype=/usr/local/freetype ; make ; make install

 

安装httpd(apache)

./configure--prefix=/usr/local/apache2 --sysconfdir=/etc/httpd/ --with-included-apr --disable-userdir--enable-so --enable-deflate=shared --enable-expires=shared--enable-rewrite=shared --enable-static-support ; make  ;  make install

检测是否安装成功,启动apache:  /usr/local/apache/bin/apachectlstart   查找进程,如果有则安装成功    ps aux | grephttpd

最后在浏览器上输入你的IP地址看是否成功.

:有很多教程就在配置的时候加了 --with-z=/usr/local/zlib,但是因为我们已经把zlib安装在默认路径,所以在这里我们就不必加了。

如果在我们执行的时候,提示mod_rewrite.so或更多模块没有权限启动.则我们可以用这个命令解决:chcon -t texrel_shlib_t /usr/local/apache/modules/mod_name

 

安装mysql

1.在安装mysql的过程中,很容易出错,因为在安装mysql之前,我们必须要先安装编译一个ncurses.

安装ncurses

./configure --with-shared--without-debug --without-ada --enable-overwrite ; make ; make install

2.创建用户和用户组

Shell> groupadd mysql

Shell> useradd -g mysql mysql

3.开始安装mysql

./configure--prefix=/usr/local/mysql --with-extra-charsets=all ; make ; make install

4.把mysql源码里面support-files目录下的配置文件复制到/etc/目录下,生成配置文件

Shell> cp my-medium.cnf/etc/my.cnf

5.创建mysql数据库的授权表

Shell>/usr/local/mysql/bin/mysql_install_db --user=mysql

6.然后修改mysql数据目录的拥有者和拥有组

Shell> chown -R root/usr/local/mysql

Shell> chown -R mysql /usr/local/mysql/var

Shell> chgrp -R mysql/usr/local/mysql

7.启动mysql

Shell>/usr/local/mysql/bin/mysqld_safe --user=mysql &

8.检查是否启动了

Shell> ps aux | grep mysql

可以使用mysqladmin查看所有的参数

Shell> ./mysqladmin variables

然后设置密码

Shell> ./mysqladmin -urootpassword xiaozhe

9.设置开机自动启动

我们可以把这些启动命令写入系统每次开机时读取的文件如/etc/rc.d/rc.local,然后执行如下命令:

echo"/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local

或者贝源码中自带的一个mysql.server文件拷贝到init.d目录下,可以重新取名.

Shell>cp/opt/lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld

修改这个文件的权限和所有权

Shell> chown root.root/etc/rc.d/init.d/mysqld

Shell> chmod 755/etc/rc.d/init.d/mysqld

使用chkconfig命令,没用过,我要学习这个命令

chkconfig --add mysqld

chkconfig --list mysqld

修改运行的等级

chkconfig --levels 245 mysqld off

 

 

安装php

1.进行配置,编译和安装

./configure--prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/--with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/--with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/--with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap--enable-mbstring=all --enable-sockets ; make ; make install

2.将php源码包里面的配置文件复制到php配置目录里面

Shell> cp php.ini-dist/usr/local/php/etc/php.ini

3.修改apache配置文件增加执行php

AddType application/x-httpd-php.php .phtml

4.重启服务器

Shell>/usr/local/apache2/bin/apachectl restart

5.写一个php文件测试一下

vim/usr/local/apache2/htdocs/phpinfo.php

 

安装zend加速器

直接进入ZendOptimizer加速器目录,然后./install.sh

后面一切按配置自己修改

 

安装phpMyadmin

1.直接将phpmyadmin文件夹复制到htdocs目录下

Shell>cp -aphpMyAdmin-3.0.0-rc1-all-languages /usr/local/apache2/htdocs/phpmyadmin

2.进入phpmyadmin目录,重命名配置文件

Shell> cp config.sample.inc.phpconfig.inc.php

3.修改配置文件,将auth_type为http即可

4.然后在浏览器打开phpmyadmin找到index文件点进即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值