TinyCore Nginx server with php-cgi and vsftpd
http://blog.matchgenius.com/tinycore-nginx-server-with-php-cgi-and-vsftpd/
Create fast testing server with TinyCore. I will be using Microcore (8MB) that resides in RAM and 500MB disk drive for persistence. TinyCore Nginx server with php-cgi and vsftpd can be used for for various testing purposes. My setup will be using another box for mysql. Assuming that you have TinyCore Microcore already installed on hard drive lets proceed to installing nginx. My Tiny Core is already installed and I can ssh to it from local machine.
#1: Install Nginx server
From terminal access application browser and search for nginx.
|
1
|
tce-ab
|
Select nginx.tcz and install. Press 2 then q and i to install. Along with Nginx other dependencies will be downloaded automatically: readline.tcz and pcre.tcz.
#2: Install php5
While you still inside application browser press s to search and type php5. Select php5.tcz and install. Installation will take a little longer because there are a lot more dependencies.
#3: Install vsftpd
Repeat the same installation process for vsftpd. s type vsftpd. Select vsftpd.tcz or if you want to use ssl version vsftpd-ssl.tcz and install.
#4: Copy configuration files
Copy default nginx.conf file to /usr/local/etc and edit it.
|
1
|
sudo cp/usr/local/nginx.conf.default/usr/local/etc/nginx.conf
|
Copy mime.types to /usr/local/etc
|
1
|
sudo cp/usr/local/mime.types/usr/local/etc/mime.types
|
Copy fastcgi_params to /usr/local/etc
|
1
|
sudo cp/usr/local/fastcgi_params/usr/local/etc/fastcgi_params
|
Create symbolic link to libodbc.so.1 (In my case php-cgi fails to load without it)
|
1
|
sudo ln-s/usr/local/lib/libodbc.so/usr/local/lib/libodbc.so.1
|
Create nginx php-cgi startup script in /usr/local/etc/init.d/nginx . I modified my OpenSSH startup script like that:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/sh
# nginx php-cgi start script
[$(id-u)=0]||{echo"must be root";exit1;}
start(){
[-f/usr/local/etc/nginx.conf]||{echo"Config file /usr/local/etc/nginx.conf not found";exit1;}
# Load nginx server
echo-n"Starting nginx php-cgi"
/usr/local/sbin/nginx-c/usr/local/etc/nginx.conf
# Load php-cgi server
/usr/local/bin/php-cgi-b127.0.0.1:9000&
}
stop(){
echo"Stopping nginx"
kill$(pidof nginx)
ifpidof php-cgi>/dev/null;then
echo-n"Stopping php-cgi"
kill$(pidof php-cgi)
fi
}
restart(){
ifpidof nginx>/dev/null;then
stop&&start
else
start
fi
}
case$1in
start)start;;
stop)stop;;
restart)restart;;
*)echo"Usage $0 {start|stop|restart}";exit1
esac
|
#5: Edit nginx.conf
Edit /usr/local/etc/nginx.conf and make changes inside http{ server{ location / index index.php
|
1
2
3
4
5
6
7
8
9
10
11
12
|
server{
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location/{
root html;
index index.htmlindex.htmindex.php;
}
|
On the bottom of the same file uncomment whats under pass the PHP scripts to FastCGI
|
1
2
3
4
5
6
7
8
9
|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location~\.php${
root /usr/local/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/html$fastcgi_script_name;
include fastcgi_params;
}
|
#6: Edit vsftpd.conf
Configure /usr/local/etc/vsftpd.conf file. You can tweak it as you like and add more things but I will keep it basic for now. Make sure this settings are present.
|
1
2
3
4
5
|
anonymous_enabled=NO
local_enable=YES
local_umask=002
connect_from_port_20=YES
local_root=/usr/local/html
|
#7: Create test index.php
Just so you can test your server lets create simple page to test if php is working.
|
1
|
sudo vi/usr/local/html/index.php
|
|
1
2
3
4
5
6
7
8
9
|
<?php
$myvar="Tiny Core simple server test";
?>
<html>
<head><title>TinyCoreserver</title></head>
<body>
<h2><center><?phpecho$myvar;?></center></h2>
</body>
</html>
|
#8: Tiny Core persistence save
All configuration will be lost if we reboot the server so lets make it persistent.
Edit /opt/.filetool.lst
|
1
|
sudo vi/opt/.filetool.lst
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
opt
home
/etc/hostname
/etc/passwd
/etc/shadow
/usr/local/etc/ssh
/usr/local/etc/nginx.conf
/usr/local/etc/mime.types
/usr/local/html/
/usr/local/etc/init.d/nginx
/usr/local/etc/fastcgi_params
/usr/local/lib/libodbc.so.1
/usr/local/etc/vsftpd.conf
|
Edit /opt/bootlocal.sh
|
1
|
sudo vi/opt/bootlocal.sh
|
|
1
2
3
4
5
|
#!/bin/sh
# put other system startup commands here
/usr/local/etc/init.d/openssh start
/usr/local/etc/init.d/nginx start
/usr/local/sbin/vsftpd
|
Add auto bakup before server shutdown in /opt/shutdown.sh
|
1
|
sudo vi/opt/shutdown.sh
|
|
1
2
3
4
5
|
#!/bin/sh
# put user shutdown commands here
/usr/bin/filetool.sh-b
...
|
Save your files to backup
|
1
|
sudo filetool.sh-b
|
Now you should be ready for reboot and test.
#9: TinyCore Nginx server test connect from outside
In my setup before I can connect to my TinyCore I have to add NAT in my firewall. Depending on your situation you may have to do it as well. Make sure nothing is blocking your connection. Because Im connecting through middle server that is OpenBSD im going to add NAT in my pf.conf file. Im going to open port 80 for Nginx and 20 and 21 for vsftpd.
|
1
2
3
4
5
|
$external_nic="re0"
$mylaptop="192.168.0.2"
$tinycore_server="10.10.0.2"
passinon$external_nicprototcpfrom$mylaptoptoanyport80rdr-to$tinycore_server
passinon$external_nicprototcpfrom$mylaptoptoanyport{20,21}rdr-to$tinycore_server
|
Web server test:
|
1
2
|
lynx http://192.168.0.10 -dump
Tiny Core simple server test
|
FTP server test:
Shell
|
1
2
3
4
5
6
7
8
9
|
ftp tc@192.168.0.10
Connected to192.168.0.10.
220(vsFTPd2.3.5)
331Please specify the password.
Password:
230Login successful.
Remote system typeisUNIX.
Using binary mode totransfer files.
ftp>
|
TinyCore Nginx server with php-cgi and vsftpd的更多相关文章
- 配置 nginx server 出现nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7
在配置nginx 虚拟机时,执行 sudo /usr/sbin/nginx -t 报下面的错误: nginx: [emerg] nginx: configuration file /etc/nginx ...
- 用Keepalived搭建双Nginx server集群,防止单点故障
综述: 浏览器访问虚拟IP: 192.168.1.57, 该虚拟IP被Keepalived接管,两个Keepalived进程分别运行在物理IP为192.168.1.56和192.168.1.59服务器 ...
- nginx server
配置nginx 首先apt install nginx 然后安装php apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-mbs ...
- nginx server中的server_name配置的域名在客户机上无法访问
nginx配置如下: nginx.conf: #user nobody; worker_processes 2; #error_log logs/error.log; #error_log logs/ ...
- How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu
sudo apt-get update sudo apt-get install nginxsudo mkdir -p /var/www/example.com/html sudo chown -R ...
- NGINX server配置中if的用法
server的配置以php为例,如下: 1 server{ 2 root /var/webproject/www/mytools-php; 3 index index.html index.php; ...
- Nginx server之Nginx添加ssl支持
//环境介绍 1.nginx服务器:10.10.54.157 2.配置nginx服务器,当监听到来自客户端www.zijian.com:80请求时,转到10.10.54.150:1500这个web服务 ...
- nginx Server names
通配符名称 正則表達式名称 混合名称 优化 兼容性 server名称定义使用的server_name指令和决定哪个server块用于一个给定的请求. 參见"怎样Nginx处理一个请求&quo ...
- Failed to Stop or Restart Nginx Server Through Serevice Command(nginx进程不能停止重启)
Many people are accustomed to start a Nginx web server through init scripts and then they can contro ...
随机推荐
- Docker 传奇之 dotCloud
2010年,几个大胡子年轻人在旧金山成立了一家做 PaaS 平台的公司,起名为「dotCloud」,这个名字让我想起了微软的「DotNet」. dotCloud 主要是基于 PaaS 平台为开发者或开 ...
- javascript:addEventListener
addEventListener 用于注册事件处理程序,IE 中为 attachEvent,我们为什么讲 addEventListener 而不讲 attachEvent 呢?一来 attachEve ...
- Java异常---获取异常的堆栈信息
Java 实例 - 获取异常的堆栈信息 Java 实例 以下实例演示了使用异常类的 printStack() 方法来获取堆栈信息: Main.java 文件 public class Main{ p ...
- Linux init 0-6 启动级别
原文地址:http://blog.sina.com.cn/s/blog_5f8e8d9801010wlr.html 原文地址:[转]Linux init 0-6 启动级别作者:流水清风 init 0- ...
- Xcode 5.1.1 与 Xcode 6.0.1 的共存之路(建议大家在升级Xcode 6.0.1 的时候保留Xcode 5.1.1)
最近升级了Xcode 6.0.1 与原有项目有不少冲突.建议大家谨慎升级,同时做好备份.二者共存推荐如下帖子. http://jingyan.baidu.com/article/1612d500457 ...
- unity,荧光效果(bloom)实现过程
两个月前,刚接触unity的时候费了半天劲儿做了个荧光效果(见:http://www.cnblogs.com/wantnon/p/4430749.html),今天终于抽空整理了一下,把过程写下来. 荧 ...
- SharePoint Online 创建和使用视图
前言 本文介绍如何在Office 365中创建和使用视图. 正文 首先,解释一下什么是SharePoint站点视图,所谓视图,就是列表的一个呈现形式,包含特定的栏.排序.筛选.分组等特性,我们通常创建 ...
- SEO如何利用百度知道日引流上千IP
个人小站长.SEO们经常为网站没有流量而发愁,一个没有流量的网站就像一个不喝水的人,迟早得死.没有流量,就没有PV,也就是说你的网站只是 给你一个人看的,那做站有什么意义呢?网站上所发布的内容都是分享 ...
- http链接的性能测试工具httping
安装:MAC环境下使用brew进行安装 brew install httping 使用参数: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 ...
- 利用Visual Studio 2013 开发微软云Windows Azure配置指南(针对中国大陆)
微软云在中国是由“世纪互联”营运的,所以如果你用Visual Stuido 2003全通通用账户开发微软云,会有问题,这是他的不方便支持.好处是,因为是在大陆营运,所以速度比较快. (1)打开官网 h ...