设为首页 收藏本站
查看: 635|回复: 0

[经验分享] centos6.5安装 LAMP环境搭建

[复制链接]

尚未签到

发表于 2018-4-27 13:08:42 | 显示全部楼层 |阅读模式
  mysql用的二进制包安装。 Apache php 用的源码包
  mysql版本5.5.46    Apache版本2.4.7  PHP版本:5.5
  安装mysql
  mysql下载地址:http://mirrors.sohu.com/mysql/MySQL-5.5/
  初始化
  [root@localhost lamp]# tar zxvf mysql-5.5.46-linux2.6-x86_64.tar.gz   #解压   
  [root@localhost lamp]# mv mysql-5.5.46-linux2.6-x86_64  /usr/local/mysql   #移动位置,并去掉版本好
  [root@localhost lamp]# useradd -s /sbin/nologin -M mysql    #增加mysql用户。 不能登录 不创建家目录
  [root@localhost lamp]# mkdir -p /data/mysql    #创建datadir  数据库文件会放在这里
  [root@localhost lamp]# chown -R mysql:mysql /data/mysql/    #更改属组 属主
  [root@localhost lamp]# cd /usr/local/mysql/                #进入目录
  [root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql    --user定义数据库的所属主,--datadir 定义安装目录
                                     
  接下来会看到有两个OK.说明执行正确。
  

  [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
  #复制启动脚本文件
  [root@localhost mysql]# chmod 755 /etc/init.d/mysqld
  # 修改启动脚本权限
  [root@localhost mysql]# vim /etc/init.d/mysqld
  #修改启动脚本。 找到bashedir 增加下面的路径
  basedir=/usr/local/mysql    # 安装位置
  datadir=/data/mysql          # 数据库位置
  然后把启动脚本加入系统服务项,设定开机启动
  chkconfig --add mysqld
  chkconfig mysqld on
  service mysqld start
  如果启动不了。请到/data/mysql 目录下查看错误日志。这个日志通常是主机名.err。
  检查MYSQL石否启动的命令为:
  ps aux |grep mysqld
  netstat -an |grep 3306
  

  

  安装Apache2.4.7版本。
  下载地址为:http://mirrors.sohu.com/apache/
  tar zxvf httpd-2.4.7.tar.gz     #解压文件
  cd httpd-2.4.7               #进入目录
  ./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared   #编译参数
  错误
  configure: error:Bundled APR requested but not found at./srclib/.

    tar zxvf apr-1.4.6.tar.gz     #解压apr包
    tar -zxvf apr-util-1.4.1.tar.gz   #解压apr-util包
    cp -r /lamp/apr-1.4.6 /lamp/httpd-2.4.7/srclib/apr
    cp -r /lamp/apr-util-1.4.1 /lamp/httpd-2.4.7/srclib/apr-util    # 然后把两个包复制到httpd-2.4.7/srclib/ 里面并且取消版本号。
  

  错误:
  configure: error: in `/lamp/httpd-2.4.7/srclib/apr':
  configure: error: no acceptable C compiler found in $PATH
  See `config.log' for more details
  configure failed for srclib/apr
  

  yum -y install gcc-c++   #安装 gcc
  错误:
  configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
  tar zxvf pcre-8.34.tar.gz
  [root@localhost lamp]# cd pcre-8.34
  [root@localhost pcre-8.34]# ./configure  && make &&  make install
  

  错误
  checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
  

  yum -y install openssl-devel   #yum安装
  

  把上面4个错误解决后。重新 ./configure 参数编译 无问题就执行
  make
  make install
  

  /usr/local/apache2/bin/apachectl start         # 启动apache
  启动完后用以下命令检查apache是否正常启动,
  ps aux |grep httpd
  netstat -an |grep :80
  

  如果不能启动 请清空防火墙规格。关闭selinux
  防火墙清空命令如下,关闭selinux 请修改selinux配置文件。
  iptables -F
  service iptables save
  

  通过浏览器输入地址访问:http://192.168.137.30 (我服务器的地址)  。若能显示“It works”表明apache正常工作。
  设置Apache系统开机是自动开启。
  vim /etc/rc.d/rc.local
  增加一行 把下面增加进去。
  /usr/local/apache2/bin/apachectl start   

  

  安装php5.5版本
  tar zxvf php-5.5.9.tar.gz  #解压php安装包
  cd php-5.5.9  #进入php文件
  ./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  --with-mcrypt=/usr/local/libmcrypt/    #编译参数
  

以下***为解决方法。
错误
configure: error: xml2-config not found. Please check your libxml2 installation.
yum install -y libxml2-devel
错误
  configure: error: Please reinstall the BZip2 distribution
yum install -y bzip2 bzip2-devel
  错误
  configure: error: jpeglib.h not found.
   yum install libjpeg-devel -y
  

  错误
  configure: error: png.h not found.
   yum install libpng-devel -y
  

  错误
  configure: error: freetype-config not found.
  yum install -y freetype freetype-devel
  错误
  configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  tar zxvf mcrypt-2.6.8.tar.gz    #提示mcrypt包没有安装。安装mcrypt包 又依赖依赖 libmcrypt,  mhash 这两个包。
  1.首先编译安装  libmcrypt,  mhash,  mcrypt  二进制源码包。

  下载libmcrypt-2.5.8.tar.gz
  

  tar zxvf libmcrypt-2.5.8.tar.gz
  cd libmcrypt-2.5.8
  ./configure --prefix=/usr/local/related/libmcrypt
  make  
  make install
  

  安装 libltdl,也在libmcrypt源码包里面
  cd libmcrypt-2.5.8 /libltdl

  ./configure --enable-ltdl-install
  make
  make install
  
  下载mhash-0.9.9.9.tar.gz
  tar zxvf mhash-0.9.9.9
  cd mhash-0.9.9.9
  ./configrue --prefix
  make
  make install
  

  这两个包安装完。然后在安装mcrypt包。
  

  安装mcrypt
  tar zxvf mcrypt-2.6.8.tar.gz
  LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib ./configure --with-libmcrypt-prefix=/usr/local/libmcrypt   #编译参数
  make
  make install
  #mcrypt 没有安装完成。这是php模块。需要等php安装完成之后。在继续安装。
  

  

  

  把以上的依赖关系解决完了之后在继续安装PHP
  ./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  --with-mcrypt=/usr/local/libmcrypt/
  make
  make install
  

  生成php.ini
  cp /lamp/php-5.5.9/php.ini-production  /usr/local/php/etc/php.ini
  

  apache结合php
  Apache的主配置文件为 :/usr/local/apache2/etc/httpd.conf   #参数编译的时候指定到/usr/local/apache2/etc/ 这个目录下。
  

  vim /usr/local/apache2/etc/httpd.conf
  找到AddType application/x-gzip .gz .tgz 这一行在下面增加
  AddType application/x-httpd-php .php
  

  找到:<IfModule dir_module>
      DirectoryIndex index.html
  </IfModule>
  将中间一样的内容改为:DirectoryIndex index.html index.htm index.php
  修改完成后保存退出。
  启动前检测apache的配置文件是否正常。
  /usr/local/apache2/bin/apachectl -t  
  如果显示“Syntax OK” 表示正常。
  

  启动apache
  
/usr/local/apache2/bin/apachectl start

  


  
检测是否启动成功。

  
netstart -lnp |grep httpd

  


  


  


  


  LAMP相关小知识。
  /usr/local/apache2/bin/apachectl  graceful   加载apache配置文件   不用重启
  

  /usr/local/apache2/bin/apachectl  -t  查看php配置文件是否正常
  

  /usr/local/php/bin/php -i |more  能查看php安装信息。。./configure 内容 等等
  

  cat /usr/local/apache2/build/config.nice   查看apache 安装的编译代码
  

  cat /usr/local/mysql/bin/mysqlbug |grep -i confi     参看musql安装的编译参数
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-452755-1-1.html 上篇帖子: Rhel7/Centos7 修改运行级别 下篇帖子: CentOS 6.5 drbd
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表