Install php5.4.13 in ubuntu source code and configure nginxubuntu11.04. the following steps are based on my installation in the previous two days and install php5.4.13 in ubuntu in sequence, I hope that my friends can operate in order to avoid repeated operations. can I save you time? Install php5.4.13 in ubuntu source code and Configure nginx
Ubuntu11.04, the following steps are based on my installation in the previous two days, and installed again under the new ubuntu
The steps are all in sequence. we hope that you can operate them in sequence to avoid repeated operations. We hope this will save you time.
?
I. preparations before installation
Download the latest version of php-5.4.13.tar.gz to the/user/src directory.
?
II. Installation
??? The installation of php depends on many libraries. to prevent repeated installation, we recommend that you follow the steps below.
??? Install autoconf
apt-get install autoconf
??? Install libxml2 library
apt-get install libxml2-dev
??? Install libbz2-dev
apt-get install libbz2-dev
??? Install curl
apt-get install libcurl4-gnutls-dev
??? Install stronglib
apt-get install libjpeg-dev
??? Install png
apt-get install libpng-dev
? ? Install libxpm-dev
apt-get install libxpm-dev
??? Install freetype
apt-get install libfreetype6-dev
??? Install libt1
apt-get install libt1-dev
??? Install mcrypt
apt-get install libmcrypt-dev
??? Install xslt
apt-get install libxslt1-dev
???
??? Follow the steps above to install the library, which will save you at least 20 minutes or more. if there are any errors, install the library as prompted.
??? Finally, execute the installation command, the original php file package is currently unzipped/usr/src/php-5.4.13 Directory
. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-curl -- with-pear -- with-gd -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-xpm-dir -- with-freetype-dir -- with-t1lib -- with-mcrypt -- with-mhash -- -mysql -- with-mysqli -- enable-pdo -- with-pdo-mysql -- with-openssl -- with-xmlrpc -- with-xsl -- with-gettext -- with-fpm-user = www -data -- with-fpm-group = www-data -- enable-fpm -- enable-exif -- enable-wddx -- enable-zip -- enable-bcmath-with-bz2 -- enable-calendar -- enable -ftp -- enable-mbstring -- enable-soap -- enable-sockets -- enable-shmop -- enable-dba -- enable-sysvmsg -- enable-sysvsem -- enable-sysvshm -- enable-debug -- enable -maintainer-zts -- enable-embedmake & make install
Installation successful !!
?
3. configure php
??? Add the php installation directory to the PATH
echo 'if [ -d "/usr/local/php/bin" ] && [ -d "/usr/local/php/sbin" ]; then PATH="$PATH:/usr/local/php/bin:/usr/local/php/sbin" fi' >> /etc/bash.bashrc
??? The current member is added to the PATH.
export PATH="$PATH:/usr/local/php/bin:/usr/local/php/sbin"
??? Prepare the php log file directory
mkdir /var/log/php-fpm chown -R www:www /var/log/php-fpm
??? Prepare the php configuration file
cd /usr/src/php-5.4.13cp -f php.ini-production /usr/local/php/etc/php.inichmod?644?/usr/local/php/etc/php.inicp?/usr/local/php/etc/php-fpm.conf.default?/usr/local/php/etc/php-fpm.conf
Note: The PHP configuration file is in/usr/local/php/etc/php. ini,
???????? Php-fpm configuration file in/usr/local/php/etc/php-fpm.conf.
?
??? Set the php-fpm startup management file and enable PHP to run automatically at ubuntu startup.
cp -f sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod 755 /etc/init.d/php-fpmupdate-rc.d -f php-fpm defaults
??? Set automatic log segmentation and compression for PHP
Vi/etc/logrotate. d/php-fpm enter the following content:/var/log/php-fpm/*. log {weeklymissingokrotate 52 compressdelaycompress1_emptycreate 640 www wwwsharedscriptspostrotate [! -F/usr/local/php/var/run/php-fpm.pid] | kill-USR1 'cat/usr/local/php // var/run/php-fpm.pid 'endscript}
?
IV,Configure php-fpm and nginx
??? Open the php-fpm configuration file
vi /usr/local/php/etc/php-fpm.conf
?? The following parameters need to be changed
Pid = run/php-fpm.pid // This must be removed from the previous; comment (the result was not removed at the beginning with a 502 error)
Error_log = log/php-fpm.log
Log_level = notice
; Emergency_restart_threshold = 0
; Emergency_restart_interval = 0
; Process_control_timeout = 0
; Daemonize = yes
[Www]
; Prefix =/path/to/pools/$ pool
Listen = 127.0.0.1: 9000
; Listen. backlog =-1
Listen. allowed_clients = 127.0.0.1
Listen. owner = www
Listen. group = www
Listen. mode = 0666
User = www
Group = www
Pm = dynamic
Pm. max_children = 50
Pm. start_servers = 20
Pm. min_spare_servers = 5
Pm. max_spare_servers = 35
Pm. max_requests = 500
Then Configure nginx
vi /usr/local/nginx/conf/nginx.conf
? ? The content is as follows:
User www;
Worker_processes 2;
Error_log/var/log/nginx/error. log warn;
Pid/var/run/nginx. pid;
Events
{
Use epoll;
Worker_connections 1024;
}
Http
{
Include mime. types;
Default_type application/octet-stream;
# Charset gb2312;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32 k;
Large_client_header_buffers 4 32 k;
Client_max_body_size 8 M;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 60;
Tcp_nodelay on;
Fastcgi_connect_timeout 300 s;
Fastcgi_send_timeout 300 s;
Fastcgi_read_timeout 300 s;
Fastcgi_buffer_size 64 k;
Fastcgi_buffers 4 64 k;
Fastcgi_busy_buffers_size 128 k;
Fastcgi_temp_file_write_size 128 k;
Gzip on;
Gzip_min_length 1 k;
Gzip_buffers 4 16 k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
# Limit_zone crawler $ binary_remote_addr 10 m;
Server
{
Listen 80; #/* listener port */
Server_name localhost; #/* server name */
Index index.html index.htm index. php; #/* Default homepage name */
Root/var/www; #/* the root directory of the website. you can also use the following content */
# You can also use relative paths. the following comments */
# Location /{
# Root html;
# Index index.html index.htm;
#}
# Limit_conn crawler 20;
# FastCGI supports PHP and php pages are processed by the fastcgi proxy. this is also an application of reverse proxy. jsp/asp and other scripts can be used here.
Location ~ . * \. (Php | php5 )? $
{
Include/etc/nginx/fastcgi_params; # set basic environment variables for the FastCGI module
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www/$ fastcgi_script_name;
# Include fcgi. conf; #/* fastcgi configuration file, changed to the following content */
}
# For a certain type of files, set the expiration time. the static page is usually a little longer.
# Handle static files by nginx
Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf | js | css) $
{
Expires 30d;
}
# Log Format
Log_format access' $ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" $ http_x_forwarded_for ';
Access_log/var/log/nginx/access. log access;
}
}
??? Save and exit. restart fpm and nginx.
/etc/init.d/php-fpm restart /etc/init.d/nginx restart
??? Installation complete !!!