Advertisement
Guest User

NginX PHP HTTP 499 Error Build

a guest
Mar 25th, 2013
1,333
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Update the OS
  2. sudo apt-get update && sudo apt-get upgrade -y
  3.  
  4. ### Install some tools which we need for the platform or for monitoring
  5. sudo apt-get install build-essential -y && \
  6. sudo apt-get install nginx -y && \
  7. sudo apt-get install mysql-client -y && \
  8. sudo apt-get install mytop -y && \
  9. sudo apt-get install git -y && \
  10. sudo apt-get install lynx -y && \
  11. sudo apt-get install autoconf -y && \
  12. sudo apt-get install htop -y && \
  13. sudo apt-get install sysstat -y && \
  14. sudo apt-get install iptraf -y
  15.  
  16.  
  17. ### Create NginX Config files
  18.  
  19. sudo echo '## Drop Config
  20. # Dont record errors regarding missing favicons and robot.txt
  21. location = /robots.txt  {
  22.    access_log off;
  23.    log_not_found off;
  24.    try_files /robots.txt =204;
  25. }
  26. location = /favicon.ico {
  27.    access_log off;
  28.    log_not_found off;
  29.    try_files /favicon.ico =204;
  30. }
  31. # Refuse to server linux hidden files includes .htaccess etc
  32. location ~ /\.          { access_log off; log_not_found off; deny all; }
  33. # Dont serve and swap files createed by VIM etc
  34. location ~ ~$           { access_log off; log_not_found off; deny all; }
  35. ' > /etc/nginx/drop.conf
  36.  
  37. ### Get PHP 5.4.11
  38. sudo wget http://www.php.net/get/php-5.4.11.tar.bz2/from/uk1.php.net/mirror && sudo tar -xjf mirror && sudo rm mirror && cd php-5.4.11
  39.  
  40. ## Get PHP Dependancies
  41. sudo apt-get install \
  42. libxml2 \
  43. libxml2-dev \
  44. libcurl4-openssl-dev \
  45. libmcrypt-dev \
  46. libmcrypt4 \
  47. libxml-libxslt-perl \
  48. libxslt1-dbg \
  49. libxslt1-dev -y
  50.  
  51.  
  52. ### Compile PHP
  53.  
  54. sudo ./configure \
  55. --prefix=/usr/local/php \
  56. --enable-fpm \
  57. --with-fpm-user=www-data \
  58. --with-fpm-group=www-data \
  59. --with-config-file-path=/usr/local/php/php.ini \
  60. --with-config-file-scan-dir=/usr/local/php/conf.d \
  61. --enable-debug \
  62. --with-openssl \
  63. --with-kerberos \
  64. --with-zlib \
  65. --with-curl \
  66. --with-curlwrappers \
  67. --enable-exif \
  68. --with-jpeg-dir=/usr \
  69. --with-png-dir=/usr \
  70. --with-vpx-dir=/usr \
  71. --with-freetype-dir=/usr \
  72. --enable-exif \
  73. --with-mhash \
  74. --enable-mbstring \
  75. --with-mcrypt \
  76. --with-mysql \
  77. --with-mysqli \
  78. --with-pdo-mysql \
  79. --enable-shmop \
  80. --enable-soap \
  81. --enable-sockets \
  82. --with-xsl \
  83. --enable-zip \
  84. --with-pear
  85.  
  86. sudo make && sudo make test
  87. sudo make install &&  sudo cp /home/ubuntu/php-5.4.11/php.ini-production /usr/local/php/php.ini
  88. sudo
  89. PATH=/usr/local/php/bin:$PATH && pear upgrade-all
  90.  
  91. # Update the System PATH
  92. PATH=/usr/local/php/bin:$PATH
  93.  
  94. ### Install APC Cache using PECL
  95. pecl install apc
  96. # Create the PHP.ini conf settings for APC in a separate file for ease of administration
  97. sudo mkdir /usr/local/php/conf.d && sudo echo '[PHP]
  98. extension=apc.so
  99. apc.enabled=1
  100. apc.shm_segments=1
  101. apc.shm_size=128M
  102. apc.ttl=7200
  103. apc.user_ttl=7200
  104. apc.num_files_hint=1024
  105. apc.enable_cli=0
  106. apc.cache_by_default=1
  107. apc.filters
  108. apc.mmap_file_mask=/tmp/apc.XXXXXX
  109. apc.file_update_protection=2' > /usr/local/php/conf.d/apc.conf
  110.  
  111. # Set a default timezone
  112. sudo echo '[PHP]
  113. date.timezone = Europe/London' > /usr/local/php/conf.d/date.conf
  114.  
  115. # PHP CLI Config Settings
  116. sudo echo '[PHP]
  117. log_errors = on
  118. error_log = /var/log/php.log
  119. ' > /usr/local/php/conf.d/error.ini
  120.  
  121. # Restart PHP and NginX
  122. sudo service php-fpm restart && sudo service nginx restart
  123.  
  124. # Create a fresh path to place the test files
  125. sudo mkdir /www && sudo chown www-data:www-data /www
  126.  
  127. ##### Then create a new NginX config within /etc/nginx/sites-enabled using the settings
  128.  
  129. server {
  130.     listen   80;
  131.     listen   [::]:80 default ipv6only=on;
  132.  
  133.     server_name example.com;
  134.     root    /www/;
  135.     index   index.php index.html index.htm;
  136.  
  137.     # Logs - Enable on REAL deployment
  138.     access_log /var/log/nginx/example.access.log;
  139.     error_log /var/log/nginx/example.error.log;
  140.  
  141.     location / {
  142.         # First attempt to serve request as file, then
  143.         # as directory, then fall back to index.html
  144.         try_files $uri $uri/ index.php;
  145.         # Uncomment to enable naxsi on this location
  146.         # include /etc/nginx/naxsi.rules
  147.     }
  148.  
  149.     # This block will catch static file requests, such as images, css, js
  150.     # The ?: prefix is a 'non-capturing' mark, meaning we do not require
  151.     # the pattern to be captured into $1 which should help improve performance
  152.     location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
  153.         # Some basic cache-control for static files to be sent to the browser
  154.         expires max;
  155.         add_header Pragma public;
  156.         add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  157.     }
  158.  
  159.     # Common configurations
  160.     include drop.conf;
  161.  
  162.     location ~ \.php$ {
  163.         try_files $uri =404;
  164.         fastcgi_pass 127.0.0.1:9000;
  165.         fastcgi_buffers 256 4k;
  166.     fastcgi_index index.php;
  167.     include fastcgi_params;
  168.     }
  169. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement