首页 运维 正文
LAMP安装手册

 2022-10-23    326  

  LAMP安装手册 :

  一、主要软件包

LAMP安装手册

  1. httpd-2.2.6.tar.gz

  2. mysql-5.0.45-linux-i686-glibc23.tar.gz ( 这个版本是已编译好的压缩包,解压后稍做配置即可使用 )

  3. php-5.2.5.tar.gz

  安装 php 所需的软件包(其中 libxml2 是安装 php5 必须的 . )

  1. libxml2-(version).tar.gz —> http://ftp.gnome.org/pub/GNOME/sources/libxm2

  2. libxslt-(version).tar.gz —> http://ftp.gnome.org/pub/GNOME/sources/libxslt

  3. curl-(version).tar.gz —> http://curl.haxx.se/download

  GD 库所需要软件包(有人说 PHP 源码包里自带了 GD2.0.28 和 zlib ,只要安装 GD 的三个支持包: jpg,png 和 freetype ,但是我们还是下载)

  1. gd-(version).tar.gz —> http://www.libgd.org/Main_Page or http://www.libgd.org/releases/

  2. freetype-(version).tar.gz —> http://sourceforge.net/projects/freetype

  3. jpegsrc.v6b.tar.gz —> http://ijg.org/files/jpegsrc.v6b.tar.gz

  4. libpng-(version).tar.gz —> http://www.libpng.org/pub/png/libpng.html

  5. zlib-1.2.3.tar.gz —> http://www.zlib.net

  把以上所有软件包下载到: /root/Software/ 目录下 .

