LAMP环境的搭建

时间:2021-09-22 03:16:25
一、mysql的安装
1、tar -zxvf mysql.gz
2、mv mysql-5.1.49-linux-i686-glibc23/ /usr/local/mysql
3、cd /usr/local/mysql
4、useradd -s /sbin/nologin -M mysql
5、mkdir -p /data/mysql
6、chown -R mysql:mysql /data/mysql/
7、./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
8、cp support-files/my-large.cnf /etc/my.cnf
vim /etc/my.cnf
把#log-bin=mysql-bin
#binlog_format=mixed
#server-id      = 1这三行注释掉
9、cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
把basedir=/usr/local/mysql
datadir=/data/mysql加上
10、service mysqld start
11、/usr/local/mysql/bin/mysql
二、Apache的安装
1、tar -zxvf apache.gz

2、 cd httpd-2.2.31/

../configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared 

中间有几处错误,缺失的可以 yum list |grep ***然后再yum install -y **-devel的安装上再重新编译即可
3、make
4、make install
三、PHP的安装
1、tar -jxvf php.bz2
2、cd php
3、./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
4、yum list |grep libxml2
 yum install -y libxml2-devel.i686
5、yum list |grep openssl
yum install -y openssl-devel.i686
6、yum list |grep bzip2
yum install -y bzip2-devel.i686
7、yum list |grep jpeg
yum install -y libjpeg-turbo-devel.i686 openjpeg-devel.i686
8、yum list |grep png
yum install -y libpng-devel.i686
9、yum list |grep freetype
yum install -y freetype-devel.i686
10、yum list |grep mcrypt
 rpm -ivh 'http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm'
yum list |grep mcrypt
yum install -y libmcrypt-devel.i386
11、make && make install
12、cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/apache2/conf/httpd.conf
AddType application/x-httpd-php .php




四、测试是否搭建成功
1、/usr/local/apache2/bin/apachectl -t这个命令查看是否有错。Syntax OK 说明没错/
2、/usr/local/apache2/bin/apachectl start
3、vim /usr/local/apache2/htdocs/1.php
<?php
echo phpinfo();
?>
4、  去浏览器访问或curl localhost/1.php




五、/usr/local/php/bin/php -m
cat /usr/local/apache2/build/config.nice 查看Apache的编译参数
cat /usr/local/mysql/bin/mysqlbug |grep config 查看mysql 的编译参数
/usr/local/php/bin/php -i |less查看PHP 的编译参数