If you want to build Nginx + MariaDB in windows, refer to another blog article titled Nginx + MariaDB + PHP in windows using WnMp.
First, Log On As root:
Basic Server Configuration
Set Hostname
- echo “plato” > /etc/hostname
- hostname -F /etc/hostname
Edit/etc/hosts IPv6)
Added:
12.34.56.78 plato.example.com plato
2600: 3c01: a123: b456: c789: d012 plato.example.com plato
Set Time Zone
- dpkg-reconfigure tzdata
Update Server Software
- nano /etc/apt/sources.list
Add the following two lines:
- deb http://packages.dotdeb.org squeeze all
- deb-src http://packages.dotdeb.org squeeze all
-
- wget http://www.dotdeb.org/dotdeb.gpg
- cat dotdeb.gpg | apt-key add -
-
- apt-get update
- apt-get upgrade –show-upgraded
Configure security attributes
Add a system administrator
- adduser example_user
- usermod -a -G sudo example_user
- logout
- ssh example_user@123.456.78.90
Now, you can use the new user and sudo to execute the Administrator command.
Reverse-activate root SSH Logon
- sudo nano /etc/ssh/sshd_config
Update this line: PermitRootLogin no
Sudo service ssh restart
Set firewall:
- sudo iptables -L
- sudo nano /etc/iptables.firewall.rules
Copy:
- *filter
-
- # Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn’t use lo0
- -A INPUT -i lo -j ACCEPT
- -A INPUT -d 127.0.0.0/8 -j REJECT
-
- # Accept all established inbound connections
- -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-
- # Allow all outbound traffic – you can modify this to only allow certain traffic
- -A OUTPUT -j ACCEPT
-
- # Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
- -A INPUT -p tcp –dport 80 -j ACCEPT
- -A INPUT -p tcp –dport 443 -j ACCEPT
-
- # Allow SSH connections
- #
- # The -dport number should be the same port number you set in sshd_config
- #
- -A INPUT -p tcp -m state –state NEW –dport 22 -j ACCEPT
-
- # Allow ping
- -A INPUT -p icmp -j ACCEPT
-
- # Log iptables denied calls
- -A INPUT -m limit –limit 5/min -j LOG –log-prefix “iptables denied: ” –log-level 7
-
- # Drop all other inbound – default deny unless explicitly allowed policy
- -A INPUT -j DROP
- -A FORWARD -j DROP
-
- COMMIT
-
- sudo iptables-restore
Automatically load the firewall after each restart:
- sudo nano /etc/network/if-pre-up.d/firewall
- #!/bin/sh
- /sbin/iptables-restore
- sudo chmod +x /etc/network/if-pre-up.d/firewall
Install Fail2Ban to automatically detect and prevent attacks:
- sudo aptitude install fail2ban
Install PHP-FPM
- sudo aptitude install php5 php5-cli php5-dev php5-gd php-pear php5-fpm php5-geoip libgeoip1 libgeoip-dev geoip-database
Update some configurations:
- sudo nano /etc/php5/fpm/php.ini
- memory_limit: 512M
- cgi.fix_pathinfo=0
Install Nginx
- sudo aptitude install nginx
Configure a VM
- sudo mkdir -p /srv/www/insready.com/{public_html,logs}
- sudo chown -R www-data:www-data /srv/www
- sudo chmod -R 775 /srv/www
- cd /etc/nginx/sites-available/
- sudo wget https://gist.github.com/raw/4248423/c7b2ea550ef9273f7f5d0823f81f054296fc…
You need to modify the above domain name configuration sudo nano insready.com
Sudo nano/etc/php5/fpm/pool. d/www. conf
Change listen = 127.0.0.1: 9000:
- listen = /tmp/php-fpm.sock
- sudo ln -s /etc/nginx/sites-available/insready.com /etc/nginx/sites-enabled
Configure Nginx Microcache (and put the Microcache in the memory to experience the lightning speed !)
- Sudo nano/etc/nginx/conf. d/microcache. conf
- Fastcgi_cache_path/dev/shm/microcache levels = keys_zone = microcache: 5 M max_size = 1G inactive = 2 h; # Set the nicnx Microcache in the memory, which is faster!
- Map $ http_cookie $ cache_uid {
- Default nil; # hommage to Lisp :)
- ~ SESS [[: alnum:] + = (? <Session_id> [[: alnum:] +) $ session_id;
- }
-
- Map $ request_method $ no_cache {
- Default 1;
- HEAD 0;
- GET 0;
- }
Now enable Nginx to run automatically every time it is started.
- sudo update-rc.d nginx defaults
Start Nginx
- sudo /etc/init.d/nginx start
Install MariaDB
To put it bluntly, MariaDB is a new open-source database that was created after Oracle bought MySQL. MariaDB is used in the same way as MySQL.
- sudo nano /etc/apt/sources.list.d/MariaDB.list
-
- # MariaDB 5.5 repository list – created 2012-12-08 07:39 UTC
- # http://downloads.mariadb.org/mariadb/repositories/
- deb http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/5.5/debian squeeze main
- deb-src http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/5.5/debian squeeze main
-
- sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
-
- sudo aptitude update
- sudo aptitude install libmariadbclient-dev libmariadbclient18 libmariadbd-dev
- libmysqlclient18 mariadb-client mariadb-client-5.5 mariadb-client-core-5.5
- mariadb-common mariadb-server mariadb-server-5.5 mariadb-server-core-5.5 mariadb-test mariadb-test-5.5 mysql-common
Install the latest version of Drupal
- cd /srv/www/insready.com
- sudo wget http://ftp.drupal.org/files/projects/drupal-7.18.tar.gz
- sudo tar -xvzf drupal-7.18.tar.gz
- cd drupal-7.18
- sudo cp -a . ../public_html/
- sudo chown www-data:www-data public_html -R
Install Memcache and APC
- sudo aptitude install memcached libmemcached-tools memstat make
- sudo pecl install memcache
- sudo pecl install apc
Create the following file to configure Memcache
- sudo nano /etc/php5/conf.d/memcache.ini
- extension= memcache.so
- memcache.hash_strategy=”consistent”
Create the following files and configure apc
- sudo nano /etc/php5/conf.d/apc.ini
- extension=apc.so
- apc.shm_size = 256M
- apc.apc.stat = 0
Install uploadprogress
- sudo pecl install uploadprogress
Create the following file and configure uploadprogress
- sudo nano /etc/php5/conf.d/uploadprogress.ini
- extension=uploadprogress.so
Restart:
- sudo service nginx restart
- sudo service mysql restart
- sudo service php5-fpm restart
- sudo service memcached restart
Done!
Edit recommendations]
- MariaDB 5.3 will support the alter table progress prompt
- The founder of MySQL builds MariaDB fully compatible with MySQL 5.1.
- MariaDB 2 anniversary
- How to optimize your MongoDB in five steps
- Install MariaDB in Windows