Home  >  Article  >  Backend Development  >  Deploy php test environment on ubuntu machine

Deploy php test environment on ubuntu machine

WBOY
WBOYOriginal
2016-08-08 09:30:531028browse

Deploy php test environment on ubuntu machine

1. Deployment environment

Ubuntu11.10_X86_32, compile and install the corresponding software: nginx+mysql+php.

2. Software installation

2.1 Software Download

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 relatively clean and some necessary software tools need to be installed

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-dev libtool libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-dev libltd l3-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 Install mysql

groupadd mysql #Add mysql group

useradd -g mysql mysql -s /bin/false #Create user mysql and add it to the mysql group. Mysql users are not allowed to log in to the system directly

mkdir -p /data/mysql #Create MySQL database storage directory

chown -R mysql:mysql /data/mysql #Set MySQL database directory permissions

tar zxvf mysql-5.5.19.tar.gz

cd mysql-5.5.19

mkdir -p /usr/local/mysql #Create MySQL installation directory

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_CHAR SETS=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 #Copy the configuration file (note: there is a my.cnf under the /etc directory by default, just overwrite it directly)

vi /etc/my.cnf #Edit the configuration file and add

to the [mysqld] section

datadir = /data/mysql #Add MySQL database path

./scripts/mysql_install_db --user=mysql #Generate mysql system database

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #Add Mysql to the system to start

chmod 755 /etc/init.d/mysqld #Increase execution permissions

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:

Solution:

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

Solution: apt-get install curl

           apt-get install libcurl4-gnutls-dev

apt-get install php5-curl

Error 2: ldap not found

Solution: Delete ----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 the command to view the PHP related configuration and obtain the extension-dir value of the PHP extension storage directory: /usr/local/php/bin/php-config

The information of extension_dir = is displayed here // http://www.pprar.com

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

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

Create fastcgi configuration file

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

Modify fastcgi configuration file

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

Uncomment 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. If you start fastcgi without modification, an error will be reported “fastcgi [pool www] cannot get gid for group ‘nobody’”

user = nobody

group = nobody

was modified to

user = www

group = www

Error 1: “fastcgi [pool www] cannot get gid for group ‘www’”

Solution: You need to create users and groups yourself

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 in use (98)

      ERROR: FPM initialization failed

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

Solution: 1) Install getlibs

Download: getlibs-all.deb

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

T Sudo Apt-get update getlibs aapt

      2) Install 32-bit libraries

                  getlibs -p gnome-keyring:i386

3) Generate symbolic link

                  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 Install 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 the service:/usr/local/nginx/sbin/nginx

Stop service: killall nginx

3. Application deployment

3.1 Environment Deployment

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

Add

server {

Listen 7070; #External network access port number

               server_name  blue-desk.com.cn;

location / {

U root/usr/local/src/wwwroot;#The address of the application

                                                                                                                                                                                        off

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

location ~ .php$ {

                                                                                                                                                                                                                      since_ FastCGI_PASS 10.128.7.101:9000;#-connected port number connected to PHP-FPM, PHP-FPM configuration is at /usr/local/php/php-fpm.conf

fastcgi_index index.php;

                        fastcgi_param SCRIPT_FILENAME   /usr/local/src/wwwroot$fastcgi_script_name;     #/usr/local/src/wwwroot Application address

E include fastcgi_params;

}

}

3.2 Configure application

onethink application configuration

Database name: mysql

Username: root

Database password: 123456

The above introduces the deployment of PHP test environment on Ubuntu machine, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn