Android linux 部署(localhost LAMP 服务器配置)

Android linux deploy (localhost LAMP server configuration)

大家好我的人类同胞!

我有两部 android 手机,每部 运行 使用 "Linux Deploy" 应用程序的 chroot 环境(HTC desire 510 运行 Kali Linux 和 vodafone智能 4 迷你 运行 Ubuntu)。在每台设备上,我都安装了 LAMP 使用:

aptitude install php5 php5-gd php5-cgi php5-mysql mysql-server mysql-client php5-curl lynx php-pear ca-certificates xml-core apache2 libapache2-mod-php5

当我启动 apache2 服务时,服务器说它已经开始使用 ServerName 127.0.0.1。但是,当我执行 nmap -p 80 127.0.0.1 时,端口已关闭。 Netstat 显示没有使用端口 80 的进程,我的手指因整天摆弄 iptables 而流血。在 apache 配置中更改监听端口似乎也不起作用。也许这与 Android 内核中的 iptables 有关?我只是想让这个网络服务器在电话局域网地址的端口 80 上可用。我完全被难住了,任何帮助都将不胜感激!

Linux 部署: https://github.com/meefik/linuxdeploy

apache2.config(ubuntu环境)

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
LockFile ${APACHE_LOCK_DIR}/accept.lock

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
#              graceful restart. ThreadLimit can only be changed by stopping
#              and starting Apache.
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
# It is also possible to omit any default MIME type and let the
# client's browser guess an appropriate action instead. Typically the
# browser will decide based on the file's extension then. In cases
# where no good assumption can be made, letting the default MIME type
# unset is suggested  instead of forcing the browser to accept
# incorrect  metadata.
#
DefaultType None


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:
Include httpd.conf

# Include ports listing
Include ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/
root@localhost:/etc/apache2#

netstat 结果(ubuntu 环境)

