一、Centos6.3下 Apache+PHP+Mysql 源碼安裝


1、安裝Apachephp

  一、配置html

/configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support --disable-userdir

  二、編譯mysql

make

  三、安裝c++

make install

  四、啓動與關閉web

/usr/local/apache2/bin/apachectl start   #啓動
netstat -tnl  #查看端口是否開啓
/usr/local/apache2/bin/apachectl stop    #中止

  Apache安裝成功後,網站的目錄在Apache安裝目錄下的htdocs目錄下。絕對路徑爲:/usr/local/apache2/htdocssql

2、源碼安裝phpshell

  一、配置apache

/configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc   --with-jpeg-dir --with-png-dir --with-bz2 --with-freetype-dir --with-iconv-dir --with-zlib-dir  --enable-soap --enable-gd-native-ttf --enable-ftp --enable-sockets --enable-mbstring --enable-exif --enable-memcache --enable-vld

  其中--with-apxs2=/usr/local/apache2/bin/apxs是進行apache關聯,爲上面安裝Apache的具體路徑vim

  二、編譯app

make

  編譯後可能會報錯,根據報錯。通常都是libxml二、bzip2什麼的沒有安裝。那咱們用yum命令安裝就行.缺什麼安裝什麼

yum install bzip2
yum install bzip2-devel
yum install libxml2
yum install libxml-devel

 三、安裝

make install

四、將安裝包中的php.ini-dist文件複製並重命名到以下目錄

cp /usr/src/php-5.2.6/php.ini-dist  /usr/local/php/etc/php.ini

3、Apache與PHP結合

       其實在/usr/local/apache2/conf/httpd.conf文件中添加以下東西便可讓Apache解析PHP。都不用最下面一長串了。

  Listen 80 
  NameVirtualHost *:80 
  <VirtualHost *:80 >
       ServerAdmin example@company.com
       DocumentRoot  /usr/local/apache2/htdocs
      <Directory "/usr/local/apache2/htdocs">
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all 
      </Directory>
  </VirtualHost>


  一、 Apache主配置文件爲:/usr/local/apache2/conf/httpd.conf
# vim /usr/local/apache2/conf/httpd.conf
 找到:
    AddType application/x-gzip .gz .tgz
 在該行下面添加
    AddType application/x-httpd-php .php

二、修改默認讀取文件
    找到:
        <IfModule dir_module>
        DirectoryIndex index.html
        </IfModule>
    將該行改成
    <IfModule dir_module>
        DirectoryIndex index.html index.htm index.php
    </IfModule>
三、找到:
    #Include conf/extra/httpd-mpm.conf
    #Include conf/extra/httpd-info.conf
    #Include conf/extra/httpd-vhosts.conf
    #Include conf/extra/httpd-default.conf
    去掉前面的「#」號,取消註釋。

4、配置Apache虛擬主機

一、配置文件爲:/usr/local/apache2/conf/extra/httpd-vhosts.conf
將配置文件中下面一段修改成以下:

<VirtualHost *:80>
   # ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/data/www"
    ServerName www.example.com.cn
    ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /www/logs/error.log-%Y%m%d 86400"
   CustomLog "|/usr/local/apache2/bin/rotatelogs -l /www/logs/access.log-%Y%m%d 86400" combined
   </VirtualHost>

說明:
    ServerAdmin 參數後爲管理員email
    DocumentRoot 指的是論壇文件存放的目錄
    ServerName  是論壇的域名
    ErrorLog 是論壇錯誤日誌  經過管道使用apache自帶的rotatelogs工具將日誌切割爲天天一個文件
    CustomLog 是論壇訪問日誌,一樣切割爲天天一個文件

二、配置Apache缺省httpd設置

  配置文件爲/usr/local/apache2/conf/extra/httpd-default.conf
      將配置文件中下面一段:
  將KeepAlive On 改成KeepAlive Off

三、配置Apache的訪問權限
 vim /usr/local/apache2/conf/httpd.conf
 找到
  <Directory />
    Options FollowSymlinks
    AllowOverride None
    Order deny,allow
    Deny form all
  </Directory>
改爲:
  <Directory />
   Options FollowSymlinks
   AllowOverride None
   Order deny,allow
   Allow form all
  </Directory> 

四、配置Apache的運行帳戶

vim  /usr/local/apache2/conf/httpd.conf
 找到
    User  daemon
    Group daemon
 改爲
    User www
    Group www

            

通過上面一系列:Apache終於能夠解析PHP文件了


5、Mysql安裝

一、配置

./configure --prefix=/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock

安裝mysql的時候出現了No curses

    解決方式(CentOS)

        yum list|grep ncurses

        yum -y install ncurses-devel

 二、編譯

make

 make時出錯
  ../depcomp: line 571: exec: g++: not found
  make[1]: *** [my_new.o] 錯誤 127
  make[1]: Leaving directory `/usr/local/src/mysql/mysql-5.1.32/mysys`
  make: *** [all-recursive] 錯誤 1
 解決:
  #yum install gcc-c++ 可解決問題。
 從新指定安裝路徑:
  #./configure --prefix=/usr/local/mysql-5.0.90
make

三、安裝

make install
相關文章
相關標籤/搜索