Atitit. 查找linux 项目源码位置

Atitit. 查找linux 项目源码位置

 

1. 查找占用80端口进程pid 。。。netstat   -anp |grep 801

1.1. 列出进程启动位置     ls -l /proc/112682

1.2. 1.3 启动关闭nginx3

1.3. 找到nginx配置文件4

1.4. ./etc/nginx/nginx.conf4

1.5. etc/nginx/conf.d/eform.conf;5

2. Nginxphp安装原理6

2.1. /$ find . -name 'php.ini'7

2.2. 寻找apache配置文件路径7

 

1. 查找占用80端口进程pid 。。。netstat   -anp |grep 80 

 

 

/etc$  netstat   -anp |grep 80

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      11268/nginx: master

tcp        0      0 101.200.12.187:80       175.4.154.150:51114     ESTABLISHED 11270/nginx: worker

tcp        0      0 101.200.12.187:80       175.4.154.150:51120     ESTABLISHED 11270/nginx: worker

tcp        0      0 101.200.12.187:80       175.4.154.150:51119     ESTABLISHED 11270/nginx: worker

tcp        0      0 101.200.12.187:80       175.4.154.150:51117     ESTABLISHED 11270/nginx: worker

tcp        0      0 101.200.12.187:50402    140.205.140.205:80      ESTABLISHED 30075/AliYunDun     

tcp        0      0 101.200.12.187:80       175.4.154.150:51116     ESTABLISHED 11270/nginx: worker

tcp        0      0 101.200.12.187:80       175.4.154.150:51118     ESTABLISHED 11270/nginx: worker

unix  3      [ ]         DGRAM                    9980     366/systemd-udevd    

unix  2      [ ]         DGRAM                    9806     1/systemd   

 

 

linux下使用top命令可以查看进程,但是单从文件名无法定位到进程的位置。

有如下两种方法:

(1)获取进程的pid,然后使用命令ls -l /proc/${pid},这个命令可以列出该进程的启动位置。

作者::  ★(attilax)>>>   绰号:老哇的爪子  全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊  汉字名:艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

ls -l /proc/11268

2/usr/sbin/lsof | grep ${进程名称} 这个命令也能列出进程的启动位置。

1.1. 列出进程启动位置     ls -l /proc/11268    

到/proc/4431下,ls -l 会看到(需要root权限)

这样就知道是哪种webserver了。。

 

 

/etc$ ls -l /proc/11268

total 0

dr-xr-xr-x 2 root root 0 Apr 29 23:36 attr

-rw-r--r-- 1 root root 0 Apr 29 23:44 autogroup

-r-------- 1 root root 0 Apr 29 23:44 auxv

-r--r--r-- 1 root root 0 Apr 29 23:44 cgroup

--w------- 1 root root 0 Apr 29 23:44 clear_refs

-r--r--r-- 1 root root 0 Apr 28 16:08 cmdline

-rw-r--r-- 1 root root 0 Apr 29 23:44 comm

-rw-r--r-- 1 root root 0 Apr 29 23:44 coredump_filter

-r--r--r-- 1 root root 0 Apr 29 23:44 cpuset

lrwxrwxrwx 1 root root 0 Apr 29 23:44 cwd -> /

-r-------- 1 root root 0 Apr 29 23:44 environ

lrwxrwxrwx 1 root root 0 Apr 28 15:30 exe -> /usr/sbin/nginx

dr-x------ 2 root root 0 Apr 29 23:36 fd

dr-x------ 2 root root 0 Apr 29 23:44 fdinfo

-rw-r--r-- 1 root root 0 Apr 29 23:44 gid_map

-r-------- 1 root root 0 Apr 29 23:44 io

-r--r--r-- 1 root root 0 Apr 29 23:44 limits

-rw-r--r-- 1 root root 0 Apr 29 23:44 loginuid

-r--r--r-- 1 root root 0 Apr 29 23:44 maps

