搭建LAMP 笔记

本文详细介绍了如何下载并安装MySQL-5.1.58、php-5.2.17、httpd-2.2.19源码,并通过编译安装完成配置,同时安装了APC、mcrypt等扩展库,最终通过配置Apache和PHP实现Web服务部署。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 下载源码mysql-5.1.58.tar.gz,php-5.2.17.tar.gz ,httpd-2.2.19.tar.gz
  2. 首先安装mysql (# 为命令提示符)
  3. 先为mysql创建用户和组

#groupadd mysql

#useradd -g mysql mysql

用户和组创建好了,接下来是编译安装

#tar zxvf mysql-5.1.58.tar.gz

#cd mysql-5.1.58

./configure '--prefix=/opt/mysql5' ' 安装路径

--with-charset=utf8' ' 默认支持字符集

--with-extra-charsets=latin1,gbk' 扩展字符集

'--with-mysqld-user=mysql'

'--with-plugins=innodb_plugin,myisam,heap'

#make

#make install

#cp support-file/my-medium.cnf /etc/my.cnf //拷贝配置文件

#cd /opt/mysql5

#bin/mysql_install_db --user=mysql //安装初始化数据库

#chown -R root .

#chown -R mysql var

#chgrp -R mysql .

启动mysql

#cp support-files/mysql.server /etc/init.d/mysqld //拷贝启动脚本

#chmod +x /etc/init.d/mysqld

#cd /etc/init.d

#chkconfig --add mysqld

#/etc/init.d/mysqld start

编译安装apache

#tar zxvf httpd-2.2.19.tar.gz

#cd httpd-2.2.19 #编译和安装 apr 1.2
#cd srclib/apr
#./configure --prefix=/Data/apps/apr-httpd/
#make
#make install

# 编译和安装 apr-util 1.2
#cd ../apr-util
#./configure --prefix=/Data/apps/apr-util-httpd/ --with-apr=/Data/apps/apr-httpd/
#make
#make install

# ./configure

--prefix=/Data/apps/apache2

--with-apr=/Data/apps/apr-httpd

--with-apr-util=/Data/apps/apr-util-httpd

--enable-so --enable-rewrite

--enable-vhost-alias

--enable-deflate

--enable-expires

--with-mpm-prefork

#make

#make install

编译安装PHP

#tar zxvf php-5.2.17.tar.gz

#cd php-5.2.17

./configure'

'--prefix=/Data/apps/php/'

'--with-apxs2=/Data/apps/apache2/bin/apxs'

'--with-mysql=/opt/mysql5'

'--enable-mbstring' '--with-curl'

'--disable-debug'

'--enable-inline-optimization'

'--with-jpeg-dir=/usr/lib' (64)

'--with-png-dir=/usr/lib' (64)

'--enable-ctype'

'--with-bz2'

'--with-zlib'

'--with-gd'

'--with-freetype-dir=/usr/'

'--with-kerberos'

'--with-gettext'

'--enable-force-cgi-redirect'

'--with-iconv'

'--enable-gd-native-ttf'

'--enable-sockets'

'--enable-soap'

'--enable-ftp'

'--with-openssl'

'--enable-zip'

如果出现configure: error: libjpeg.(a|so) not found

执行

cp -frp /usr/lib64/libjpeg.* /usr/lib/

cp -frp /usr/lib64/libpng* /usr/lib/

解决 重新配置 #make

#make install

配置php.ini

#cp php.ini.dist /Data/apps/php/bin/php.ini

安装APC 扩展库

#tar zxvf APC-3.1.9.tgz

#cd APC-3.1.9

#/Data/apps/php/bin/phpize

#./configure

--with-php-config=/Data/apps/php/bin/php-config

--enable-apc

--enable-apc-filehits

#make

#make install

安装mcrypt

#tar zxvf libmcrypt-2.5.8.tar.gz

#cd libmcrypt-2.5.8

#./configure

#make

#make install

#ldconfig

#cd //PHP源码包//

#cd ext/mcrypt

#/Data/apps/php/bin/phpize

#./configure --with-php-config=/Data/apps/php/bin/php-config

#make

#make install

编辑php.ini

更改extension_dir = "/Data/apps/php/lib/php/extensions/no-debug-non-zts-20060613/"
加入extension = "apc.so"
加入extension = "mcrypt.so"

更改include_path = ".:/Data/www/phplibs"

再增加一些安全设置

更改log_errors = On
更改error_log = "/var/log/php-error.log"
更改disable_functions = phpinfo,system,passthru,shell_exec,popen

配置httpd.conf

#vim /Data/apps/apache2/conf/httpd.conf

添加

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

保存重启apache

#/Data/apps/apache2/bin/apachectl restart

写个网页测试一下

<?php

phpinfo();

?>

保存后缀为.php 文件

放在/Data/apps/apache2/htdocs 目录下

浏览器访问 http://IP 能看到PHP配置信息

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值