(60MB)
:Http://pan.baidu.com/s/1kTieHzL
Md5sum png.tar.gz 547e261ef268d267799add5e2ffa4f34
To install a dependency package:
sudo apt-get-y install \
Build-essential \
autoconf \
Libtool \
LIBXML2 \
Libxml2-dev \
OpenSSL \
Libcurl4-openssl-dev \
libbz2-1.0 \
Libbz2-dev \
Libjpeg-dev \
Libpng12-dev \
Libfreetype6 \
Libfreetype6-dev \
Libldap-2.4-2 \
Libldap2-dev \
LIBMCRYPT4 \
Libmcrypt-dev \
Libmysqlclient-dev \
libxslt1.1 \
Libxslt1-dev \
Libxt-dev \
Libpcre3-dev
It is necessary to download the 24MB installation package.
To create a running user:
sudo addgroup png--system
sudo adduser png--system--disabled-login--ingroup png--no-create-home--home/nonexistent--gecos "PNG user"--shell/ Bin/false
To create an extract directory:
sudo mkdir/png
sudo chown $USER: $USER/png
Unzip to the corresponding directory:
Tar xzf png.tar.gz-c/png
/png/httpd/2.4.10/
/png/nginx/1.6.0/
/png/php/5.4.31/
Site root directory:
/png/www/
Configuration location:
/png/httpd/2.4.10/conf/httpd.conf
/png/nginx/1.6.0/conf/nginx.conf
/png/php/5.4.31/lib/php.ini
/png/php/5.4.31/etc/php-fpm.conf
Start:
Sudo/png/httpd/2.4.10/bin/apachectl start
Sudo/png/nginx/1.6.0/png-nginx start
SUDO/PNG/PHP/5.4.31/PNG-FPM start
Top-n1-b|egrep ' HTTPD|NGINX|FPM '
Test:
Curl-i 127.0.0.1/info.php
Curl-i 127.0.0.1/fpm/info.php
Curl-i 127.0.0.1:8080/info.php
Boot from:
sudo ln-s/png/httpd/2.4.10/bin/apachectl/etc/init.d/png-httpd
sudo ln-s/png/nginx/1.6.0/png-nginx/etc/init.d/
sudo ln-s/png/php/5.4.31/png-fpm/etc/init.d/
sudo update-rc.d png-httpd defaults
sudo update-rc.d png-nginx defaults
sudo update-rc.d png-fpm defaults
Use service to manage these several services:
sudo service png-httpd Restart|stop|start
sudo service Png-nginx Restart|stop|start
sudo service png-fpm Restart|stop|start
If necessary, you can delete the startup item like this:
sudo update-rc.d-f png-httpd Remove
sudo update-rc.d-f png-nginx Remove
sudo update-rc.d-f png-fpm Remove
To configure environment variables:
sudo nano/etc/profile at the end of the join:
Export Path=/png/nginx/1.6.0/sbin:/png/httpd/2.4.10/bin:/png/php/5.4.31/bin: $PATH
The source/etc/profile takes effect at the current terminal and the restart is fully in effect.
Nginx-v && httpd-v && php-v
To restart the test:
sudo shutdown-r now
attached: Compiling configuration reference (Grant people to Fish & give people with fishing)
nginx Compile configuration:
Edit Nginx Source code package in the AUTO/CC/GCC, with "#" comment off cflags= "$CFLAGS-G", remove the debug information, so compiled Nginx volume less than 1MB.
To modify Nginx header information:
Src/core/nginx.h
#define Nginx_version "1.6.0"
#define Nginx_ver "nginx/" nginx_version where NGINX can be changed to Nginx_ubuntu_server
Where Ngx_cache_purge is a third-party module, please download it yourself and use--add-module to specify the location.
configure-nginx.sh
#!/bin/bash
./configure \
--prefix=/png/nginx/1.6.0 \
--sbin-path=/png/nginx/1.6.0/sbin/nginx \
--conf-path=/png/nginx/1.6.0/conf/nginx.conf \
--error-log-path=/png/nginx/1.6.0/var/log/error.log \
--http-log-path=/png/nginx/1.6.0/var/log/access.log \
--pid-path=/png/nginx/1.6.0/var/run/nginx.pid \
--lock-path=/png/nginx/1.6.0/var/run/nginx.lock \
--http-client-body-temp-path=/png/nginx/1.6.0/var/cache/client_temp \
--http-proxy-temp-path=/png/nginx/1.6.0/var/cache/proxy_temp \
--http-fastcgi-temp-path=/png/nginx/1.6.0/var/cache/fastcgi_temp \
--http-uwsgi-temp-path=/png/nginx/1.6.0/var/cache/uwsgi_temp \
--http-scgi-temp-path=/png/nginx/1.6.0/var/cache/scgi_temp \
--user=png \
--group=png \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--add-module=/png/src/ngx_cache_purge-2.1
After you have successfully generated the Makefile, you can perform a build && make install installation.
Nginx's service management script can refer to the script/etc/init.d/nginx in Nginx's official Deb package:
http://nginx.org/packages/ubuntu/pool/nginx/n/nginx/
You only need to modify several values that the script begins to define:
Conffile=/png/nginx/1.6.0/conf/nginx.conf
Daemon=/png/nginx/1.6.0/sbin/nginx
pidfile=/png/nginx/1.6.0/var/run/$NAME. PID
scriptname=/png/nginx/1.6.0/$NAME
I put the modified service management script in the/png/nginx/1.6.0/png-nginx
Edit/png/nginx/1.6.0/conf/nginx.conf
Remove the two rows from the location/, and add them at location/front:
# define root directory and index file
root/png/www;
Index index.html index.htm index.php;
# Open Directory List
AutoIndex on;
Autoindex_exact_size off;
Autoindex_localtime on;
Add at location/post:
# The PHP request under the FPM directory is referred to PHP-FPM processing
Location ^~/FPM {
Location ~ \.php$ {
Try_files $uri = 404;
Include Fastcgi_params;
#fastcgi_pass 127.0.0.1:9000;
Fastcgi_pass Unix:/tmp/php-fpm.sock;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
}
}
# Other PHP requests are handled by the Apache listening on port 8080
Location ~ \.php$ {
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $remote _addr;
Proxy_set_header Host $host;
Proxy_pass http://127.0.0.1:8080;
}
Apache Compilation configuration:
To modify the header information for httpd:
File 1:include/ap_release.h
#define Ap_server_basevendor "Apache software Foundation"
#define Ap_server_baseproject "Apache HTTP SERVER"
#define AP_SERVER_BASEPRODUCT "Apache" where Apache can be changed to Apache_ubuntu_server
#define Ap_server_majorversion_number 2
#define AP_SERVER_MINORVERSION_NUMBER 4
#define Ap_server_patchlevel_number 9
File 2:os/unix/os.h
#define PLATFORM "Unix" where UNIX can be changed to Gnu/linux
configure-httpd.sh
#!/bin/bash
./configure \
--prefix=/png/httpd/2.4.10 \
--enable-mods-shared=most \
--enable-ssl=shared \
--WITH-SSL=/USR \
--WITH-INCLUDED-APR \
--with-mpm=prefork
After you have successfully generated the Makefile, you can perform a build && make install installation.
Edit/png/httpd/2.4.10/conf/httpd.conf
Add at the end:
# The files ending in. php are handled by the PHP module, replacing AddHandler application/x-httpd-php. php
<filesmatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
# add index.php, load index.php when there is no index.html
<ifmodule dir_module>
DirectoryIndex index.html index.php
</IfModule>
# modifier List
Include conf/extra/httpd-autoindex.conf
# Set the list encoding (default is Iso-8859-1)
Indexoptions Charset=utf-8
# Displays detailed server information
Serversignature on
Servertokens full
# Hide Version Information
#ServerSignature OFF
#ServerTokens Prod
Include conf/extra/httpd-mpm.conf
To modify a running user:
Put
User Daemon
Group Daemon
Switch
User png
Group png
Because Nginx and PHP compile configuration with the parameters specified Nginx and php-fpm running users, so Nginx and php-fpm running users do not need to manually modify.
To modify the root directory of Apache:
Search for/png/httpd/2.4.10/htdocs, replace with/png/www, 2 places.
Open. htaccess Rewrite support:
Change the <directory "/png/www" > allowoverride none to allowoverride all
To modify the listening port:
Change Listen 80 to Listen 8080
Change ServerName www.example.com:80 to ServerName 127.0.0.1:8080
PHP compiler configuration:
Note the order, compile Apache first, then compile PHP, because PHP needs to be compiled using--WITH-APXS2=/PNG/HTTPD/2.4.10/BIN/APXS build Apache PHP module libphp5.so.
Do a soft link to the LDAP library before compiling PHP, otherwise the--WITH-LDAP parameter will cause configure and make to fail.
32-bit:
sudo ln-s/usr/lib/i386-linux-gnu/libldap.so/usr/lib/
sudo ln-s/usr/lib/i386-linux-gnu/liblber.so/usr/lib/
64-bit:
sudo ln-s/usr/lib/x86_64-linux-gnu/libldap.so/usr/lib/
sudo ln-s/usr/lib/x86_64-linux-gnu/liblber.so/usr/lib/
configure-php.sh
#!/bin/bash
./configure \
--prefix=/png/php/5.4.31 \
--ENABLE-FPM \
--ENABLE-PDO \
--enable-sockets \
--ENABLE-EXIF \
--ENABLE-SOAP \
--ENABLE-FTP \
--ENABLE-WDDX \
--ENABLE-PCNTL \
--ENABLE-SOAP \
--enable-bcmath \
--enable-mbstring \
--ENABLE-DBA \
--ENABLE-GD-NATIVE-TTF \
--enable-zip \
--enable-calendar \
--ENABLE-SHMOP \
--ENABLE-SYSVMSG \
--enable-sysvsem \
--ENABLE-SYSVSHM \
--with-mysql \
--WITH-MYSQLI \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-iconv \
--with-zlib \
--WITH-BZ2 \
--with-gettext \
--WITH-XMLRPC \
--WITH-OPENSSL \
--with-mhash \
--with-mcrypt \
--with-xsl \
--with-curl \
--with-pcre-regex \
--WITH-GD \
--WITH-FREETYPE-DIR=/USR \
--WITH-JPEG-DIR=/USR \
--WITH-PNG-DIR=/USR \
--WITH-LDAP \
--with-pear \
--with-fpm-user=png \
--with-fpm-group=png \
--with-apxs2=/png/httpd/2.4.10/bin/apxs
After you have successfully generated the Makefile, you can perform a build && make install installation.
Once PHP is compiled, PHP modules are automatically loaded into the/png/httpd/2.4.10/conf/httpd.conf without adding them manually:
LoadModule Php5_module modules/libphp5.so
Install Common extensions:
/png/php/5.4.31/bin/pecl Install ZendOpcache-7.0.3 xdebug memcache Redis
PHP config file php.ini:
cp/png/src/php-5.4.31/php.ini-*/png/php/5.4.31/lib/
Cp/png/php/5.4.31/lib/php.ini-development/png/php/5.4.31/lib/php.ini
At the end of/png/php/5.4.31/lib/php.ini, add:
; zend_extension=/png/php/5.4.31/lib/php/extensions/no-debug-non-zts-20100525/opcache.so
; opcache.memory_consumption=128
; opcache.interned_strings_buffer=8
; opcache.max_accelerated_files=4000
;; Verifies that PHP file timestamps are updated every 60 seconds
;; o Pcache.revalidate_freq=60
; opcache.fast_shutdown=1
; opcache.enable_cli=1
;; Close PHP File Validation
; Opcache.validate_timestamps=off
;; Set non-Cached blacklists
; opcache.blacklist_filename=/png/www/blacklist
;; The default opcache is on, corresponding to the master value value under Zend Opcache in Phpinfo ().
; opcache.enable=on
; Permission settings chmod 777/png/xdebug
When using NGINX+PHP-FPM to configure Request_terminate_timeout in php-fpm.conf, PHP.ini is configured in Max_execution_time when using httpd+php, Avoid debug timeouts.
; Xdebug (PHP-FPM) connects NetBeans or eclipse-monitored 9001 ports for debugging sessions (session) execution commands are visible: sudo lsof-i: 9001 or sudo netstat-antp|grep 9001
; NetBeans listens on port 9001 for Xdebug debugging and does not listen for this port when debugging.
Zend_extension=/png/php/5.4.31/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
Xdebug.remote_enable = On
Xdebug.remote_handler = DBGP
Xdebug.remote_host = 127.0.0.1
Xdebug.remote_port = 9001
Xdebug.remote_log= "/png/xdebug/xdebug.log"
; Can only open Profiler profiler
; xdebug.profiler_enable = 1
; xdebug.profiler_output_dir = "/png/xdebug/"
Extension=memcache.so
Extension=redis.so
Set the value of the Date.timezone to Asia/shanghai
PHP-FPM configuration file and service management scripts:
Cp/png/php/5.4.31/etc/php-fpm.conf.default/png/php/5.4.31/etc/php-fpm.conf
cp/png/src/php-5.4.31/sapi/fpm/init.d.php-fpm/png/src/php-5.4.31/png-fpm
PHP-FPM listens to port 9000 for communication by default, or you can use UNIX sock communication instead:
Change listen = 127.0.0.1:9000 to listen =/tmp/php-fpm.sock
and open:
Listen.owner = png
Listen.group = png
Listen.mode = 0660
compile time comparison:
Time nice-20 make-j4 (Ubuntu 14.04 uses i5-3230m to compile Nginx 1.6.0 for 14 seconds, CPU idle value is almost 0 during compilation)
Time nice-20 make (Ubuntu 14.04 takes 32 seconds to compile Nginx 1.6.0 with i5-3230m, CPU idle value is around 73% during compilation)
Time nice-20 make (Ubuntu 14.04 uses i5-3230m to compile Apache 2.4.10 2分钟20秒, CPU idle value during compilation is around 73%)
Time nice-20 make (Ubuntu 14.04 uses i5-3230m to compile PHP 5.4.31 takes 5分钟50秒, CPU idle value is around 73% during compilation)
Data storage services like mysql,memcached I generally use apt-get installation, convenient and quick:
sudo apt-get install mysql-server memcached