-rw------- 1 root root 0 Apr 29 23:44 mem

-r--r--r-- 1 root root 0 Apr 29 23:44 mountinfo

-r--r--r-- 1 root root 0 Apr 29 23:44 mounts

-r-------- 1 root root 0 Apr 29 23:44 mountstats

dr-xr-xr-x 5 root root 0 Apr 29 23:44 net

dr-x--x--x 2 root root 0 Apr 29 23:44 ns

-r--r--r-- 1 root root 0 Apr 29 23:44 numa_maps

-rw-r--r-- 1 root root 0 Apr 29 23:44 oom_adj

-r--r--r-- 1 root root 0 Apr 29 23:44 oom_score

-rw-r--r-- 1 root root 0 Apr 29 23:44 oom_score_adj

-r--r--r-- 1 root root 0 Apr 29 23:44 pagemap

-r--r--r-- 1 root root 0 Apr 29 23:44 personality

-rw-r--r-- 1 root root 0 Apr 29 23:44 projid_map

lrwxrwxrwx 1 root root 0 Apr 29 23:44 root -> /

-rw-r--r-- 1 root root 0 Apr 29 23:44 sched

-r--r--r-- 1 root root 0 Apr 29 23:44 sessionid

-r--r--r-- 1 root root 0 Apr 29 23:44 smaps

-r--r--r-- 1 root root 0 Apr 29 23:44 stack

-r--r--r-- 1 root root 0 Apr 28 15:12 stat

-r--r--r-- 1 root root 0 Apr 29 23:44 statm

-r--r--r-- 1 root root 0 Apr 28 16:08 status

-r--r--r-- 1 root root 0 Apr 29 23:44 syscall

dr-xr-xr-x 3 root root 0 Apr 29 23:44 task

-rw-r--r-- 1 root root 0 Apr 29 23:44 uid_map

-r--r--r-- 1 root root 0 Apr 29 23:44 wchan

 

 

 

 

 

1.2. 1.3 启动关闭nginx

全选复制放进笔记

## 检查配置文件是否正确# /usr/local/nginx-1.6/sbin/nginx -t # ./sbin/nginx -V     # 可以看到编译选项

## 启动、关闭# ./sbin/nginx        # 默认配置文件 conf/nginx.conf,-c 指定# ./sbin/nginx -s stop

或 pkill nginx

## 重启,不会改变启动时指定的配置文件# ./sbin/nginx -s reload

kill -HUP `cat /usr/local/nginx-1.6/logs/nginx.pid`

当然也可以将 nginx 作为系统服务管理,下载 nginx 到/etc/init.d/,修改里面的路径然后赋予可执行权限。

# service nginx {start|stop|status|restart|reload|configtest}

 

1.3. 找到nginx配置文件

网上说路径在这里,没有找到,使用搜索命令find找到。。

8.修改配置文件

cd /usr/local/nginx/conf

vi nginx.conf

 

 

/usr/local$ cd /

/$  find . -name 'nginx.conf'

./etc/nginx/nginx.conf

 

 find . -name 'fcgi.conf'

 

1.4. ./etc/nginx/nginx.conf

 

http {

    include       mime.types;

    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    server_names_hash_bucket_size 128;

    client_header_buffer_size 32k;

    large_client_header_buffers 4 32k;

    client_max_body_size 300m;

    sendfile        on;

    tcp_nopush     on;

    fastcgi_connect_timeout 300;

    fastcgi_send_timeout 300;

    fastcgi_read_timeout 300;

    fastcgi_buffer_size 64k;

    fastcgi_buffers 4 64k;

    fastcgi_busy_buffers_size 128k;

    fastcgi_temp_file_write_size 128k;

    keepalive_timeout  60;

    tcp_nodelay on;

    server_tokens off;

    gzip  on;

    gzip_min_length  1k;

    gzip_buffers     4 16k;

    gzip_http_version 1.1;

    gzip_comp_level 2;

    gzip_types       text/plain application/x-javascript text/css application/xml;

    gzip_vary on;

 

    include /etc/nginx/conf.d/*.conf;

}

 

1.5. etc/nginx/conf.d/eform.conf;

 

 

 

server {

    listen 80;

    server_name  qinbd.com www.qinbd.com;

    root /mnt/www/eform/public;

    index index.php index.html index.htm;

 

    charset utf-8;

 

    location / {

        #laravel加入

        try_files $uri $uri/ /index.php?$query_string;

    }

 

    location = /robots.txt { allow all; access_log off; log_not_found off; }

    location = /favicon.ico { allow all; access_log off; log_not_found off; }

 

    error_page 401 /401.html;

    error_page 403 /403.html;

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;

 

    location ~ \.php$ {

        root           /mnt/www/eform/public;

        #sock开启

        fastcgi_pass    unix:/var/run/php5-fpm.sock;

        #TCP开启

        #fastcgi_pass   127.0.0.1:9000;

        fastcgi_index   index.php;

        #写入上一步自己创建fast-cgi的配置文件路径

        include         fcgi.conf;

        include         fastcgi_params;

    }

 

    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    location ~ /\.ht {

        #deny  all;

    }

}

 

 

/$  find . -name 'fcgi.conf'

./etc/nginx/fcgi.conf

 

find . -name “php.ini

 

2. Nginxphp安装原理

针对Nginxphp安装和针对apachephp安装是有区别的,因为Nginx中的php是以fastcgi的方式结合nginx的,可以理解为nginx代理了phpfastcgi,而apache是把php作为自己的模块来调用

 

 

/etc/nginx$ netstat   -anp  |grep php

unix  2      [ ACC ]     STREAM     LISTENING     14495    1068/php-fpm: maste  /var/run/php5-fpm.sock

unix  3      [ ]         STREAM     CONNECTED     14493    1068/php-fpm: maste  

unix  3      [ ]         STREAM     CONNECTED     14494    1068/php-fpm: maste  

 

 

2.1. /$ find . -name 'php.ini'

./etc/php.ini

 

 

 

du -sh   /mnt/www/eform/public

/$ du -sh   /mnt/www/eform/public

3.4G/mnt/www/eform/public

/$ du -sh   /mnt/www/eform/

3.6G/mnt/www/eform/

/$ du -sh   /mnt/www/

3.6G/mnt/www/

 

 

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

 

2.2. 寻找apache配置文件路径

root@iZ94mqp30dmZ:~# cd /

root@iZ94mqp30dmZ:/# find -name 'httpd.conf'

./root/sh-1.5.0-Ubuntu-14.04/apache/config-httpd/config-httpd-2.2.22/httpd.conf

./root/sh-1.5.0-Ubuntu-14.04/httpd-2.2.29/docs/conf/httpd.conf

./alidata/server/httpd-5/conf/original/httpd.conf

./alidata/server/httpd-5/conf/httpd.conf

./alidata/server/httpd-2/conf/original/httpd.conf

./alidata/server/httpd-2/conf/httpd.conf

./alidata/server/httpd-4/conf/original/httpd.conf

./alidata/server/httpd-4/conf/httpd.conf

./alidata/server/httpd-6/conf/original/httpd.conf

./alidata/server/httpd-6/conf/httpd.conf

./alidata/server/httpd-3/conf/original/httpd.conf

./alidata/server/httpd-3/conf/httpd.conf

 

 

 01:50 exe -> /alidata/server/httpd-4/bin/httpd

 

得到apache的运行版本,然后确认配置文件是在。。可以修改测测。。

./root/sh-1.5.0-Ubuntu-14.04/apache/config-httpd/config-httpd-2.2.22/httpd.conf

 

posted @ 2016-05-01 23:44  attilaxAti  阅读(298)  评论(0编辑  收藏  举报