筆記:centos6 php配置測試

來源:互聯網
上載者:User

標籤:centos6 linux php nginx mysql

先安裝

nginx

mysql


安裝大部分通用的依賴包(不影響安裝,但是容易造成使用環境出現問題)

freetype-devel libpng-devel gd-devel curl-devel(libcurl-devel) libxslt-devel

zlib-devel libxml2-devel libjpeg-devel(libjpeg-turbo-devel) libiconv-devel 


其中有可能libiconv-devel (若第三方源有用yum可以安裝則不需要這步)

mkdir -p ~/tools && cd ~/tools &&\

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz &&\

tar xf libiconv-1.14.tar.gz && cd libiconv-1.14 &&\

./configure --prefix=/usr/local/libiconv && make && make install && echo $?


檢查下是否已經安裝

rpm -qa xxx


安裝libmcrypt庫(編譯安裝)

wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

tar xf libmcrypt-2.5.8.tar.gz && cd libmcrypt && ./configure && make && make install

sleep 5

/sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-install && make && make install


可以使用yum安裝以上的包,部分需要第三方源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo &&\

yum install libmcrypt-devel -y


安裝mcrypt

yum install mcrypt -y && rpm -qa grep|mcrypt


安裝mhash庫

yum install mhash mhash-devel -y


###############################

PHP5.3

解壓進入目錄

查看編譯參數

./configure --help


當使用--with-mysql=mysqlnd 時,本地不需要安裝mysql

mysql,curl,fpm,with-fpm-user,with-fpm-group為關鍵參數

./configure \

--prefix=/application/php5.x.x \

--with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-iconv-dir=/usr/local/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-safe-mode \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--with-curlwrappers \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-zend-multibyte \

--enable-static \

--with-xsl \

--with-fpm-user=nginx \

--with-fpm-group=nginx \

--enable-ftp



(待確認功能)--enable-mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-mysqli=mysqlnd \


假如使用自己的資料庫則make前需要處理下(2選1)

1、ln /application/mysql/lib/libmysqlclient.so.18 /usr/lib64 && touch ext/phar/phar.phar

2、echo ‘/application/mysql/lib‘ >>/etc/ld.so.conf && ldconfig


make && make install && ln -s /application/php5.3.xx /application/php


############################

PHP5.5部分參數不可用


./configure \

--prefix=/application/php5.x.x \

--with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-iconv-dir=/usr/local/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-xsl \

--with-fpm-user=nginx \

--with-fpm-group=nginx \

--enable-ftp


##############################

配置解析檔案(若需要最佳化php解析,改該檔案)

cp /application/php/php.ini-production /application/php/lib/php.ini


配置進程檔案

cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf


修改fpm設定檔

pid = /app/logs/php-fpm.pid

error_log = /app/logs/php-fpm.log

log_level = error

;檔案描述符

rlimit = 32768

events.mechanism = epoll

listen.owner = nginx

listen.group = nginx

pm.max_children = 1024

pm.start_servers = 16

pm.min_spare_servers = 5 

pm.max_spare_servers = 20

pm.process_idle_timeout = 15s;

pm.max_requests = 2048

slowlog = /app/logs/$pool.log.slow

request_slowlog_timeout = 10

p_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]


配置nginx,將請求處理追加到server配置裡

location ~.*/.(php|php5)?$ {

 root html/blog;

 fastcgi_pass 127.0.0.1:9000;

 fastcgi_index index.php;

 include fastcgi.conf;

}


重新檢查載入nginx檔案


頁面測試

<?php

phpinfo.php

?>


資料庫測試

<?php

$link_id=mysql_connect(‘mysql_server‘,‘mysql‘,‘password‘) or mysql_error();

if($link_id){

echo "successful!";

}else{

echo mysql_error();

}

?>




本文出自 “神奇的海螺” 部落格,請務必保留此出處http://bilishell.blog.51cto.com/11756401/1829504

筆記:centos6 php配置測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.