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

來源:互聯網
上載者:User

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

一、部署環境

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

二、軟體安裝

2.1 軟體下載

libiconv-1.14.tar.gz

libmcrypt-2.5.7.tar.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 libncurses5 libncurses5-dev libtool libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-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/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=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)產生符號連結

sudo ln -s /usr/lib32/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so

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 10.128.7.101:9000; #與php-fpm聯絡的連接埠號碼,php-fpm的配置在/usr/local/php/etc/php-fpm.conf

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/local/src/wwwroot$fastcgi_script_name; #/usr/local/src/wwwroot 應用所在地址

include fastcgi_params;

}

}

3.2 配置應用

onethink 應用配置

資料庫名:mysql

使用者名稱: root

資料庫密碼:123456

以上就介紹了在ubuntu機器上部署php測試環境,包括了方面的內容,希望對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.