root@localhost:/etc/apache2# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0    312 192.168.1.8:ssh         192.168.1.10:58501      ESTABLISHED
tcp6       1      0 192.168.1.8%13923:50042 syd01s18-in-f1.1e:https CLOSE_WAIT
tcp6       1      0 192.168.1.8%13924:45698 syd01s19-in-f9.1e:https CLOSE_WAIT
tcp6       0      0 192.168.1.8%13926:53997 tg-in-f188.1e100.n:5228 ESTABLISHED
tcp6       1      0 192.168.1.8%13928:48576 183.61.112.29:http      CLOSE_WAIT
tcp6       1      0 192.168.1.8%13929:55681 syd01s18-in-f6.1e1:http CLOSE_WAIT
tcp6      24      0 192.168.1.8%13931:36897 ec2-54-241-32-22.:https CLOSE_WAIT
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         STREAM                   776      /dev/socket/rild-mtk-modem
unix  2      [ ]         STREAM                   1545     /dev/socket/adbd
unix  2      [ ]         STREAM                   205      @@king_dserver:1
unix  2      [ ]         STREAM                   1483     @@king_dserver:0
unix  2      [ ]         STREAM                   211      @@king_dserver:2
unix  2      [ ]         DGRAM                    344      @/dev/socket/palinjectsock
unix  2      [ ]         DGRAM                    342      @/dev/socket/palhal
unix  2      [ ]         DGRAM                    3701     /dev/socket/wpa_wlan0
unix  2      [ ]         DGRAM                    343      @/dev/socket/paltimersock
unix  2      [ ]         DGRAM                    341      @palbt_bt30hs
unix  4      [ ]         DGRAM                    4381     /data/misc/wpa_supplicant/wlan0
unix  4      [ ]         DGRAM                    4396     /data/misc/wpa_supplicant/p2p0
unix  2      [ ]         DGRAM                    4386     /data/misc/wifi/sockets/wpa_ctrl_816-2
unix  2      [ ]         DGRAM                    4387     /data/misc/wifi/sockets/wpa_ctrl_816-3
unix  2      [ ]         DGRAM                    4416     /data/misc/wifi/sockets/wpa_ctrl_816-4
unix  2      [ ]         DGRAM                    4417     /data/misc/wifi/sockets/wpa_ctrl_816-5
unix  2      [ ]         STREAM                   168      /dev/socket/atci-serv-fw
unix  2      [ ]         STREAM                   170      /dev/socket/atci-service
unix  2      [ ]         DGRAM                    1464     /dev/socket/soc_vt_svc
unix  2      [ ]         DGRAM                    1466     /dev/socket/soc_vt_stk
unix  2      [ ]         DGRAM                    1468     /dev/socket/soc_vt_tcv
unix  3      [ ]         DGRAM                    348      /data/agps_supl/soc_soc
unix  2      [ ]         DGRAM                    350      /data/agps_supl/soc_supl
unix  2      [ ]         DGRAM                    355      /data/agps_supl/soc_tls
unix  2      [ ]         DGRAM                    351      /data/agps_supl/mnl2supl
unix  2      [ ]         DGRAM                    1966     /data/agps_supl/soc_rrlp
unix  2      [ ]         DGRAM                    353      /data/agps_supl/agps_mgr
unix  2      [ ]         DGRAM                    356      /data/agps_supl/soc_mmi
unix  2      [ ]         DGRAM                    357      /data/agps_supl/soc_gps
unix  2      [ ]         DGRAM                    3537     @bt.app.gap.twin
unix  2      [ ]         DGRAM                    3536     @bt.app.gap
unix  2      [ ]         DGRAM                    1529     /dev/socket/bt.a2dp.stream
unix  3      [ ]         DGRAM                    1531     /dev/socket/bt.int.adp
unix  2      [ ]         STREAM                   1533     /dev/socket/backuprestore
unix  3      [ ]         STREAM     CONNECTED     61257
unix  3      [ ]         STREAM     CONNECTED     61256
unix  3      [ ]         STREAM     CONNECTED     61079
unix  3      [ ]         STREAM     CONNECTED     61078
unix  3      [ ]         STREAM     CONNECTED     61069
unix  3      [ ]         STREAM     CONNECTED     61068
unix  2      [ ]         DGRAM                    59406
unix  3      [ ]         SEQPACKET  CONNECTED     44431
unix  3      [ ]         SEQPACKET  CONNECTED     44430
unix  3      [ ]         STREAM     CONNECTED     45386
unix  3      [ ]         STREAM     CONNECTED     45385
unix  3      [ ]         STREAM     CONNECTED     42809
unix  3      [ ]         STREAM     CONNECTED     42808
unix  3      [ ]         SEQPACKET  CONNECTED     23826
unix  3      [ ]         SEQPACKET  CONNECTED     23825
unix  3      [ ]         SEQPACKET  CONNECTED     22620
unix  3      [ ]         SEQPACKET  CONNECTED     22619
unix  3      [ ]         SEQPACKET  CONNECTED     18542
unix  3      [ ]         SEQPACKET  CONNECTED     18541
unix  2      [ ]         STREAM     CONNECTED     10052    /data/data/com.kingroot.kinguser/cache/.socketgTt170
unix  3      [ ]         SEQPACKET  CONNECTED     6932
unix  3      [ ]         SEQPACKET  CONNECTED     6931
unix  3      [ ]         SEQPACKET  CONNECTED     7543
unix  3      [ ]         SEQPACKET  CONNECTED     7542
unix  3      [ ]         SEQPACKET  CONNECTED     6923
unix  3      [ ]         SEQPACKET  CONNECTED     6922
unix  3      [ ]         SEQPACKET  CONNECTED     6921
unix  3      [ ]         SEQPACKET  CONNECTED     6920
unix  3      [ ]         SEQPACKET  CONNECTED     7389
unix  3      [ ]         SEQPACKET  CONNECTED     7388
unix  3      [ ]         STREAM     CONNECTED     4864     /dev/socket/rild
unix  3      [ ]         STREAM     CONNECTED     5130
unix  3      [ ]         SEQPACKET  CONNECTED     4849
unix  3      [ ]         SEQPACKET  CONNECTED     4848
unix  3      [ ]         SEQPACKET  CONNECTED     4050
unix  3      [ ]         SEQPACKET  CONNECTED     4049
unix  3      [ ]         SEQPACKET  CONNECTED     4726
unix  3      [ ]         SEQPACKET  CONNECTED     4725
unix  2      [ ]         STREAM                   3846
unix  3      [ ]         STREAM     CONNECTED     4524     @com.kingroot.master.ap
unix  3      [ ]         STREAM     CONNECTED     4525
unix  2      [ ]         STREAM     CONNECTED     4522
unix  3      [ ]         STREAM     CONNECTED     4419
unix  3      [ ]         STREAM     CONNECTED     4418
unix  3      [ ]         SEQPACKET  CONNECTED     3726
unix  3      [ ]         SEQPACKET  CONNECTED     3725
unix  3      [ ]         STREAM     CONNECTED     3717
unix  3      [ ]         STREAM     CONNECTED     3716
unix  3      [ ]         STREAM     CONNECTED     4292     /dev/socket/zygote
unix  3      [ ]         STREAM     CONNECTED     3643
unix  3      [ ]         SEQPACKET  CONNECTED     3642
unix  3      [ ]         SEQPACKET  CONNECTED     3641
unix  3      [ ]         SEQPACKET  CONNECTED     3639
unix  3      [ ]         SEQPACKET  CONNECTED     3638
unix  3      [ ]         SEQPACKET  CONNECTED     3633
unix  3      [ ]         SEQPACKET  CONNECTED     3632
unix  3      [ ]         STREAM     CONNECTED     3594     /dev/socket/agpsd
unix  3      [ ]         STREAM     CONNECTED     3593
unix  3      [ ]         STREAM     CONNECTED     4235     /dev/socket/mdns
unix  3      [ ]         STREAM     CONNECTED     4234
unix  3      [ ]         STREAM     CONNECTED     4185     /dev/socket/netd
unix  3      [ ]         STREAM     CONNECTED     4184
unix  3      [ ]         STREAM     CONNECTED     4182     /dev/socket/vold
unix  3      [ ]         STREAM     CONNECTED     4181
unix  3      [ ]         SEQPACKET  CONNECTED     3530
unix  3      [ ]         SEQPACKET  CONNECTED     3529
unix  3      [ ]         SEQPACKET  CONNECTED     3521
unix  3      [ ]         SEQPACKET  CONNECTED     3520
unix  3      [ ]         SEQPACKET  CONNECTED     3115
unix  3      [ ]         SEQPACKET  CONNECTED     3114
unix  3      [ ]         STREAM     CONNECTED     280      /dev/socket/installd
unix  3      [ ]         STREAM     CONNECTED     992
unix  3      [ ]         STREAM     CONNECTED     2223
unix  3      [ ]         STREAM     CONNECTED     2222
unix  3      [ ]         SEQPACKET  CONNECTED     383
unix  3      [ ]         SEQPACKET  CONNECTED     382
unix  2      [ ]         DGRAM                    352
unix  2      [ ]         DGRAM                    349
unix  2      [ ]         DGRAM                    339
unix  3      [ ]         STREAM     CONNECTED     270
unix  3      [ ]         STREAM     CONNECTED     269
unix  3      [ ]         STREAM     CONNECTED     1551
unix  3      [ ]         STREAM     CONNECTED     1550
unix  3      [ ]         STREAM     CONNECTED     1548
unix  3      [ ]         STREAM     CONNECTED     1547
unix  3      [ ]         STREAM     CONNECTED     124
unix  3      [ ]         STREAM     CONNECTED     123

ports.conf(ubuntu环境)

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

我还使用 Linux Deploy 在 Android 平板电脑上安装了 Linux,并且还安装了 LAMP 堆栈,所以我处于类似的位置给你。我使用的 linux 版本是 Debian Wheezy,因此可能与您的具体情况有所不同。

首先(我怀疑这有什么区别)我使用 "apt-get install".

安装

然后我编辑 /etc/apache2/sites-enabled/000-default 以启用本地主机和其他 LAN 客户端连接。

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order deny,allow
    deny from all
    allow from 127.0.0.1 192.168
</Directory>

我很确定就是这样!如果我记得我必须做的任何其他设置步骤,我会进一步贡献。

我们两个设置之间的另一个区别可能是 Android 的版本。我在我的平板电脑上使用的是 运行 CyanogenMod 12.1 (Android v5.1.1),但我不确定这是否是您遇到问题的原因。