码迷,mamicode.com
首页 > 其他好文 > 详细

LAMP环境

时间:2016-08-04 19:16:40      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

一、           实验步骤及结果

第一阶段

                                                        搭建LAMP环境

 

Hostname

OS

IP

Software

www.benet.com

 

CentOS-6.5

10.0.0.2

Httpd-2.2.17.tar.gz/Mysql-5.1.55.tar.gz/libmcrypt-2.5.8.tar.gz

mhash-0.9.9.9.tar.gz/mcrypt-2.6.8.tar.gz/php-5.3.6.tar.gz

ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz

 

关闭防火墙:service iptables stop

编译安装Apache

[root@www /]# yum remove –y httpd                                    //卸载原有httpd服务

[root@www /]# tar zxvf httpd-2.2.17.tar.gz -C /usr/src/

[root@www /]# cd /usr/src/httpd-2.2.17/

[root@www httpd-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite && make && make install

[root@www httpd-2.2.17]# ln -s /usr/local/httpd/bin/* /usr/local/bin/

[root@www ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

#chkconfig: 35 80 25

#description: Apache Server

[root@www ~]# vim /usr/local/httpd/conf/httpd.conf

ServerName www.benet.com:80

[root@www ~]# vim /etc/hosts

10.0.0.2    www.benet.com

[root@www ~]# chkconfig --add httpd

[root@www ~]# chkconfig --list httpd

httpd             0:off       1:off       2:off       3:on 4:off       5:on 6:off

[root@www ~]# /etc/init.d/httpd start

[root@www ~]# netstat -anpt |grep httpd

tcp        0      0 :::80                       :::*                        LISTEN      68073/httpd

[root@www ~]# elinks http://www.benet.com

       It works!

 

编译安装Mysql

[root@www ~]# yum remove -y mysql-server mysql                //卸载原有的mysql

[root@www /]# tar zxvf cmake-2.8.5.tar.gz -C /usr/src/            //mysql5.5需要cmake编译

[root@www /]# cd /usr/src/cmake-2.8.5/

[root@www cmake-2.8.5]# ./configure && gmake && gmake install

[root@www /]# useradd -M -s /sbin/nologin mysql                   //创建mysql运行用户

 

yum -y install ncurses-devel

[root@www /]# tar zxvf mysql-5.5.22.tar.gz –C /usr/src

[root@www /]# cd /usr/src/mysql-5.5.22/

[root@www mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc

[root@www mysql-5.5.22]# make && make install

[root@www ~]# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf        //复制配置文件模板

cp: overwrite `/etc/my.cnf‘? y

[root@www ~]# chown -R mysql.mysql /usr/local/mysql/                                     //修改属主属组

[root@www ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/                                                        //以mysql用户初始化数据库

[root@www ~]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile             //设置环境变量

[root@www ~]# . /etc/profile                                                 //立即生效

[root@www ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld          //添加启动脚本

[root@www ~]# chmod +x /etc/init.d/mysqld                   //添加执行权限

[root@www ~]# chkconfig --add mysqld                          //添加到服务

[root@www ~]# /etc/init.d/mysqld start

Starting MySQL....                                         [  OK  ]

[root@www ~]# netstat -anpt |grep mysql

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      64808/mysqld

 

编译安装PHP

yum install libxml2-devel libpng-devel pcre-devel

准备工作,安装libmcrypt、mhash、mcrypt

[root@www /]# tar zxvf libmcrypt-2.5.8.tar.gz -C /usr/src/

[root@www /]# cd /usr/src/libmcrypt-2.5.8/

[root@www libmcrypt-2.5.8]# ./configure && make && make install

[root@www libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib/

 

[root@www /]# tar zxvf mhash-0.9.9.9.tar.gz -C /usr/src/

[root@www /]# cd /usr/src/mhash-0.9.9.9/

[root@www mhash-0.9.9.9]# ./configure && make && make install

[root@www mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib

 

[root@www /]# tar zxvf mcrypt-2.6.8.tar.gz -C /usr/src/

[root@www /]# cd /usr/src/mcrypt-2.6.8/

解决mcrypt进行配置./configure报错

[root@www mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

[root@www mcrypt-2.6.8]# ./configure && make && make install

 

安装PHP

[root@www /]# tar zxvf php-5.3.6.tar.gz -C /usr/src/

[root@www /]# cd /usr/src/php-5.3.6/

[root@www php-5.3.6]# ./configure --prefix=/usr/local/php --with-gd --with-zlib --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib

[root@www php-5.3.6]# make && make install

## 优化php执行路径 ##

[root@LNMP ~]# ln -s /usr/local/php/bin/* /usr/local/bin/

[root@LNMP ~]# ln -s /usr/local/php/sbin/* /usr/local/sbin/

## 生成PHP主配置文件并进行修改 ##

 

 

注:主配置文件  cp php-5.3.28/php.ini-development /usr/local/php5/php.ini

 

 

[root@LNMP ~]# cd /usr/local/php/etc/

[root@LNMP etc]# cp php-fpm.conf.default php-fpm.conf

[root@LNMP etc]# useradd -M -s /sbin/nologin php

[root@LNMP etc]# vim php-fpm.conf

pid = run/php-fpm.pid                               //确认pid文件位置

user = php                                                //运行用户改为php

group = php                                              //运行组改为php

pm.start_servers = 20                                 //启动时开启的进程数

pm.min_spare_servers = 5                          //最小空闲进程数

pm.max_spare_servers = 35                        //最大空闲进程数

       pm.max_children = 50

 

优化ZendGuardLoader

[root@www /]# tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz -C /usr/src/

[root@www /]# cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/

[root@www php-5.3.x]# cp ZendGuardLoader.so /usr/local/php5/lib/php/

[root@www /]# vim /usr/local/php5/php.ini

zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so

zend_loader.enable=1

[root@www /]# vim /usr/local/httpd/conf/httpd.conf

AddType application/x-httpd-php .php

 

<IfModule dir_module>

    DirectoryIndex index.html index.php

</IfModule>

[root@www /]# /etc/init.d/httpd restart

[root@www /]# vim /usr/local/httpd/htdocs/test1.php

<?php

phpinfo();

?>

[root@www /]# vim /usr/local/httpd/htdocs/test2.php

<?php

$link=mysql_connect(‘localhost‘,‘root‘,‘aptech‘);

if($link)

echo "Mysql OK~~~";

mysql_close();

?>

 

打开客户端分别访问www.benet.com/test1.php、www.benet.com/test2.php。

LAMP环境

标签:

原文地址:http://www.cnblogs.com/baishuchao/p/5737736.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!