Unzip ready, Ubuntu on nginx/apache/php compilation package

Source: Internet
Author: User
Tags apache php ldap php compiler zts netbeans

(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-dev \
OpenSSL \
Libcurl4-openssl-dev \
libbz2-1.0 \
Libbz2-dev \
Libjpeg-dev \
Libpng12-dev \
Libfreetype6 \
Libfreetype6-dev \
Libldap-2.4-2 \
Libldap2-dev \
Libmcrypt-dev \
Libmysqlclient-dev \
libxslt1.1 \
Libxslt1-dev \
Libxt-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

Site root directory:

Configuration location:

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 '


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:
#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 \
--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 \
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:
You only need to modify several values that the script begins to define:
pidfile=/png/nginx/1.6.0/var/run/$NAME. PID
I put the modified service management script in the/png/nginx/1.6.0/png-nginx

Remove the two rows from the location/, and add them at location/front:
# define root directory and index file
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 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;

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_patchlevel_number 9

File 2:os/unix/os.h
#define PLATFORM "Unix" where UNIX can be changed to Gnu/linux

./configure \
--prefix=/png/httpd/2.4.10 \
--enable-mods-shared=most \
--enable-ssl=shared \
After you have successfully generated the Makefile, you can perform a build && make install installation.

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
# add index.php, load index.php when there is no index.html
<ifmodule dir_module>
DirectoryIndex index.html index.php
# 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:
User Daemon
Group Daemon
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

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.
sudo ln-s/usr/lib/i386-linux-gnu/libldap.so/usr/lib/
sudo ln-s/usr/lib/i386-linux-gnu/liblber.so/usr/lib/
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 \
--prefix=/png/php/5.4.31 \
--enable-sockets \
--enable-bcmath \
--enable-mbstring \
--enable-zip \
--enable-calendar \
--enable-sysvsem \
--with-mysql \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-iconv \
--with-zlib \
--WITH-BZ2 \
--with-gettext \
--with-mhash \
--with-mcrypt \
--with-xsl \
--with-curl \
--with-pcre-regex \
--with-pear \
--with-fpm-user=png \
--with-fpm-group=png \
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:
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.
Xdebug.remote_enable = On
Xdebug.remote_handler = DBGP
Xdebug.remote_host =
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/"


Set the value of the Date.timezone to Asia/shanghai

PHP-FPM configuration file and service management scripts:
PHP-FPM listens to port 9000 for communication by default, or you can use UNIX sock communication instead:
Change listen = 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

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.