顯示具有 PHP 標籤的文章。 顯示所有文章
顯示具有 PHP 標籤的文章。 顯示所有文章

2014年3月11日 星期二

CentOS 6.4 安裝 Nginx+PHP5.5+PHP-FPM

翻譯、引用來源:http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/

一、開啟終端機,切換至su權限

二、安裝額外的來源套件
Remi repository
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
建立Nginx 來源文件
vi  /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
三、 安裝 Nginx, PHP 5.5.9 和 PHP-FPM
yum --enablerepo=remi,remi-php55 install nginx php-fpm php-common -y
四、 安裝 PHP 5.5.9 模組
yum --enablerepo=remi,remi-php55 install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y
五、 停止 httpd (Apache) , 並啟動 Nginx HTTP 和 PHP-FPM (FastCGI Process Manager)服務
service httpd stop
service nginx start
service php-fpm start
六、開機時自動啟動啟動 Nginx 和 PHP-FPM ,並關閉httpd(Apache)自動執行
chkconfig httpd off
chkconfig --add nginx
chkconfig --levels 235 nginx on
chkconfig --add php-fpm
chkconfig --levels 235 php-fpm on
七、 設定 Nginx 和 PHP-FPM (建立你的網站目錄)
在此範例使用 testsite.local 做為網站,但你也可以使用自己的網站名稱

建立網站目錄和記錄檔目錄
mkdir -p /srv/www/testsite.local/public_html
mkdir /srv/www/testsite.local/logs
chown -R apache:apache /srv/www/testsite.local
**這裡使用的是apache這個帳號做為目錄權限,如果要使用別的帳號,要記的修改 /etc/php-fpm.d/www.conf  中的user/group 帳號。
於 /etc/nginx/ 建立虛擬主機目錄
mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled
編輯 /etc/nginx/nginx.conf ,於 http {  } 這個區塊的 "include /etc/nginx/conf.d/*.conf" 下方新增一行 include /etc/nginx/sites-enabled/*;
vi /etc/nginx/nginx.conf
include /etc/nginx/sites-enabled/*;
於 /etc/nginx/sites-available/ ,建立 testsite.local 虛擬主機設定檔,內容如下
這是很基本的虛擬主機設定檔
 server {
    server_name testsite.local;
    access_log /srv/www/testsite.local/logs/access.log;
    error_log /srv/www/testsite.local/logs/error.log;
    root /srv/www/testsite.local/public_html;

    location / {
        index index.html index.htm index.php;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/testsite.local/public_html$fastcgi_script_name;
    }
建立虛擬主機連結,將 /etc/nginx/sites-available 下的設定檔連結至 /etc/nginx/sites-enabled,並重新啟動 nginx 使其生效
ln -s /etc/nginx/sites-available/testsite.local /etc/nginx/sites-enabled
service nginx restart
於 /etc/hosts 檔案中增加網站域名,讓它看起來像這個樣子
127.0.0.1               localhost.localdomain localhost testsite.local
八、測試網站
於 /srv/www/testsite.local/public_html/ 建立 index.php 文字,內容如下
<?php
    phpinfo();
?>
開啟瀏覽器,輸入 http://testsite.local/ 執行後應該可以看到php的版本資訊。


九、開啟 nginx 的遠端連線服務(放行 Iptables 防火牆的 80 Port)
編輯iptables的設定檔
vi /etc/sysconfig/iptables
新增一條規則於INPUT 區塊,內容如下
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重新啟動Iptables 防火牆
service iptables restart

2012年2月15日 星期三

使用XAMPP1.7.7安裝APC

使用XAMPP1.7.7安裝APC


一、至http://downloads.php.net/pierre/下載對應版本的 APC

二、解壓縮至 xampp\php\ext,重新命名為php_apc.dll

三、開啟xampp\php\php.ini
增加這行  extension = php_apc.dll


四、開啟http://127.0.0.1/xampp/phpinfo.php頁面
檢查頁面下是否有apc相關資訊,有即為安裝成功。

2012年2月14日 星期二

使用XAMPP1.7.7安裝eAccelerator

使用XAMPP1.7.7安裝eAccelerator

一、至http://dev.freshsite.pl/php-accelerators/eaccelerator.html下載對應版本的 eAccelerator

二、解壓縮至 xampp\php\ext,重新命名為php_eaccelerator_ts.dll

三、修改xampp\php\php.ini中的
;zend_extension = "\xampp\php\ext\php_eaccelerator_ts.dll"
為
extension = php_eaccelerator_ts.dll

四、開啟http://127.0.0.1/xampp/phpinfo.php頁面
檢查Zend Engine V2.3.0下是否有
 with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
 有該行即為安裝成功。

PHP 載入Intl.dll

使用XAMPP1.7.7要加戴PHP_intl.dll時發生錯誤

PHP版本:5.3.8

解決方式:
從\xampp\php\  複製以下三個檔案
icudt46.dll
icuin46.dll
icuuc46.dll
至xampp\apache\bin,再重新啟動 apache 即可。