Deploying a PHP test environment on an Ubuntu machine

Source: Internet
Author: User
Tags ldap mcrypt openssl lib zts

Deploying a PHP test environment on an Ubuntu machine

First, the deployment environment

UBUNTU11.10_X86_32, compile and install the appropriate software: nginx+mysql+php.

Second, software Installation

2.1 Software Downloads









2.2 Environment Configuration

The system is more pure to install some necessary tools and software

Apt-get install gcc g++ ssh automake cmake build-essential autoconf make re2c wget cron bzip2 rcconf flex VIM Bison M4 Maw K CPP Binutils libncurses5 unzip tar libncurses5 libncurses5-dev libtool libpcre3 libpcrecpp0 libssl-dev zlibc OpenSSL Lib Xml2-dev libltdl3-dev libpcre3 libpcrecpp0 libssl-dev zlibc OpenSSL libxml2-dev libltdl3-dev Libmcrypt-dev

2.3 Auxiliary Software Installation

2.3.1 libiconv-1.14.tar.gz

Tar zxvf libiconv-1.14.tar.gz

CD libiconv-1.14/

CD libiconv-1.14/



Make install

2.3.2 mhash-

Tar zxvf mhash-

CD mhash-



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/



Make install


CD libltdl/



Make install

2.3.4 mcrypt-2.6.8.tar.gz

Tar zxvf mcrypt-2.6.8.tar.gz

CD mcrypt-2.6.8/




Make install

2.3.5 pcre-8.10.tar.gz

Tar zxvf pcre-8.10.tar.gz

CD pcre-8.10



Make install

2.4 Installing MySQL

Groupadd MySQL #添加mysql组

useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, does not allow MySQL users to log in directly to the system

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 install





CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: the/etc directory has a my.cnf under the default, can be directly overwritten)

Vi/etc/my.cnf #编辑配置文件, added in [mysqld] section

DataDir =/data/mysql #添加MySQL数据库路径

./scripts/mysql_install_db--user=mysql #生成mysql系统数据库


chmod 755/etc/init.d/mysqld #增加执行权限

Start: Bin/mysqld_safe-user=mysql &



Change Password/usr/local/mysql/bin/mysqladmin-u root-p password "123456"

Error 1:


2.5 Installing 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

Error 1:configure:error:please Reinstall the Libcurl distribution-easy.h should be in/include/curl/

Workaround: Apt-get Install Curl

Apt-get Install Libcurl4-gnutls-dev

Apt-get Install Php5-curl

Error 2: LDAP not found

WORKAROUND: Delete the----WITH-LDAP in the configuration information

Make zend_extra_libs= '-liconv '

Make Test

Make install

CP Php.ini-production/usr/local/php/etc/php.ini

Execute command View PHP related configuration, get php extension directory Extension-dir value:/usr/local/php/bin/php-config

This shows the information of Extension_dir =//


Modified: Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"

Create a fastcgi configuration file


Modifying the fastcgi configuration file


Remove comments from the following lines

PID = Run/

Error_log = Log/php-fpm.log

Log_level = Notice




Modify the following two lines of the file, do not modify the startup fastcgi will error "fastcgi [pool www] cannot get GID for group ' nobody '"

user = Nobody

Group = Nobody

Revision changed to

user = www

Group = www

Error 1: "fastcgi [pool www] cannot get gid for group ' www '"

WORKAROUND: You need to create your own users and groups

Sudo Useradd www

Start fastcgi


Error 2:error:unable to bind listening socket for address ' ': Address already on use (98)

ERROR:FPM initialization failed

Workaround: Netstat-lntup | grep 9000

Killall PHP-FPM

Error 3:COULDN ' t load module:/usr/lib/i386-linux-gnu/pkcs11/ open Shared object file:no such file or directory

WORKAROUND: 1) Install Getlibs

Download: Getlibs-all.deb

Execution: sudo dpkg-i--force-all getlibs-all.deb

sudo apt-get update getlibs AAPT

2) Install the 32-bit library

Getlibs-p gnome-keyring:i386

3) Creating Symbolic Links

sudo ln-s/usr/lib32/i386-linux-gnu/pkcs11/ usr/lib/i386-linux-gnu/pkcs11/

2.6 Installing Nginx

Tar zxvf nginx-1.1.10.tar.gz

CD nginx-1.1.10/



Make install

Start Nginx


Restart Service:/usr/local/nginx/sbin/nginx

Stop service: Killall nginx

III. Deployment of applications

3.1 Environment Deployment


Add to

server {

Listen 7070; #外网访问端口号



Root/usr/local/src/wwwroot; #应用所在地址

Index index.html INDEX.HTMI index.php;


Error_page 502 503 504/50x.html;

Location =/50x.html {

root HTML;


Location ~ \.php$ {

Root/usr/local/src/wwwroot; #应用所在地址

Fastcgi_pass; #与php-FPM Contact port number, PHP-FPM configuration in/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 Address of your application

Include Fastcgi_params;



3.2 Configuring the App

Onethink application Configuration

Database name: MySQL

User name: Root

Database Password: 123456

The above describes the deployment of the PHP test environment on the Ubuntu machine, including the aspects of the content, I hope that the PHP tutorial interested in a friend to help.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    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.