[Linux] Web Service環境安裝建置 by LNMP – Ubuntu 14.04

Server Environment Installation

  • Version: 1.2.0
  • Environment: Ubuntu 14.04 LTS

Set server time zone data

$ dpkg-reconfigure tzdata

Set crontab with updating date

$ ntpdate time.stdtime.gov.tw

Add user

$ adduser nick
$ visudo 
    > nick_tsai ALL=(ALL) NOPASSWD:ALL

// Change deault editor if needed
$ update-alternatives --config editor  

// SSH password login: $ vi /etc/ssh/sshd_config
PasswordAuthentication yes
$ service ssh restart

Install webserver using nginx

$ apt-get install nginx

Configuration:

/etc/nginx/nginx.conf
  > client_max_body_size 128M;    
  > worker_processes 2; (if instance core is 2)

Install php-fpm with extensions

$ apt-get install php5-fpm php5-mysql php5-cli php5-mcrypt php5-curl php5-imagick php5-gd
$ apt-get install php5-memcached memcached 
$ php5enmod mcrypt

Configuration

   /etc/php5/fpm/php.ini 
      > cgi.fix_pathinfo = 0
      > mbstring.internal_encoding = UTF-8 (uncomment)
      > max_input_vars = 5000

   /etc/php5/fpm/pool.d/www.conf
       > pm.max_children = 100
       > pm.start_servers = 10
       > pm.min_spare_servers = 5
       > pm.max_spare_servers = 15

Install MySQL (As DB server)

$ apt-get install mariadb-server

Configuration

    > set datadir = /home/mysql/data
    > set default-time-zone = ‘+8:00’

Add a Storage to this instance

$ mkfs -t ext4 device_name

// Backup /home data before mounting then recover it
$ mount /dev/svdf /home

# Addition Installation

Install graph handler imagemagic libaray

$ apt-get install imagemagick

convert for anyone and it’s orginal path is /etc/alternatives/convert

Install Fail2ban

$ apt-get install fail2ban

Leave a Reply

Your email address will not be published. Required fields are marked *