Redhat環境MySQL+Apache+PHP環境配置

紅帽不註冊,yum方法:

查看yum包
rpm -qa|grep yum
卸載之
rpm -qa|grep yum|xargs rpm -e –nodeps

下載對應的yum包,...爲機器型號
http://centos.ustc.edu.cn/centos/5/os/.../CentOS/yum-3.2.22-26.el5.centos.noarch.rpm

http://centos.ustc.edu.cn/centos/5/os/.../CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

http://centos.ustc.edu.cn/centos/5/.../CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

並且安裝之
rpm -ivh yum-*
注意:yum和yum-fastestmirror相互依賴,所以同時安裝即可。

下載yum的配置源
wget http://www.linuxidc.com/files/2011/05/06/CentOS-Base.repo 下載到 /etc/yum.repos.d/ 目錄下面

運行yum makecache生成緩存

1. MySQL

(1). rpm安裝:rpm -ivh MySQL-shared-5.6.11-1.rhel5.x86_64.rpm

rpm卸載:rpm -e MySQL-shared

rpm查看:rpm -aq

a. MySQL-server-5.6.10-1.rhel5.x86_64.rpm

b. MySQL-client-5.6.10-1.rhel5.x86_64.rpm

c. MySQL-devel-5.6.10-1.rhel5.x86_64.rpm

d. MySQL-shared-5.6.11-1.rhel5.x86_64.rpm

(2). cp /usr/share/mysql/my-default.cnf /etc/my.cnf

(3). 如果出現InnoDB的ibdata1錯誤,根據錯誤日誌,vi /etc/my.cnf

添加innodb_data_file_path = ibdata1:10M:autoextend

 

2. Apache2安裝

./configure --enable-lib64 -libdir=/usr/lib64 --enable-cache --enable-cache-disk --with-pcre=/usr/local --enable-ssl --with-ssl=/usr/ --with-libxml2=/usr --enable-so --enable-expires --enable-rewrite

make;make install

自動啓動:

(1). cp apachectl /etc/init.d/apache

(2). vi /etc/init.d/apache

在!/bin/sh後面添加chkconfig識別標誌,345爲啓動級別,10和70爲關閉和啓動順序。

#chkconfig: 345 10 70

#description: Start and stop the Apache HTTP Service.

(3). chkconfig --add apache

 

3. PHP5.4.14安裝

(1) tar -xvf php-5.4.14.tar.bz2

(2). ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/ --with-libxml-dir=/usr/ --with-gd=/usr --with-jpeg-dir=/usr/ --with-png-dir=/usr/ --with-png-dir=/usr/ --with-zlib-dir=/usr/lib64/ --with-freetype-dir=/usr/ --with-curl=/usr --enable-soap --with-xsl=/usr --enable-sockets --enable-mbstring --enable-soap

(3). make; make install

(4). cp php.ini-product /usr/local/lib/php.ini

 

4. 配置Apache2和PHP

(1). vi/usr/local/apache2/conf/httpd.conf 打開配置文件,/AddType找到AddType,添加

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

:wq保存退出(windows也一樣添加)

(2). opcode緩存apc

tar -xvf APC-3.1.9.tgz

cd APC-3.1.9

/usr/local/bin/phpize

./configure --enable-apc --with-apc-mmap

make; make install

編輯php.ini

添加配置信息

[apc]

extension=apc.so

apc.cache_by_default=1

apc.enabled=1

apc.shm_segments=1

apc.shm_size=128M

apc.ttl=0

apc.user_ttl=7200

apc.num_files_hint=1000

apc.write_lock=1

apc.stat=0

apc.maxfile_size=1M

(3) mod_cache配置

<IfModule mod_cache.c>
CacheDefaultExpire  3600
CacheMaxExpire  86400
CacheLastModifiedFactor  0.1

<IfModule mod_cache_disk.c>
CacheRoot  "D:/Program Files/Apache Software Foundation/Apache2.2/cache/"
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3
CacheMaxFileSize  10000000
CacheMinFileSize  1
</IfModule>

</IfModule>

(4) xdebug配置

linux安裝

pecl install xdebug

php.ini添加

[Xdebug]

zend_extension="/usr/local/lib/php/extensions/no-debug-zts-20100525/xdebug.so"(linux)
zend_extension="D:\Program Files\PHP\ext\php_xdebug.dll"(windows)
xdebug.profiler_output_dir="D:\Program Files\PHP\xdebug"
xdebug.profiler_enable=On
xdebug.profiler_enable_trigger=1
xdebug.default_enable=On
xdebug.show_exception_trace=On
xdebug.show_local_vars=1
xdebug.max_nesting_level=50
xdebug.var_display_max_depth=6
xdebug.dump_once=On
xdebug.dump_globals=On
xdebug.dump_undefined=On
xdebug.dump.REQUEST=*
xdebug.dump.SERVER=REQUEST_METHOD,REQUEST_URI,HTTP_USER_AGENT
xdebug.trace_output_dir="D:\Program Files\PHP\xdebug"

xdebug.trace_output_dir=/usr/local/apache2/xdebug(linux)

注意linux目錄要daemon有執行權限chown daemon /usr/local/apache2/xdebug

查看調試文件

下載WinCacheGrind(windows)\kcachegrind(linux)工具

tar -zxf kcachegrind-0.4.6.tar.gz

cd kcachegrind-0.4.6

由於kcachegrind依賴於kde,所以需要先安裝kde相關的庫:

yum install kdebase-devel

然後再進行安裝,注意configure時要制定qt的路徑,否則會報checking for Qt... configure: error: Qt (>= Qt 3.0) (headers and libraries) not found錯誤:

./configure --prefix=`kde-config --prefix`
make && make install

安裝完成後在命令行下運行kcachegrind 即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章