lamp环境搭建详细文档

  1. 云栖社区>
  2. 博客>
  3. 正文

lamp环境搭建详细文档

技术小阿哥 2017-11-27 16:48:00 浏览798
展开阅读全文

1 /usr/local下自带的目录文件有

:bin etc games include lib libexec sbin share src
2 准备安装工具:gcc gcc-c++ make
检查工具是否安装 rpm -q make ; rpm -q gcc ; rpm -q gcc-c++
3 安装工具有两种方法,rpm(会有很多依赖关系需要解决) yum(yum能解决依赖关系,推荐使用)
   挂载光盘,1创建一个空目录 mkdir /mnt/cdrom
           2 挂载光盘 mount /dev/cdrom /mnt/cdrom
           3 确定是否有你需要的软件 rpm -i /mnt/cdrom/CentOS/gcc (敲两下talbe键,会列出所有gcc开头的文件)

4 不能上网的用户,可以将光盘作为yum源
 /etc/yum.repos.d/ 下有两个配置文件,更改CentOS-Media.repo光盘做为yum源
 将enabled=0,改为1,将baseurl第一个改为 file:///mnt/cdrom/(挂载光盘的路径)
 并将mv /etc/yum.repos.d/CentOS-Base.repo /backup剪切走,这样缺省的就是使用光盘的yum源
5 yum install gcc; yum install gcc-c++ 直接就能安装了
6 rpm -qa | grep httpd列出系统所有安装的apache
  rpm -qa | grep mysql
  rpm -qa | grep php
7 卸载掉系统自带的apache myslq php,先确保这些服务都停止了,启动了要关闭 service httpd stop
service httpd status 查看apache是否启动了,没有启动就没有影响
使用 rpm -e 文件名 --nodeps,就可以卸载掉了
8 关闭SELinux 
vi /etc/sysconfig/selinux  设置SELINUX=disabled后重新启动系统
9 关闭防火墙 iptables -F
10 解压缩的shell脚本 vi tar.sh
cd /usr/local/src   #切换到安装文件目录
ls *.tar.gz > ls.list # 列出文件名到ls.list文件
for TAR in `cat ls.list`
do
    tar -zxf $TAR
done
执行 sh -x tar.sh

11 安装源码包分4步
    1 tar -zxf 解压解包
    2 ./configure 配置
    3 make 编译过程
    4 make install 安装、拷贝的过程


################################
真正的安装
################################
./configure --help查看帮助,最后提示信息error要特别关注
卸载安装文件:1 将安装目录删除掉 rm -rf /usr/local/libxml2
             2 将源代码包也删除掉 rm -rf /lamp/libxml2-2.6.30
卸载apache要卸载的话,要将apache的进程停掉,在卸载
ps -le | grep httpd #检测apache是否启动
ps -le | grep mysqld 


cd /lamp/libxml2-2.6.30
./configure --prefix=/usr/local/libxml2/
make 
make install
 
cd /lamp/libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt/
make 
make install

cd /lamp/libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make
make install

cd /lamp/zlib-1.2.3
./configure
make
make install 

cd /lamp/libpng-1.2.31
./configure --prefix=/usr/local/libpng/
make
make install

mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1   #递归创建
cd /lamp/jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install

cd /lamp/freetype-2.3.5
./configure --prefix=/usr/local/freetype/
make
make install

cd /lamp/autoconf-2.61
./configure
make 
make install
 
cd /lamp/gd-2.0.35
./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/
make
make install


#注意zlib库安装时候没指定路径的话,这儿就不需要配置
cd /lamp/httpd-2.2.9
./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
 
/usr/local/apache2/bin/apachectl start
ps -le | grep httpd #检测apache是否启动
netstat -tnl | grep 80 #检测apache是否启动
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit #apache开机自动启动

cd /lamp/ncurses-5.6 # 不安装的话,安装mysql可能有问题
./configure --with-shared --without-debug --without-ada --enable-overwrite
make 
make install

groupadd mysql
useradd -g mysql mysql
cd /lamp/mysql-5.0.41
./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all
make
make install

cp support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql

/usr/local/mysql/bin/mysqld_safe  --user=mysql & #启动mysql

检测mysql 进程是否存在
ps -le | grep mysqld     ;  netstat -tnl|grep 3306


删除匿名用户 
/usr/local/mysql/bin/mysql -u root
DELETE FROM mysql.user WHERE Host='localhost' AND User='';
FLUSH PRIVILEGES;
为root用户添加密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('sursen-du8');
连接数据库
/usr/local/mysql/bin/mysql -u root -h localhost -p
关闭数据库
/usr/local/mysql/bin/mysqladmin -u root -p shudown


# 可以不用设置
cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld #启动系统后自动启动mysql
chown root.root /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
chkconfig --levels 245 mysqld off
 
#注意zlib库安装时候没指定路径的话,这儿就不需要配置
如果提示缺少libtool 安装下就好了  yum install libtool   yum install libtool-ltdl
cd /lamp/php-5.2.6
./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

cp php.ini-dist /usr/local/php/etc/php.ini # 创建配置文件

vi /etc/httpd/httpd.conf #编辑apache配置文件
在AddType下添加一行
Addtype application/x-httpd-php .php .phtml
/usr/local/apache2/bin/apachectl restart

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


出自:http://huxiuchen.blog.163.com/blog/static/42127336201181623728422/

网友评论

登录后评论
0/500
评论
技术小阿哥
+ 关注