CentOS 6.3 編譯安裝 配置 nginx server php mysql c gcc g++ c++等


參考:http://www.ansen.org/centos-build-lnmp.html

1 CentOS iptables 配置

ifcfg-eth0配置

selinux配置

2 資源列表 :

mysql5.5.28: http://sourceforge.net/projects/mysql.mirror/files/MySQL%205.5.28/

http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.28-linux2.6-x86_64.tar.gz

php5.4: http://www.php.net/get/php-5.4.13.tar.gz/from/a/mirror

      http://cn2.php.net/get/php-5.4.8.tar.gz/from/a/mirror

nginx: http://nginx.org/download/nginx-1.3.15.tar.gz

http://nginx.org/download/nginx-1.3.8.tar.gz

jpeg src : http://www.ijg.org/

 

下載pcre (支持nginx偽靜態)
http://exim.mirror.fr/pcre/  http://sourceforge.net/projects/pcre/files/pcre/

CMAKE: http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz

libmcrypt: ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

3 安裝依賴庫:

yum installmakeapr* autoconf automake curl curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch libevent-devel php-devel【支持phpize】

 

4   安裝CMAKE (不一定需要) ,libmcrypt,FreeType(安裝gd時候需要) ,PCRE 

http://sourceforge.net/projects/freetype/files/freetype2/2.4.11/freetype-2.4.11.tar.gz/download

tar zxvf freetype-2.4.11*

./configure 

./configure --prefix=/usr/local/freetype

make && make install

  

5 安裝libjpeg 

  不清楚為啥第三部沒有裝上libjpeg的支持,不得不重新編譯php

http://www.ijg.org/files/jpegsrc.v9.tar.gz

tar zxvf jpegsrc.v9.*

cd jpegv9

./configure --prefix=/usr/local/jpeg9/ --enable-shared --enable-static

make && make install

  安裝 libpng

 http://sourceforge.net/projects/libpng/files/libpng12/1.2.50/libpng-1.2.50.tar.gz/download

6 安裝gd2

https://bitbucket.org/libgd/gd-libgd/downloads

https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0-rc1.tar.gz

tar zxvf gd-2.1.0-preview.tar.gz

./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg9/ --with-png=/usr/local/libpng/ --with-zlib --with-freetype=/usr/local/freetype/

make && make install

 

 

7 安裝mysql 5.5.28

直接從官網下載已編譯好的,不知道為啥其他版本編譯不過去

shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysqld

加上這個命令:chkconfig mysqld on[隨系統啟動]

service mysqld start ,這個時候pid文件在data目錄了

8 安裝nginx


tar zxvf nginx-1.3.8.*

cd nginx-1.3.8

groupadd www #添加www組

useradd -g www www -s /bin/false #創建nginx運行賬戶www並加入到www組,不允許www用戶直接登錄系統cd /usr/local/src
tar zxvf nginx-1.0.12. tar .gz
cd nginx-1.0.12
. /configure --prefix= /usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-openssl= /usr/ --with-pcre= /usr/local/src/pcre-8 .30
注意:--with-pcre= /usr/local/src/pcre-8 .30指向的是源碼包解壓的路徑,而不是安裝的路徑,否則會報錯
make
make install
/usr/local/nginx/sbin/nginx #啟動nginx

 

9 安裝PHP5 

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mysqlnd  --with-pdo-mysql --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-magic-quotes --enable-safe-mode --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --with-bz2 --enable-soap --with-pear --with-gettext --enable-session --with-mcrypt --with-curl  --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg9 --with-png-dir=/usr/local/libpng/ --with-libxml-dir=/usr/include/libxml2/ --enable-exif --enable-bcmath  --enable-shmop --enable-sysvsem --enable-sysvmsg --enable-sysvshm --with-mhash --with-openssl --disable-json

 【刪除線下的參數,5.5.6不支持】

這里禁用了json因為要使用jsond,我自己修改了jsond的源碼,兼容json的函數和常量

  --with-iconv-dir --with-freetype-dir --with-png-dir --with-libxml-dir --with-mysql=mysqlnd

  --with-gd=shared 

 

make && make install 

 

 10 配置nginx server

nginx最常用的方法是利用 tcp/ip 協議連接 phpfastcgi 接口, 因此要連接php必須先啟動fastcgi程序.

啟動方法:

/usr/local/php5/bin/php-cgi -b 9000 -c /etc/php.ini &

-b 用於指定監聽地址與端口(nginx.conf默認是9000)

如果想指定配置文件位置,可以使用-c選項

 

訪問php文件報出:“No input file specified.” 解決方法如下:

參考:http://zhidao.baidu.com/question/325668800.html

#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

改為$document_root即可

---不知道為啥,amqp沒有編譯完成,就又報同樣的問題了

於是

改成這樣:fastcgi_param  SCRIPT_FILENAME  /data1/www/test$fastcgi_script_name;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM