edfwe 发表于 2015-5-5 08:35:33

安装配置LAMP

真的很无奈啊,最近要在线上服务器配置LAMP的环境,因为开发的游戏只能在LAMP环境下才能正常的运行,哎。。。之前没有用研究过apache,也没有用过,无耐。。。。

没办法,只能应游戏要求,配置LAMP环境


配置如下:
    软件版本:
      httpd-2.2.16.tar.gz   mysql-5.1.40-linux-i686-icc-glibc23.tar.gz   php-5.3.27.tar.gz




安装依赖包:
      yum -y install patch make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap pcre pcre-devel apr apr-devel




安装mysql:

      cd /usr/local/src/
      wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
      tar -zxf mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
      mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql
      useradd -s /sbin/nologin mysql
      cd /usr/local/mysql
      mkdir -p /data/mysql
      chown -R mysql:mysql /data/mysql
      /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql(看到两个OK即可)
      cp support-files/my-large.cnf /usr/local/mysql/my.cnf
      mv my.cnf my.cnf.old
      vi my.cnf
      
      basedir=/usr/local/mysql
      datadir=/data/mysql
      socket=/tmp/mysql.sock
      pid-file=/data/mysql/mysqld.pid
      user=mysql
      # Disabling symbolic-links is recommended to prevent assorted security risks
      symbolic-links=0

      innodb-file-per-table=1
      innodb-open-file=500
      innodb_log_file_size=512M
      innodb_log_buffer_size=8M
      innodb_buffer_pool_size=1G

      max_allowed_packet=32M
      max_connections=1000
      log-bin=/data/binlog/mysql-binlog

      
      log-error=/var/log/mysqld.log
      mkdir -p /data/binlog/
      chown -R mysql:mysql /data/binlog/
      cp support-files/mysql.server/etc/init.d/mysqld
      chmod 755 /etc/init.d/mysqld
      vi /etc/init.d/mysqld
      找到datadir="/$basedir/data"改为datadir="/data/mysql"
      chkconfig --add mysqld
      chkconfig mysqld on
      service mysqld start
      # ps -ef | grep mysql
          root      1401   10 10:17 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysqld.pid
          mysql   152214012 10:17 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/data/mysql/mysqld.pid --socket=/tmp/mysql.sock
          root      154012410 10:18 pts/1    00:00:00 grep mysql
      echo "export PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
      source /etc/profile




安装apache:
      cd /usr/local/src/
      wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
      tar -zxf httpd-2.2.16.tar.gz
      cd httpd-2.2.16
      ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
      make
      make install
      echo "export PATH=$PATH:/usr/local/apache2/bin" >> /etc/profile
      source /etc/profile




    安装php:
      先安装依赖库libmcrypt:
      cd /usr/local/src/
      wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
      tar -zxf libmcrypt-2.5.7.tar.gz
      cd libmcrypt-2.5.7
      ./configure
      make
      make install
      ldconfig
      cd libltdl/
      ./configure --enable-ltdl-install
      make
      make install
      vi /etc/ld.so.conf
      添加:/usr/local/lib/
      ldconfig

       安装php:

      cd /usr/local/src
      wget http://am1.php.net/distributions/php-5.3.27.tar.gz
      tar -zxf php-5.3.27.tar.gz
      cd php-5.3.27
      ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-gd --with-gettext --with-libxml-dir=/usr/local --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --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 --enable-bcmath --enable-mbstring --enable-sockets --disable-ipv6
      make
      make install
      apachectl -M | grep php             (检查apache是否加载了php模块)
      cp php.ini-production /usr/local/php/etc/php.ini



    apache结合php:
      vi /usr/local/apache2/conf/httpd.conf
      找到 AddType application/x-gzip .gz .tgz
      在该行下面添加:AddType application/x-httpd-php .php
      找到 DirectoryIndex index.html
      将该行改为:DirectoryIndex index.html index.htm index.php
      找到 #ServerName www.example.com:80
      将注释去掉并改为:ServerName localhost:80
      apachectl -t                         (检测配置文件是否正确)
      apachectl start                      (启动httpd服务)
      # ps -ef | grep http
          root      6881   10 11:24 ?      00:00:00 /usr/local/apache2/bin/httpd -k start
          daemon    688268810 11:24 ?      00:00:00 /usr/local/apache2/bin/httpd -k start
          daemon    688368810 11:24 ?      00:00:00 /usr/local/apache2/bin/httpd -k start
          daemon    688468810 11:24 ?      00:00:00 /usr/local/apache2/bin/httpd -k start
          daemon    688568810 11:24 ?      00:00:00 /usr/local/apache2/bin/httpd -k start
          daemon    688668810 11:24 ?      00:00:00 /usr/local/apache2/bin/httpd -k start
          root      689012410 11:25 pts/1    00:00:00 grep http
      # curl localhost
      <html><body><h1>It works!</h1></body></html>         (只有显示这样才算正确)



    测试:
      cd /usr/local/apache2/htdocs/
      vi index.php
      <?php
      phpinfo();
      ?>
      访问:192.168.186.131/index.php



页: [1]
查看完整版本: 安装配置LAMP