CentOS下LAMP的安装

运维 系统运维
CentOS下LAMP的安装:LAMP是Linux操作系统,Apache网络服务器,MySQL数据库,Perl、PHP或者Python编程语言。LAMP具有通用、跨平台、高性能、低价格的优势,因此LAMP无论是性能、质量还是价格都是企业搭建网站的首选平台。CentOS下LAMP该如何安装?

基于CentOSLAMP安装

  操作版本:centos 5.2

  下载版本:

  httpd-2.2.11.tar.gz

  php-5.2.9.tar.gz

  mysql-5.1.31.tar.gz

  ZendOptimizer-3.3.3

  phpMyAdmin-3.1.3.tar.gz

  1、mysql的安装

  1.   #wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.31.tar.gz/from/http://mysql.easynet.be/  
  2.  
  3.   #tar -zxvf mysql-5.1.31.tar.gz  
  4.  
  5.   #cd mysql-5.1.31  
  6.  
  7.   #./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --enable-assembler --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile  
  8.  
  9.   #make;make install  
  10.  
  11.   #groupadd mysql  
  12.  
  13.   #useradd -g mysql mysql  
  14.  
  15.   #cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf  
  16.  
  17.   #sed -i 's/skip-federated/#skip-federated/g' /etc/my.cnf  
  18.  
  19.   #/usr/local/mysql/bin/mysql_install_db --user=mysql 
  20.  
  21.   #chmod +w /usr/local/mysql  
  22.  
  23.   #chown -R mysql /usr/local/mysql/var  
  24.  
  25.   #chgrp -R mysql /usr/local/mysql/.  
  26.  
  27.   #cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql  
  28.  
  29.   #chmod 755 /etc/init.d/mysql  
  30.  
  31.   #chkconfig --level 345 mysql on  
  32.  
  33.   #service mysql start  
  34.  
  35.   # /usr/local/mysql/bin/mysqladmin -u root -p password  
  36.  

  设置root密码,但出错:mysql“Access denied for user 'root'@'localhost'”

  解决:

  1.   #/etc/init.d/mysql stop  
  2.  
  3.   # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &;  
  4.  
  5.   #mysql -u root mysql  
  6.  
  7.   mysql> UPDATE user SET Password=PASSWORD('newpassword'where USER='root';  
  8.  
  9.   mysql> FLUSH PRIVILEGES;  
  10.  
  11.   mysql> quit  
  12.  
  13.   # /etc/init.d/mysql restart  
  14.  
  15.   # mysql -uroot -p  
  16.  
  17.   Enter password: <输入新设的密码newpassword>  
  18.  
  19.   mysql>  
  20.  

  加入环境变量:

  export PATH=$PATH:/usr/local/mysql/bin //临时修改的

  若要***生效

  1.   #echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile //***修改的  
  2.  
  3.   #source /etc/profile  
  4.  

#p#

  2、apache的安装

  1.   #tar -zxf httpd-2.2.11.tar.gz  
  2.  
  3.   #cd httpd-2.2.11  
  4.  
  5.   #./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite  
  6.  
  7.   #make; make install  
  8.  

  安装完后

  # vi /usr/local/apache/conf/httpd.conf

  找到 prefork.c 下的

  1.   MaxClients 150  
  2.  

  改为

  1.   ServerLimit 2000  
  2.  
  3.   MaxClients 1000  
  4.  

  apache默认工作在prefork.c模式下,并发进程为150,超过后就无法访问,150是远远不够的,所以这里按自己网站的需求改, 如1000

  由于apache默认***并发进程是 256 所以要先设置 ServerLimit 2000 将服务器可设的***并发数设为2000, 然后再设置***并发数 MaxClients 1000

  找到 #ServerName www.example.com:80 在其下设置 ServerName 如下

  ServerName www.mysite.com

  基中 www.mysite.com 为你网站名,也可用IP代替

  找到 DocumentRoot "/usr/local/apache/htdocs"

  设置你的 WEB 服务器的根目录 如

  DocumentRoot "/myweb"

  找到 DirectoryIndex index.html index.html.var 改为

  1.   DirectoryIndex index.html index.php index.htm  
  2.  

  找到 ForceLanguagePriority Prefer Fallback 在其下加上

  1.   AddDefaultCharset gb2312  
  2.  

  改完后保存(vi 的用法请查 Linux vi 命令)

  用下面命令启动WEB服务器

  1.   # /usr/local/apache/bin/apachectl start  
  2.  

  查看自己的站点是否正常 http://www.mysite.com 也可用IP

  用 # /usr/local/apache/bin/apachectl stop 可停止服务

  此时在浏览器中试试,可能无法访问,这是因为防火墙默认设置全部禁止访问的原因,运行lokkit设置就OK了~

  如何更改了目录:则:加上这一句

  1.   Order allow ,deny  
  2.  
  3.   Allow from all  
  4.  

#p#

  3、PHP的安装

  安装GD库(让PHP支持GIF,PNG,JPEG)

  首先下载 jpeg6,libpng,freetype 并安装模块

  wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz

  wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz

  wget http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.9.tar.gz

  wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz

  安装 jpeg6

  建立目录

  1.   # mkdir /usr/local/jpeg6  
  2.  
  3.   # mkdir /usr/local/jpeg6/bin  
  4.  
  5.   # mkdir /usr/local/jpeg6/lib  
  6.  
  7.   # mkdir /usr/local/jpeg6/include  
  8.  
  9.   # mkdir /usr/local/jpeg6/man  
  10.  
  11.   # mkdir /usr/local/jpeg6/man/man1  
  12.  
  13.   # cd /tmp  
  14.  
  15.   # tar -zxf jpegsrc.v6b.tar.gz  
  16.  
  17.   # cd jpeg-6b  
  18.  
  19.   # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static  
  20.  
  21.   # make; make install  
  22.  

  安装libpng

  1.   # cd /tmp  
  2.  
  3.   # tar -zxf libpng-1.2.8.tar.gz  
  4.  
  5.   # cd libpng-1.2.8  
  6.  
  7.   # cp scrīpts/makefile.std makefile  
  8.  
  9.   # make; make install  
  10.  

  安装 freetype

  1.   # cd /root/soft  
  2.  
  3.   # tar -zxf freetype-2.1.10.tar.gz  
  4.  
  5.   # cd freetype-2.1.10  
  6.  
  7.   # ./configure --prefix=/usr/local/freetype  
  8.  
  9.   # make;make install  
  10.  

  安装***的GD库

  1.   # cd /tmp  
  2.  
  3.   # tar -zxf gd-2.0.33.tar.gz  
  4.  
  5.   # cd gd-2.0.33  
  6.  
  7.   # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/  
  8.  
  9.   # make; make install  
  10.  

  由于php5需libxml2的支持, 所以先下载并安装libxml2

  1.   # cd /tmp  
  2.  
  3.   # wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.30.tar.gz  
  4.  
  5.   # tar -zxf libxml2-2.6.19.tar.gz  
  6.  
  7.   # cd libxml2-2.6.19  
  8.  
  9.   # ./configure --prefix=/usr/local/libxml2  
  10.  
  11.   # make; make install  
  12.  

  安装 libxslt

  1.   # cd /tmp  
  2.  
  3.   # wget http://ftp.gnome.org/pub/gnome/sources/libxslt/1.1/libxslt-1.1.22.tar.gz  
  4.  
  5.   # tar -zxf libxslt-1.1.22.tar.gz  
  6.  
  7.   # cd libxslt-1.1.22  
  8.  
  9.   # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2  
  10.  
  11.   # make; make install  
  12.  

  终于要安装PHP了:

  1.   # tar -zxf php-5.2.3.tar.gz  
  2.  
  3.   # cd php-5.2.3  
  4.  
  5.   # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring  
  6.  
  7.   # make  
  8.  
  9.   # make install  
  10.  

  其中./configure 后的

  --prefix=/usr/local/php5

  --with-apxs2=/usr/local/apache/bin/apxs

  --with-mysql=/usr/local/mysql/

  --with-libxml-dir=/usr/local/libxml2

  是必要的选项

  --with-gd=/usr/local/gd2/

  --with-jpeg-dir=/usr/local/jpeg6/

  --with-png

  --with-zlib-dir=/usr/lib

  --with-freetype-dir=/usr/local/freetype

  这是让PHP支持GD库的配置选项

  配置 httpd.conf 让apache支持PHP

  1.   # vi /usr/local/apache/conf/httpd.conf  
  2.  

  找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容

  AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps在你Web目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确

  安装 phpmyadmin

  下载

  1.   # tar zxvf phpMyAdmin-2.11.2-all-languages.tar.gz  
  2.  
  3.   # mv phpMyAdmin-2.11.2-all-languages /usr/local/httpd/htdocs/phpmyadmin  
  4.  
  5.   # cd /usr/local/httpd/htdocs/phpmyadmin  
  6.  
  7.   # cp ./libraries/config.default.php ./config.inc.php  
  8.  
  9.   #vi config.inc.php  
  10.  
  11.   $cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin';  
  12.  
  13.   $cfg['Servers'][$i]['auth_type'] = 'http';  
  14.  

  安装zend:

  1.   # tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz  
  2.  
  3.   # cd ZendOptimizer-3.2.2-linux-glibc21  
  4.  
  5.   # ./install.sh  
  6.  

  OK,CentOS下LAMP安装成功~!

【编辑推荐】

Ubuntu下LAMP的配置

如何在Linux下安装lamp

使用yum安装LAMP的方法

责任编辑:zhaolei 来源: javaeye
相关推荐

2011-03-10 15:44:18

CentOSLAMP安装

2011-03-11 09:54:48

CentOSLAMP安装

2011-03-11 12:57:34

2011-03-09 16:16:56

CentOSLAMP

2011-03-09 16:16:54

CentOSLAMP

2011-03-09 13:03:15

Centos搭建LAMP

2011-03-11 17:14:27

2011-03-09 10:52:04

ContOSLAMP安装

2011-03-09 13:46:47

SUSElamp安装

2011-03-09 10:52:36

CentOS安装LAMP

2011-03-14 13:07:23

Ubuntu安装LAMP

2011-03-11 12:57:30

CentosLAMP

2011-03-09 10:25:25

Linux安装LAMP

2011-03-09 13:02:15

LinuxLAMP安装

2011-03-11 10:39:09

CentOS 5.5安装LAMP

2011-09-09 17:23:53

CentOSLAMPmysql

2011-03-09 16:16:57

CentOSLAMP

2011-03-10 08:59:04

Ubuntu安装LAMP

2011-03-21 16:21:21

ubuntulamp

2011-03-08 10:44:26

Red Hat安装LAMP
点赞
收藏

51CTO技术栈公众号