首頁 >後端開發 >php教程 >在ubuntu機器上部署php測試環境

在ubuntu機器上部署php測試環境

WBOY
WBOY原創
2016-08-08 09:30:531044瀏覽

在ubuntu機器上部署php測試環境

一、部署環境

Ubuntu11.10_X86_32,編譯安裝對應的軟體:nginx+mysql+php。

二、軟體安裝

2.1 軟體下載

libiconv-1.14.tar.gz

libmcrypt-2.5.7.ta​​r.gz

mcrypt-2.6.8.gz

mhash-0.9.9.9.tar.gz

mysql-5.5.39.tar.gz

nginx-1.1.10.tar.gz

pcre-8.20.tar.gz

php-5.4.34.tar.gz

2.2 環境配置

系統較為純淨要安裝一些必要的工具軟體

apt-get install gcc g++ ssh automake cmake build-essential autoconf make re2c wget cron bzip2 rcconf flex vim bison m4 mawk cpp binutils libncurses5 unzip tar xml2-dev libltdl3-dev libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-dev libltdl3-dev libmcrypt-dev

2.3 輔助軟體安裝

2.3.1 libiconv-1.14.tar.gz

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14/

cd libiconv-1.14/

./configure --prefix=/usr/local

make

make install

2.3.2 mhash-0.9.9.9.tar.gz

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9

./configure

make

make install

cd ../

2.3.3 libmcrypt-2.5.8.tar.gz

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure

make

make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make

make install

2.3.4 mcrypt-2.6.8.tar.gz

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure

make

make install

2.3.5 pcre-8.10.tar.gz

tar zxvf pcre-8.10.tar.gz

cd pcre-8.10

./configure

make

make install

2.4 安裝mysql

groupadd mysql    #新增mysql群組

useradd -g mysql mysql -s /bin/false  #建立使用者mysql並加入到mysql群組,不允許mysql使用者直接登入系統

mkdir -p /data/mysql   #建立MySQL資料庫存放目錄

chown -R mysql:mysql /data/mysql   #設定MySQL資料庫目錄權限

tar zxvf mysql-5.5.19.tar.gz

cd mysql-5.5.19

mkdir -p /usr/local/mysql   #建立MySQL安裝目錄

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8-unicode_ci -DMYSQL_DATADIR=/usr/local/mym/data -DWITH_INL -SQL_DATAD all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION =utf8_general_ci -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306

make

make install

cp support-files/my-small.cnf /etc/my.cnf

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

/usr/local/mysql/scripts/mysql_install_db --user=mysql

cd /usr/local/mysql

cp ./support-files/my-huge.cnf /etc/my.cnf   #拷貝設定檔(注意:/etc目錄下方預設有一個my.cnf,直接覆寫即可)

vi /etc/my.cnf   #編輯設定檔,在 [mysqld] 部分增加

datadir = /data/mysql  #新增MySQL資料庫路徑

./scripts/mysql_install_db --user=mysql  #產生mysql系統資料庫

cp ./support-files/mysql.server  /etc/rc.d/init.d/mysqld  #把Mysql加入系統啟動

chmod 755 /etc/init.d/mysqld   #增加執行權限

啟動:bin/mysqld_safe -user=mysql & 

ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql

ln -s /usr/local/mysql/include/mysql /usr/include/mysql

修改密碼/usr/local/mysql/bin/mysqladmin -u root -p password "123456"

錯誤1:

解決方法:

2.5 安裝php

apt-get install libfreetype6-dev libjpeg8-dev libpng12-dev slapd ldap-utils db5.1-util

apt-get install libldap2-dev libsasl2-dev

./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 --disable-maintainer-zts

錯誤1:configure: error: Please reinstall the libcurl distribution -    easy.h should be in /include/curl/

解決方法:apt-get install curl

           apt-get install libcurl4-gnutls-dev

           apt-get install php5-curl

錯誤2:找不到ldap

解決方法:在設定資訊中刪除 ----with-ldap

 

make ZEND_EXTRA_LIBS='-liconv'

make test

make install

cp php.ini-production /usr/local/php/etc/php.ini

執行指令查看PHP相關配置,取得PHP擴充存放目錄extension-dir值:/usr/local/php/bin/php-config

這裡顯示extension_dir =的資訊 // http://www.pprar.com

vi /usr/local/php/etc/php.ini

修改:extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"

建立fastcgi設定檔

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

修改fastcgi設定檔

vi /usr/local/php/etc/php-fpm.conf

去掉註解以下幾行的註解

pid = run/php-fpm.pid

error_log = log/php-fpm.log

log_level = notice

pm.start_servers

pm.min_spare_servers

pm.max_spare_servers

修改檔案以下兩行,不修改啟動fastcgi會報錯 “fastcgi [pool www] cannot get gid for group ‘nobody’”

user = nobody

group = nobody

修改為

user = www

group = www

錯誤1:「fastcgi [pool www] cannot get gid for group ‘www’」

解決方法:需要自行建立使用者以及群組

            Sudo useradd www

啟動fastcgi

/usr/local/php/sbin/php-fpm

錯誤2:ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)

       ERROR: FPM initialization failed

解決方法:netstat -lntup | grep 9000

           killall php-fpm

錯誤3:couldn't load module: /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11. so: cannot open shared object file: No such file or directory 

解決方法:1)安裝 getlibs

             下載:getlibs-all.deb

             執行:sudo dpkg -i --force-all getlibs-all.deb

                   sudo apt-get update getlibs aapt

          2)安裝32位元庫

             getlibs -p gnome-keyring:i386

          3)產生符號連結

                                             中與點

2.6 安裝Nginx

tar zxvf nginx-1.1.10.tar.gz

cd nginx-1.1.10/

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module

make

make install

啟動Nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

重啟服務:/usr/local/nginx/sbin/nginx

停止服務:killall nginx

三、應用部署

3.1 環境部署

vi /usr/local/nginx/conf/nginx.conf

添加

server {

        listen   7070;   #外部網路存取埠號碼

        server_name  blue-desk.com.cn;

        location / {

            root   /usr/local/src/wwwroot;    #應用程式所在位址

            index  index.html index.htmi index.php;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        location ~ .php$ {

            root           /usr/local/src/wwwroot;  #應用程式所在位址

            fastcgi_pass          fastcgi_pass          fastcgi_pass          fastcgi_pass   10.128.7.101:9000;   #與php-fpm聯絡的連接埠號,php-fpm的設定在/usr/local/php/et/

            fastcgi_index  index.php;

            fastcgi_param SCRIPT_FILENAME  /usr/local/src/wwwroot$fastcgi_script_name;   #/usr/local/src/wwwroot$fastcgi_script_name;   #/usr/local/src/wwwroot$fastcgi_script_name;   #/usr/local/src/wwwroot$fastcgi_script_name;   #/usr/local/src/wwwroot$fastcgi_script_name;   #/usr/local/src/wwwroot$fastcgi_script_name;   #/usr/local/src/wwwroot$fastcgi_script_name; .

            include        fastcgi_params;

        }

}

3.2 配置應用

onethink 應用程式配置

資料庫名稱:mysql

用戶名: root

資料庫密碼:123456

以上就介紹了在ubuntu機器上部署php測試環境,包括了方面的內容,希望對PHP教程有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:php輸出時間差下一篇:php輸出時間差