当前位置: 首页 > 工具软件 > tinyscript > 使用案例 >

tiny core linux ngnix,TinyCore Nginx server with php-cgi and vsftpd

赫连法
2023-12-01

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

sudocp/usr/local/nginx.conf.default/usr/local/etc/nginx.conf

Copy mime.types to /usr/local/etc

1

sudocp/usr/local/mime.types/usr/local/etc/mime.types

Copy fastcgi_params to /usr/local/etc

1

sudocp/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

sudoln-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$(pidofnginx)

ifpidofphp-cgi>/dev/null;then

echo-n"Stopping php-cgi"

kill$(pidofphp-cgi)

fi

}

restart(){

ifpidofnginx>/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{

listen80;

server_namelocalhost;

#charset

koi8-r;

#access_log  logs/host.access.log  main;

location/{

roothtml;

indexindex.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_pass127.0.0.1:9000;

fastcgi_indexindex.php;

fastcgi_paramSCRIPT_FILENAME/usr/local/html$fastcgi_script_name;

includefastcgi_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

sudovi/usr/local/html/index.php

1

2

3

4

5

6

7

8

9

$myvar="Tiny

Core simple server test";

?>

TinyCoreserver

<?phpecho $myvar;?>

#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

sudovi/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

sudovi/opt/bootlocal.sh

1

2

3

4

5

#!/bin/sh

# put other system startup commands here

/usr/local/etc/init.d/opensshstart

/usr/local/etc/init.d/nginxstart

/usr/local/sbin/vsftpd

Add auto bakup before server shutdown in /opt/shutdown.sh

1

sudovi/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

sudofiletool.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

lynxhttp://192.168.0.10

-dump

TinyCoresimpleservertest

FTP server test:

Shell

1

2

3

4

5

6

7

8

9

ftptc@192.168.0.10

Connectedto192.168.0.10.

220(vsFTPd2.3.5)

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>

原文:http://www.cnblogs.com/meetrice/p/3680361.html

 类似资料:

相关阅读

相关文章

相关问答