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

redhat 搭建LAMP环境

[复制链接]

尚未签到

发表于 2015-8-19 09:55:28 | 显示全部楼层 |阅读模式
  1.安装mysql
  这里用rpm包安装,需要一下四个rpm包:

   MySQL-server-5.0.45-0.i386.rpm
 MySQL-devel-5.0.45-0.i386.rpm
 MySQL-client-5.0.45-0.i386.rpm
 MySQL-shared-5.0.45-0.i386.rpm
  直接执行:
   #rpm –ivh Mysql-*.rpm
  设置密码:
   # mysqladmin -u root password 密码。
  配置:
  这部分转自:http://www.iyunv.com/xiaochaohuashengmi/archive/2011/10/18/2216087.html
  /**********************************************************************/


目录



1、数据库目录

   /var/lib/mysql/

2、配置文件

    /usr/share/mysql   (mysql.server命令及配置文件)

3、相关命令

   /usr/bin   (mysqladmin mysqldump等命令)

4、启动脚本

   /etc/rc.d/init.d/   (启动脚本文件mysql的目录)





配置



将/usr/share/mysql/my-medium.cnf复制到/etc/my.cnf,以后修改my.cnf文件来修改mysql的全局设置

将my.cnf文件中的innodb_flush_log_at_trx_commit设成0来优化  [mysqld]后添加添加lower_case_table_names设成1来不区分表名的大小写




设置字符集

MySQL的默认编码是Latin1,不支持中文,要支持需要把数据库的默认编码修改为gbk或者utf8。



1、中止MySQL服务(bin/mysqladmin -u root shutdown)

  2、在/etc/下找到my.cnf,如果没有就把MySQL的安装目录下的support-files目录下的my-medium.cnf复制到/etc/下并改名为my.cnf即可

  3、打开my.cnf以后,在[client]和[mysqld]下面均加上default-character-set=utf8,保存并关闭

  3、打开my.cnf以后,在[client]下面添加default-character-set=utf8,在[mysqld]下面添加character_set_server = utf8


  4、启动MySQL服务(bin/mysqld_safe &)



  出错时要注意查看日志信息:/var/lib/mysql/localhost.localdomain.err

  5、

查询字符集:show variables like '%set%';





增加MySQL用户

格式:



grant select on 数据库.* to 用户名@登录主机 identified by "密码"









grant select,insert,update,delete on *.* to user_1@'%' Identified by '123';
grant all on *.* to user_1@'localhost' Identified by '123';



远程访问



  其一: 







GRANT ALL PRIVILEGES ON *.* TO xoops_root@'%' IDENTIFIED BY '654321';
  允许xoops_root用户可以从任意机器上登入MySQL。



  其二:



  编辑 /etc/mysql/my.cnf



  >skip-networking => # skip-networking



  这样就可以允许其他机器访问MySQL了。     grant all on *.* to 'root'@'ip' identified by 'password';






备份与恢复

备份

进入到库目录,cd /val/lib/mysql





mysqldump -u root -p --opt aaa > back_aaa
恢复



mysql -u root -p ccc < back_aaa  /***********************************************************************************/
  2.安装apache
  这部分转自:http://www.iyunv.com/huzhiwei/archive/2012/07/19/2599854.html
  /***********************************************************************************/
  不知道为什么在安装apache2.2.22版本的时候没有任何问题,直接使用命令
  ./configure --prefix=/usr/local/apache2 –-sysconfdir=/etc/httpd --enable-proxy --enable-so --enable-mods-shared=most --with-mpm=worker --enable-shared=max --enable-module=rewrite --enable-module=so
  没有任何问题,不过在安装新版本2.4.2的时候就会报错。
  解决方案如下:
  #./configure --prefix……检查编辑环境时出现:
checking for APR... no
configure: error: APR not found . Please read the documentation.
  可以用./configure –help | grep apr 查看帮助。
--with-included-apr Use bundled copies of APR/APR-Util
--with-apr=PATH prefix for installed APR or the full path to apr-config
--with-apr-util=PATH prefix for installed APU or the full path to
安装APR(Apache Portable Runtime )
[iyunv@localhost ~]# cd /tmp/52lamp/ //源码存放位置
[iyunv@localhost 52lamp]# tar -zxvf apr-1.4.2.tar.gz //unzip -o apr-1.4.2.zip
[iyunv@localhost 52lamp]# cd apr-1.4.2
[iyunv@localhost apr-1.4.2]# ./configure
[iyunv@localhost apr-1.4.2]# make
[iyunv@localhost apr-1.4.2]# make install
  再次检查编译环境出现
checking for APR-util... no
configure: error: APR-util not found . Please read the documentation.
  [iyunv@localhost httpd-2.2.16]# ./configure –help | grep apr-util
--with-apr-util=PATH prefix for installed APU or the full path to
  [iyunv@localhost 52lamp]# tar -zxvf apr-util-1.3.9.tar.gz
