Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Update the OS
- sudo apt-get update && sudo apt-get upgrade -y
- ### Install some tools which we need for the platform or for monitoring
- sudo apt-get install build-essential -y && \
- sudo apt-get install nginx -y && \
- sudo apt-get install mysql-client -y && \
- sudo apt-get install mytop -y && \
- sudo apt-get install git -y && \
- sudo apt-get install lynx -y && \
- sudo apt-get install autoconf -y && \
- sudo apt-get install htop -y && \
- sudo apt-get install sysstat -y && \
- sudo apt-get install iptraf -y
- ### Create NginX Config files
- sudo echo '## Drop Config
- # Dont record errors regarding missing favicons and robot.txt
- location = /robots.txt {
- access_log off;
- log_not_found off;
- try_files /robots.txt =204;
- }
- location = /favicon.ico {
- access_log off;
- log_not_found off;
- try_files /favicon.ico =204;
- }
- # Refuse to server linux hidden files includes .htaccess etc
- location ~ /\. { access_log off; log_not_found off; deny all; }
- # Dont serve and swap files createed by VIM etc
- location ~ ~$ { access_log off; log_not_found off; deny all; }
- ' > /etc/nginx/drop.conf
- ### Get PHP 5.4.11
- 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
- ## Get PHP Dependancies
- sudo apt-get install \
- libxml2 \
- libxml2-dev \
- libcurl4-openssl-dev \
- libmcrypt-dev \
- libmcrypt4 \
- libxml-libxslt-perl \
- libxslt1-dbg \
- libxslt1-dev -y
- ### Compile PHP
- sudo ./configure \
- --prefix=/usr/local/php \
- --enable-fpm \
- --with-fpm-user=www-data \
- --with-fpm-group=www-data \
- --with-config-file-path=/usr/local/php/php.ini \
- --with-config-file-scan-dir=/usr/local/php/conf.d \
- --enable-debug \
- --with-openssl \
- --with-kerberos \
- --with-zlib \
- --with-curl \
- --with-curlwrappers \
- --enable-exif \
- --with-jpeg-dir=/usr \
- --with-png-dir=/usr \
- --with-vpx-dir=/usr \
- --with-freetype-dir=/usr \
- --enable-exif \
- --with-mhash \
- --enable-mbstring \
- --with-mcrypt \
- --with-mysql \
- --with-mysqli \
- --with-pdo-mysql \
- --enable-shmop \
- --enable-soap \
- --enable-sockets \
- --with-xsl \
- --enable-zip \
- --with-pear
- sudo make && sudo make test
- sudo make install && sudo cp /home/ubuntu/php-5.4.11/php.ini-production /usr/local/php/php.ini
- sudo
- PATH=/usr/local/php/bin:$PATH && pear upgrade-all
- # Update the System PATH
- PATH=/usr/local/php/bin:$PATH
- ### Install APC Cache using PECL
- pecl install apc
- # Create the PHP.ini conf settings for APC in a separate file for ease of administration
- sudo mkdir /usr/local/php/conf.d && sudo echo '[PHP]
- extension=apc.so
- apc.enabled=1
- apc.shm_segments=1
- apc.shm_size=128M
- apc.ttl=7200
- apc.user_ttl=7200
- apc.num_files_hint=1024
- apc.enable_cli=0
- apc.cache_by_default=1
- apc.filters
- apc.mmap_file_mask=/tmp/apc.XXXXXX
- apc.file_update_protection=2' > /usr/local/php/conf.d/apc.conf
- # Set a default timezone
- sudo echo '[PHP]
- date.timezone = Europe/London' > /usr/local/php/conf.d/date.conf
- # PHP CLI Config Settings
- sudo echo '[PHP]
- log_errors = on
- error_log = /var/log/php.log
- ' > /usr/local/php/conf.d/error.ini
- # Restart PHP and NginX
- sudo service php-fpm restart && sudo service nginx restart
- # Create a fresh path to place the test files
- sudo mkdir /www && sudo chown www-data:www-data /www
- ##### Then create a new NginX config within /etc/nginx/sites-enabled using the settings
- server {
- listen 80;
- listen [::]:80 default ipv6only=on;
- server_name example.com;
- root /www/;
- index index.php index.html index.htm;
- # Logs - Enable on REAL deployment
- access_log /var/log/nginx/example.access.log;
- error_log /var/log/nginx/example.error.log;
- location / {
- # First attempt to serve request as file, then
- # as directory, then fall back to index.html
- try_files $uri $uri/ index.php;
- # Uncomment to enable naxsi on this location
- # include /etc/nginx/naxsi.rules
- }
- # This block will catch static file requests, such as images, css, js
- # The ?: prefix is a 'non-capturing' mark, meaning we do not require
- # the pattern to be captured into $1 which should help improve performance
- location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
- # Some basic cache-control for static files to be sent to the browser
- expires max;
- add_header Pragma public;
- add_header Cache-Control "public, must-revalidate, proxy-revalidate";
- }
- # Common configurations
- include drop.conf;
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_buffers 256 4k;
- fastcgi_index index.php;
- include fastcgi_params;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement