CentOS 6部署PHP開發環境

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   使用   ar   for   

適用環境:

CentOS 6.5 32bit

Linux + Nginx + Mysql + PHP


版本與時間:(截至此帖發帖日期2014-10-14,所有版本皆為最新版本)

Nginx-1.7.6

Mysql-5.6.21

PHP-5.6.1


一、下載:

nginx:http://nginx.org/en/download.html

mysql:http://dev.mysql.com/downloads/mysql/  (選擇Linux - Generic版本的Linux - Generic (glibc 2.5) (x86, 32-bit), Compressed

php:http://php.net/downloads.php#v5.6.1



二、安裝(忽略解壓過程,安裝完後預設路徑在/usr/local/xxx):

<1> Nginx

1. 安裝依賴包:# yum -y install pcre-devel zlib-devel

2. 配置安裝:

# ./configure

# make && make install

3. 建立軟連結:# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/

4. 進入/usr/local/nginx/conf目錄,建立虛擬機器主機配置目錄,並將此目錄匯入到nginx.conf中

# mkdir vhost

# vim ./nginx.conf (在最後大括弧前添加一行並儲存退出: include vhost/*.conf; )

5. 可在vhost目錄內建立虛擬機器主機設定檔,以.conf結尾,內容可參考nginx.conf中的server部分


<2>MySql

1. 直接將解壓後的目錄移至/usr/local/mysql

2. 進入/usr/local/mysql目錄,執行以下一系列命令(來源於Mysql官網文檔:http://dev.mysql.com/doc/refman/5.6/en/binary-installation.html):


3. 配置my.cnf

a. # vim /etc/my.cnf

b. 修改幾項(在[mysqld]下):

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

character-set-server=utf8

collation-server=utf8_general_ci

c.儲存退出,並重啟mysql


<3>php

1. 安裝依賴包:# yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel openldap-devel libmcrypt-devel

2. 建立軟連結(解決PHP5.6編譯時間報Don‘t know how to define struct flock on this system, set --enable-opcache=no的錯誤):

# sudo ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
# sudo ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

3. 配置:

# ./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 --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql

4. 編譯安裝(在上一步配置過程中無報錯的情況下才開始此步驟):

# make && make install

5. 複製開機檔案和設定檔

# cp <PHP解壓縮目錄下>/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# cp <PHP解壓縮目錄下>/php.ini-production /usr/local/php/etc/php.ini

# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

# chmod a+x /etc/init.d/php-fpm

最後就可以使用命令來啟動PHP了:service php-fpm start


CentOS 6部署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.