[iyunv@localhost 52lamp]# cd apr-util-1.3.9
[iyunv@localhost apr-util-1.3.9]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[iyunv@localhost apr-util-1.3.9]# make
[iyunv@localhost apr-util-1.3.9]# make install
  ./configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
  [iyunv@localhost httpd-2.2.16]# ./configure –help | grep pcre
--with-pcre=PATH Use external PCRE library
  [iyunv@localhost 52lamp]# unzip -o pcre-8.10.zip
[iyunv@localhost 52lamp]# cd pcre-8.10
[iyunv@localhost cd pcre-8.10]# ./configure --prefix=/usr/local/pcre
[iyunv@localhost cd pcre-8.10]# make
[iyunv@localhost cd pcre-8.10]# make install
  继续安装Apache/httpd,./configure 时加上参数 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre,这个问题就解决了。
  /***********************************************************************************/
  测试一下Apache配置文件的语法
   /usr/local/apache2/bin/apachectl –t
  启动Apache
   /usr/local/apache2/bin/apachectl -k start&
  我在安装的时候就有明明安好,但是无法启动apache的现象,百思不得其解。后来换了个低版本的安装,就发现能够正常启动了。好像是apache对apr和apr-util的版本是有要求的。
  将Apache添加到自动启动中
  echo '/usr/local/apache2/bin/apachectl -k start&'>>/etc/rc.d/rc.local
  检查Apache的端口是否跑起来了
  netstat -an |grep 80
  将Apache添加到系统服务中去
   cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
   ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd
  ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc4.d/S61httpd
  
  ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc5.d/S61httpd
  

vim /etc/rc.d/init.d/httpd
在第二行处添加:
#chkconfig:345 61 61
#description:Apache
执行:
chkconfig --add httpd
ok,apache安装完毕
3、安装PHP
这部分转自:http://www.fkblog.org/blog619

  ##### zlib #####
Zlib 软件包包含 zlib 库,很多程序中的压缩或者解压缩函数都会用到这个库.


tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3./configure --prefix=/usr/local/zlib
make && sudo make install

  ##### FreeType #####


tar -jxvf freetype-2.3.5.tar.bz2
cd freetype-2.3.5./configure --prefix=/usr/local/freetype
make && sudo make install

  ##### LibPNG #####


tar -zxvf libpng-1.2.20.tar.gz
cd libpng-1.2.20
cp scripts/makefile.linux makefile
./configure --prefix=/usr/local/libpng
make &&  make install

  ##### Jpeg (让GD支持JPEG)#####


tar -zxvf jpegsrc.v6b.tar.gz
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make && make install

  ##### GD Library #####


tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlib=/usr/local/zlib
make && make install

  安装过程可能出现以下错误信息


  把报错信息“configure.ac:64: error: possibly undefined macro: AM_ICONV”


  解决办法 (文件包已下载好)
到 http://www.gnu.org/software/gettext/ 下载了gettext-0.18.1.1.tar.gz
cp /usr/lib/libattr.* /lib/ (这个在转载的文章里没说,是因为make的时候报错说没有libattr.la这个文件,所以要复制过去)


tar xzf gettext-0.17.tar.gz
cd gettext-0.17./configure
make
make install

  经过以上操作,回去安装g d 就没有问题了!


  ##### libxml2 #####


tar -zxvf libxml2-2.6.26.tar.gz
cd libxml2-2.6.26./configure --prefix=/usr/local/libxml2 --with-zlib=/usr/local/zlib
make && make install

  ##### libxslt #####


tar -zxvf libxslt-1.1.17.tar.gz
cd libxslt-1.1.17./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make && make install

  ##### curl #####


tar -zxvf curl-7.21.6.tar.gz
cd curl-7.21.6
mkdir -p /usr/local/curl
./configure --prefix=/usr/local/curl --with-ssl
make && make install

  
  ##### PHP #####
下载php
php下载地址:http://php.net/downloads.php


tar -zxvf php-5.3.5.tar.gz
cd php-5.3.5./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr/local/jpeg--with-png --with-ttf --with-zlib --with-zlib-dir=/usr/local/zlib--with-curl=/usr/local/curl --with-freetype-dir=/usr/local/freetype  --with-mysql --with-iconv --with-mbstring --enable-mbstring=all --enable-ftp  --with-libxml=/usr/local/libxml2 --with-xslt-dir=/usr/local/libxslt --with-pear=/usr/local/php/pear
make && sudo make install
cp php.ini-development /usr/local/php/lib/php.ini

  如果编译时出现错误,请注意错误提示!
  到这边LAMP环境安装完成
  
  4、Apache+PHP配置
   LoadModule php5_module modules/libphp5.so
   AddType application/x-httpd-php .php .php5 .phtml
   AddType application/x-httpd-php-source .phps
   DirectoryIndex index.html index.php index.php5 index.phtml
   DocumentRoot"/var/www"
  

运维网声明 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-100990-1-1.html 上篇帖子: (原创)LAMP搭建之一:图解如何安装并检查LAMP 下篇帖子: Linux_源码搭建LAMP环境(二)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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