#p#

  二:安装 mysql

  #tar-zvxfmysql-5.0.45-linux-i686-glibc23.tar.gz 
  •   #mkdir-p/usr/local/mysql
  •   #cp-rmysql-5.0.45/usr/local/mysql
  •   #cp/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d/mysql//开机启动mysql
  •   #cp/usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf
  •   添加 mysql 用户及用户组

      #groupaddmysql 
  •   #useradd-gmysqlmysql
  •   修改 mysql 目录权限

      #chown-Rroot/usr/local/mysql 
  •   #chgrp-Rmysql/usr/local/mysql
  •   #chown-Rmysql/usr/local/mysql/data
  •   生成 mysql 系统数据库

      #/usr/local/mysql/scripts/mysql_install_db--user=mysql&//启动mysql服务 
  •   #/usr/local/mysql/bin/mysqld_safe--user=mysql&
  •   如出现 Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常启动 mysql 服务了 .

      按 Ctrl + C 跳出修改 mysql 的 root 密码

      #/usr/local/mysql/bin/mysqladmin-uroot-ppassword"123456" 
  • #p#

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

      a. 安装 jpeg6 建立目录:

      #mkdir-p/usr/local/jpeg6 
  •   #mkdir-p/usr/local/jpeg6/bin
  •   #mkdir-p/usr/local/jpeg6/lib
  •   #mkdir-p/usr/local/jpeg6/include
  •   #mkdir-p/usr/local/jpeg6/man
  •   #mkdir-p/usr/local/jpeg6/man1
  •   #mkdir-p/usr/local/jpeg6/man/man1
  •   #cd/root/Software/
  •   #tar-zvxfjpegsrc.v6b.tar.gz
  •   #cdjpeg6
  •   #./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-static
  •   #make
  •   #makeinstall
  •   b.libpng 包 ( 支持 PNG)

      #cd/root/Software/ 
  •   #tar-zvxflibpng-(version).tar.gz
  •   #cdlibpng-(version)
  •   #./configure--prefix=/usr/local/libpng
  •   #make
  •   #>makeinstall
  •   c. 安装 freetype

      #cd/root/Software/ 
  •   #tar-zvxffreetype-(version).tar.gz
  •   #cdfreetype-(version)
  •   #mkdir-p/usr/local/freetype
  •   #./configure--prefix=/usr/local/freetype
  •   #make
  •   #makeinstall
  •   d. 安装 zlib

      #cd/root/Software/ 
  •   #tar-zxvfzlib-1.2.3.tar.gz
  •   #cdzlib.1.2.3
  •   #mkdir/usr/local/zlib
  •   #./configure--prefix=/usr/local/zlib
  •   #make
  •   #makeinstall
  •   e. 安装 GD 库

      #cd/root/Software/ 
  •   #tar-zvxfgd-(version).tar.gz
  •   #mkdir-p/usr/local/gd2
  •   #cdgd-(version)
  •   #./configure--prefix=/usr/local/gd2--with-jpeg=/usr/local/jpeg6--with-zlib-dir=/usr/local/zlib--with-png=/usr/local/libpng--with-freetype=/usr/local/freetype
  •   #make
  •   #makeinstall
  •   e. 安装 Curl 库

      #cd/root/Software/ 
  •   #tar-zxfcurl-(version).tar.gz
  •   #mkdir-p/usr/local/curl
  •   #./configure--prefix=/usr/local/curl
  •   #make
  •   #makeinstall
  • #p#

      四:安装 apache2

      #cd/roo/Software/ 
  •   #tar-zvxfhttpd-2.2.6.tar.gz
  •   #cdhttpd-2.2.6
  •   #mkdir-p/usr/local/apache2
  •   #./configure--prefix=/usr/local/apache--enable-modules=so--enable-rewrite
  •   #make
  •   #makeinstall
  •   #/usr/local/apache2/bin/apachectl-kstart//启动apahce
  •   用浏览器查看 http://localhost, 得到 it works ,说明 apache 已经配置成功了 .

      #/usr/local/apache2/bin/apachectl-kstop//停止apache 
  • #p#

      五:安装 php5

      php5 必须有 libxml2 支持 !

      a. 安装 libxml2

      #cd/root/Software/ 
  •   #tar-zvxflibxml2-(version).tar.gz
  •   #cdlibxml2-(version)
  •   #mkdir-p/usr/local/libxml2
  •   #./configure--prefix=/usr/local/libxml2
  •   #make
  •   #makeinstall
  •   b. 安装 libxslt ( 可选安装,你可以不安装 )

      #cd/root/Software/ 
  •   #tar-zvxflibxslt-(version).tar.gz
  •   #mkdir-p/usr/local/libxslt
  •   #cdlibxslt-(version)
  •   #./configure--prefix=/usr/local/libxslt--with-libxml-prefix=/usr/local/libxml2
  •   #make
  •   #makeinstall
  •   c. 安装 php5

      #cd/root/Software/ 
  •   #tar-zvxfphp-(version).tar.gz
  •   #mkdir-p/usr/local/php5
  •   #cdphp-(version)
  •   #./configure--prefix=/usr/local/php5--with-apxs2=/usr/local/apache2/bin/apxs\
  •   >--with-gd=/usr/local/gd2--with-jpeg-dir=/usr/local/jpeg6\ 
  •   >--with-zlib-dir=/usr/local/zlib\
  •   >--with-png-dir=/usr/local/libpng\
  •   >--with-freetype-dir=/usr/local/freetype-\
  •   >--enable-trace-vars--with-mysql=/usr/local/mysql\
  •   >--enable-mbstring=all--with-curl=/usr/local/curl--enable-mbregex\
  •   >--with-config-file-path=/usr/local/php5--enable-ftp\
  •   >--enable-soap--with-xsl=/usr/local/libxslt
  •   #make
  •   #makeinstall
  •   #cpphp.ini-dist/usr/local/php5/php.ini
  • #p#

      六:重新配置 apache2 让他支持 php

      #cd/usr/local/apache2/conf 
  •   #vimhttpd.conf
  •   在LoadModulephp5_modulemodules/libphp5.so
  •   添加 AddType application/x-httpd-php .php

      OK, 基本的安装已经完成 .

      重新起动 APACHE:

      #/usr/local/apache2/bin/apachectlstart 
  •   如果重新起动 APACHE 出现 :

      Syntaxerroronline232of/usr/local/apache2/conf/httpd.conf:Cannotload/usr/local/apache2/modules/libphp5.sointoserver: 
  •   /usr/local/apache2/modules/libphp4.so:cannotrestoresegmentprotafterreloc:Permissiondenied
  •   那就要按照下面的方法解决 :

      1.chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so

      2. 编辑 /etc/selinux/config ,找到这段:

      #ThisfilecontrolsthestateofSELinuxonthesystem. 
  •   #SELINUX=cantakeoneofthesethreevalues:
  •   #enforcing-SELinuxsecuritypolicyisenforced.
  •   #permissive-SELinuxprintswarningsinsteadofenforcing.
  •   #disabled-SELinuxisfullydisabled.
  •   SELINUX=enforcing
  •   把 SELINUX=enforcing 注释掉: #SELINUX=enforcing ,然后新加一行为:

      SELINUX=disabled

      保存,关闭。

      编辑 /etc/sysconfig/selinux ,找到 :

      #ThisfilecontrolsthestateofSELinuxonthesystem. 
  •   #SELINUX=cantakeoneofthesethreevalues:
  •   #enforcing-SELinuxsecuritypolicyisenforced.
  •   #permissive-SELinuxprintswarningsinsteadofenforcing.
  •   #disabled-SELinuxisfullydisabled.
  •   SELINUX=enforcing
  •   如果 SELINUX 已经是 SELINUX=disabled ,那么就不用改了,否则就把 SELINUX=enforcing 注释掉,新加一行:

      SELINUX=disabled
  •   保存,退出。

    原文链接:https://77isp.com/post/8457.html

    =========================================

    https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。