• Linux 安装 Apache2+php5+gd+freetype2


    先找到 apache php mysql proftpd 源码包下载的URL地址
    请浏览
    http://www.apache.org
    http://www.php.net
    http://www.mysql.com
    http://www.proftpd.org/
    等官方网站

    第一步:安装apache
    注:当前目录为/tmp
    目录下有httpd-2.2.4.tar.gz, php-5.2.3.tar.gz等二进制源码包
    #
    号代表为root 根权限,#后是输入的一条命令

    执行下列命令
    解压源码包
    # tar -zxf httpd-2.2.11.tar.gz
    进入安装目录
    # cd httpd-2.2.11
    配置apache安装信息
    ./configure --enable-dav --enable-so --prefix=/usr/local/apache/ --enable-maintainer-mode
    执行make安装
    # make; make install
    安装完后
    # vi /usr/local/apache/conf/httpd.conf
    找到 prefork.c 下的
    MaxClients 150
    改为
    ServerLimit 2000
    MaxClients 1000
    apache
    默认工作prefork.c模式下,并发进程为150,超过后就无法访问,150是远远不够的,所以这里按自己网站的需求改, 1000
    由于apache默认最大并发进程是 256 所以要先设置 ServerLimit 2000 将服务器可设的最大并发数设为2000, 然后再设置最大并发数 MaxClients 1000

    找到 #ServerName www.example.com:80 在其下设置 ServerName 如下
    ServerName www.mysite.com
    基中 www.mysite.com 为你网站名,也可用IP代替
    找到 DocumentRoot "/usr/local/apache/htdocs"
    设置你的 WEB 服务器的根目录 
    DocumentRoot "/myweb"
    找到 DirectoryIndex index.html index.html.var 改为
    DirectoryIndex index.html index.php index.htm
    找到 ForceLanguagePriority Prefer Fallback 在其下加上
    AddDefaultCharset gb2312
    改完后保存(vi 的用法请查 Linux vi 命令)
    用下面命令启动WEB服务器
    # /usr/local/apache/bin/apachectl start
    查看自己的站点是否正常 http://www.mysite.com 也可用IP
     # /usr/local/apache/bin/apachectl stop 可停止服务


    安装MYSQL二进制文件包,解压即可使用
    # tar -zxf mysql-standard-5.2.10-linux-i686.tar.gz
    # cp -r mysql-standard-5.2.10-linux-i686 /usr/local/mysql
    # vi /usr/local/mysql/support-files/my-medium.cnf
    在后面加上
    max_connections = 1000
    log-slow-queries
    long_query_time = 5
     max_connections 为允许的最大连接数
    log-slow-queries
     打开低速查询日志
    long_query_time
     低速查询的秒数(运行一句sql达到此时间记录在日志里)
    然后COPY 它为 /etc/my.cnf 文件
    # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
    添加mysql用户及用户组
    # groupadd mysql
    # useradd -g mysql mysql
    修改mysql目录权限
    # chown -R root /usr/local/mysql
    # chgrp -R mysql /usr/local/mysql
    # chown -R mysql /usr/local/mysql/data
    生成mysql系统数据库
    # /usr/local/mysql/scrīpts/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 -u root -p password 123456
    回车出现 Enter password: 最开始密码默认为空 继续回车即可
    123456
     即为你的新密码
    注意:在安装MySQL5.0的时候会出现一个问题,就是和PHP联合编译的时候提示-lmysqlclient错误,这个原因是因为使用了另外一个版本的MySQL,我们需要使用的是Linux x86那个版本,不要是glibc-2.2那个。参考(http://forums.mysql.com/read.php?45,100371,101591#msg-101591
     

    安装GD(PHP支持GIF,PNG,JPEG)
    首先下载 jpeg6,libpng,freetype 并安装模块

     

    cd /tmp
    wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
    wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz
    wget http://keihanna.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.10.tar.gz
    wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz

    安装 jpeg6
    建立目录
    # mkdir /usr/local/jpeg6
    # mkdir /usr/local/jpeg6/bin
    # mkdir /usr/local/jpeg6/lib
    # mkdir /usr/local/jpeg6/include
    # mkdir /usr/local/jpeg6/man
    # mkdir /usr/local/jpeg6/man/man1
    # cd /tmp
    # tar -zxf jpegsrc.v6b.tar.gz
    # cd jpeg-6b
    # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
    # make; make install

    安装libpng
    # cd /tmp
    # tar -zxf libpng-1.2.8.tar.gz
    # cd libpng-1.2.8
    # cp scrīpts/makefile.std makefile
    # make; make install

    安装 freetype
    # cd /root/soft
    # tar -zxf freetype-2.1.10.tar.gz
    # cd freetype-2.1.10
    # ./configure --prefix=/usr/local/freetype
    # make;make install

    安装最新的GD
    # cd /tmp
    # tar -zxf gd-2.0.33.tar.gz
    # cd gd-2.0.33
    # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
    # make; make install

    安装PHP5

    由于php5libxml2的支持, 所以先下载并安装libxml2
    # cd /tmp
    # wget http://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.19.tar.gz
    # tar -zxf libxml2-2.6.19.tar.gz
    # cd libxml2-2.6.19
    # ./configure --prefix=/usr/local/libxml2
    # make; make install

    安装 libxslt
    # cd /tmp
    # wget http://ftp.gnome.org/pub/GNOME/sources/libxslt/1.1/libxslt-1.1.15.tar.gz
    # tar -zxf libxslt-1.1.15.tar.gz
    # cd libxslt-1.1.15
    # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
    # make; make install

    # tar -zxf php-5.2.9.tar.gz
    # cd php-5.2.9
    # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring
    # make
    # make install

    其中./configure 后的
    --prefix=/usr/local/php5
    --with-apxs2=/usr/local/apache/bin/apxs
    --with-mysql=/usr/local/mysql/
    --with-libxml-dir=/usr/local/libxml2
    是必要的选项

    --with-gd=/usr/local/gd2/
    --with-jpeg-dir=/usr/local/jpeg6/
    --with-png
    --with-zlib-dir=/usr/lib
    --with-freetype-dir=/usr/local/freetype
    这是让PHP支持GD库的配置选项

    配置 httpd.conf apache支持PHP
    # vi /usr/local/apache/conf/httpd.conf
    找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    重启apache
    # /usr/local/apache/bin/apachectl restart
    在这里有一个问题,如果你的系统安装了SELinux模块,那么由于安全控制的原因,会出现如下错误:
    Starting httpd: Syntax error on line 191 of /etc/httpd/conf/httpd.conf:
    Cannot load /etc/httpd/modules/libphp5.so into server: libxml2.so.2: failed to map segment from shared object: Permission denied
                                                               [FAILED]
    这样需要我们到指定的库文件的目录下执行如下命令:
    restorecon libxml2.so.2.6.19
    把类似的错误都解决之后,Apache就可以正常启动了。
     
    在你Web目录里建一内容为 <? phpinfo(); ?> PHP文件, 输入URL地址查看PHP配置是否正确


    安装 phpmyadmin
    下载
    # cd /tmp
    # wget http://nchc.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.10.1.tar.gz
    # tar -zxf phpMyAdmin-2.10.1.tar.gz
    phpMyAdmin
    必须需要PHP支持MySQL
    并且在2.8以后的版本,解压完毕后,首先需要手工建一个config目录,然后配置完毕后,需要点击页面上的Configuration中的Save把文件存成config.inc.php
    # vi phpMyAdmin-2.10.1/config.inc.php
    找到 $cfg['Servers'][$i]['auth_type'] = 'config'; config 改为 http
    保存后
    mv phpMyAdmin-2.10.1 /
    你的phpmyadmin目录
    进入phpmyadmin管理
    : PHP连接mysql4.15.0 数据库后需指定字符集 需执行如 mysql_query("SET NAMES 'gb2312' ");
    否则会产生中文乱码问题!

  • 相关阅读:
    shell 10流程控制
    shell 9test命令
    shell 8字符串与文件内容处理
    shell 7输入输出
    shell 6基本运算符
    JS-JQ实现TAB选项卡
    JS-JQ实现页面滚动时元素智能定位(顶部-其他部位)
    js获取框架(IFrame)的内容
    codeforces 660C C. Hard Process(二分)
    codeforces 660B B. Seating On Bus(模拟)
  • 原文地址:https://www.cnblogs.com/mazefeng/p/3357601.html
Copyright © 2020-2023  润新知