快乐的老鼠 发表于 2018-10-7 11:30:06

lamp(apache2.2mysql5.0php5.3)

  一、下载源码包
  # mkdir -p /www/xiazai    //新建文件夹
  # cd /www/xiazai   //进入放置软件包目录
  # wget http://mirrors.sohu.com/apache/httpd-2.2.34.tar.gz下载apache
  # wget http://mirrors.sohu.com/mysql/MySQL-5.0/mysql-5.0.95-linux-x86_64-glibc23.tar.gz
  http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
  # wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz
  二、安装mysql
  # tar -zxvf mysql-5.0.95-linux-x86_64-glibc23.tar.gz    //解压
  1、把解压完的数据移动到# mkdir -p /www/server
  # mv mysql-5.0.95-linux-x86_64-glibc23 /www/server/mysql //移动到mysql目录下
  # useradd -s /sbin/nologin -M mysql//建立用户
  # cd /www/server/mysql//进入mysql安装目录
  # mkdir -p /www/data/mysqldata//新建数据库存放地址
  # chown -R mysql:mysql /www/data/mysqldata//设置mysql数据库存放目录权限
  # ./scripts/mysql_install_db --user=mysql --datadir=/www/data/mysqldata
  --user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。这一步骤很关键,如果你看到两个 “OK” 说明执行正确
  4、拷贝配置文件
  #cp support-files/my-large.cnf /etc/my.cnf//拷贝配置文件
  5、拷贝启动脚本文件并修改其属性
  # cp support-files/mysql.server/etc/init.d/mysqld
  # chmod 755 /etc/init.d/mysqld
  6、修改启动脚本
  # yum install vim*
  # vim /etc/init.d/mysqld   //编辑数据库主配置文件
  需要修改的地方有 “datadir=/data/mysql” (前面初始化数据库时定义的目录)
  basedir=/www/server/mysql
  datadir=/www/data/mysqldata
  7、把启动脚本加入系统服务项,并设定开机启动,启动mysql
  # chkconfig --add mysqld
  # chkconfig mysqld on
  # service mysqld start
  # netstat -lnp |grep mysql//查看端口是否运行
  # echo "PATH=$PATH:/www/server/mysql/bin" >> /etc/profile
  echo "PATH=$PATH:/www/wdlinux/apache_php-5.6.21/bin" >> /etc/profile
  /www/wdlinux/apache_php-5.6.21/bin/
  # source /etc/profile   设置变量开机加载
  #/www/server/mysql/bin/mysqladmin -u root password 75dn289z    //设置MySQL密码
  8、测试
  # shutdown -r now//重启
  # mysql -uroot -p
  三、安装Apache
  首先添加依赖应用
  yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-develzlib-devel pcre pcre-devel apr apr-devel
  yum install gcc zlib-devel openssl-deve
  # tar -zxvf httpd-2.2.32.tar.gz//解压缩包
  2、进入目录
  # cd httpd-2.2.32
  # mkdir -p /www/server新建安装目录
  3、编译
  #./configure --prefix=/www/server/httpd --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
  --prefix 指定安装到哪里, --enable-so 表示启用DSO --enable-deflate=shared 表示共享的方式编译deflate,后面的参数同理。
  如果这一步你出现了这样的错误 error: mod_deflate has been requested but can not be built due to prerequisite failures
  解决办法 yum install -y zlib-devel
  为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件
  ## yum install -y pcre pcre-devel apr apr-devel
  # echo $?
  0
  # make install
  ## echo $?
  # vi /etc/init.d/httpd新建启动脚本
  # chmod 775 /etc/init.d/httpd   //设置权限
  # chkconfig --add httpd
  # chkconfig httpd on
  http://note.youdao.com/noteshare?id=e4485bc811f68e4a70bb8f8be7b1f16b httpd启动脚本
  四、安装PHP
  # cd /www/xiazai/
  下面我们来 添加 jpeg 格式文件的支持
  wget http://y.w-jiahao.cn/by/la/jpegsrc.v8b.tar.gz
  tar -zxvfjpegsrc.v8b.tar.gz
  cd jpeg-8b
  ./configure --prefix=/www/server/jpeg --enable-shared --enable-static
  make && make install
  使用php mcrypt 前必须先安装Libmcrypt
  libmcrypt源码安装方法:
  cd /www/xiazai
  wget http://y.w-jiahao.cn/by/la/libmcrypt-2.5.8.tar.gz
  tar -zxvf libmcrypt-2.5.8.tar.gz
  cd libmcrypt-2.5.8
  ./configure --prefix=/www/server/libmcrypt
  make
  make install
  1、解压
  # tar -zxvf php-5.3.27.tar.gz
  2、配置参数
  # cd php-5.3.27
  # ./configure --prefix=/www/server/php --with-apxs2=/www/server/httpd/bin/apxs --with-config-file-path=/www/server/php/etc --with-mysql=/www/server/mysql --with-libxml-dir --with-gd --with-jpeg-dir=/www/server/jpeg--with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt=/www/server/libmcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
  ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir=/usr/local/jpeg--with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
  遇到如下错误
  configure: error: xml2-config not found. Please check your libxml2 installation.
  解决办法 yum install -y libxml2-devel
  configure: error: Cannot find OpenSSL's
  解决办法yum install -y openssl openssl-devel
  checking for BZip2 in default path... not found
  configure: error: Please reinstall the BZip2 distribution
  解决办法yum install -y bzip2 bzip2-devel
  configure: error: png.h not found
  解决办法 yum install -y libpng libpng-devel
  configure: error: freetype.h not found.
  解决办法yum install -y freetype freetype-devel
  configure: error: mcrypt.h not found. Please reinstall libmcrypt
  # echo $?
  # make
  报错:make: *** Error 1
  解决办法
  这是由于内存小于1G所导致.
  在./configure加上选项:
  --disable-fileinfo
  有时候我们编译php的时候会出现以下错误:
  make *** Error 1
  处理方法:
  安装两个rpm包#yum -y install libtool.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64
  然后make clean;make
  # echo $?
  # make install
  # echo $?   ///待续
  3、拷贝配置文件
  # cp php.ini-production /www/server/php/etc/php.ini    四、apache结合php
  Apache主配置文件为:/www/server/httpd/conf/httpd.conf
  # vi /www/server/httpd/conf/httpd.conf
  找到
  
  x
  DirectoryIndex index.html
  
  改为
  
  DirectoryIndex index.html index.htm index.php
  
  找到AddType application/x-gzip .gz .tgz 在下面添加AddType application/x-httpd-php .php   314
  找到#ServerName www.example.com:80改为ServerName localhost:80   102
  #AllowOverride None改为 AllowOverride All
  #Include conf/extra/httpd-vhosts.conf改为Include conf/extra/httpd-vhosts.conf
  wq保存
  六、测试PHP
  # curl localhost   查看是否正常显示It works!
  测试php
  #echo "" >/www/server/httpd/htdocs/index.php 添加php文档
  http://note.youdao.com/noteshare?id=731fc872a408734d6b1b803a1a3ec193 httpd启动脚本
  初次使用浏览器访问web服务的时候,可能无法访问,这是因为防火墙的缘故。请运行下面的命令
  # iptables -F 关闭防火墙
  截图范:
  ==============================
  curl组件安装
  进入安装目录/usr/local/src/php-5.3.27/ext/curl
  执行/www/server/php/bin/phpize
  ./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/php/lib/php/extensions
  make && make install
  在php.ini添加路径
  extension="/usr/local/php/lib/php/extensions/curl.so"
  ==============================================
  Zend安装
  换成:vim /www/server/php/etc/php.ini
  
  zend_extension = /www/server/zujian/ZendGuardLoader.so
  zend_loader.enable = 1
  配置ionCube:
  修改php.ini 在文件尾部添加以下代码:
  
  zend_extension="/usr/local/ioncube/ioncube_loader_lin_php5.4.so"
  #################################
  php添加开启pdo_mysql扩展模块
  /www/server/php/bin/phpize
  ./configure --with-php-config=/www/server/php/bin/php-config --with-pdo-mysql=/www/server/mysql
  make
  make install
  手动开启PDO,在php-ini文件上开启,连接数据库用。mysql开启PDO, 在php.ini加上extension=pdo_mysql.so,extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613", 再重启php即可
  mysqli安装
  /www/server/php/bin/phpize
  ./configure --with-php-config=/www/server/php/bin/php-config --with-mysqli=/www/server/mysql/bin/mysql_config
  make
  make install
  ############################
  Redis扩展安装
  wget http://pecl.php.net/get/redis-3.0.0.tgz
  mv redis-3.0.0.tgz redis-3.0.0.tar.gz
  tar -zxvf redis-3.0.0.tar.gz
  cd redis-3.0.0
  /www/server/php/bin/phpize
  ./configure --with-php-config=/www/server/php/bin/php-config

页: [1]
查看完整版本: lamp(apache2.2mysql5.0php5.3)