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

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 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/

./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 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

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 #拷贝配置文件 (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系统数据库

CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动

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

Start: 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

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

Error 1:

Workaround:

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 =//http://www.pprar.com

Vi/usr/local/php/etc/php.ini

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

Create a fastcgi configuration file

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

Modifying the fastcgi configuration file

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

Remove comments from the following lines

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

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

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

Error 2:error:unable to bind listening socket for address ' 127.0.0.1:9000 ': 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/gnome-keyring-pkcs11.so:/usr/lib/i386-linux-gnu/pkcs11/ Gnome-keyring-pkcs11.so:cannot 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/gnome-keyring-pkcs11.so usr/lib/i386-linux-gnu/pkcs11/ Gnome-keyring-pkcs11.so

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

Start Nginx

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

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

Stop service: Killall nginx

III. Deployment of applications

3.1 Environment Deployment

Vi/usr/local/nginx/conf/nginx.conf

Add to

server {

Listen 7070; #外网访问端口号

server_name blue-desk.com.cn;

Location/{

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 10.128.7.101:9000; #与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.

  • 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: info-contact@alibabacloud.com 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.