设为首页 收藏本站
查看: 805|回复: 0

lanmp 环境搭建

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-30 08:24:28 | 显示全部楼层 |阅读模式
软件分享:链接:http://pan.baidu.com/s/1dEbn229 密码:91xm 一,安装Apache
    1,mini Linux安装必要包

1
2
3
    yum -y grouplist
    yum -y groupinstall 'Development tools,Desktop Platform Development'
    yum -y groupinstall '开发工具,桌面平台开发'




    2,安装apr-1.5.0
1
2
3
4
    # tar xf apr-1.5.0.tar.gz
    # cd apr-1.5.0
    # ./configure --prefix=/usr/local/apr
    # make && make install



    3,安装apr-util-1.5.3
1
2
3
4
    # tar xf apr-util-1.5.3.tar.bz2
    # cd apr-util-1.5.3
    # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    # make && make install



    4,安装pcre
1
2
3
4
  unzip pcre-8.32.zip
  cd pcre-8.32
  ./configure --prefix=/usr/local/pcre
  make && make install



    5,安装Apache

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
5.1 出现openssl错误:
yum -y install openssl-devel

tar xf httpd-2.4.10.tar.gz
cd httpd-2.4.10
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre=/usr/local/pcre/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event

5.2 make && make install
编辑/etc/httpd24/httpd.conf,添加如下行即可:shift+g定位到行尾
PidFile  "/var/run/httpd.pid"

5.3 编辑一个/etc/rc.d/init.d/httpd
-------------------------------------
#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \\
#        HTML files and CGI.
# processname: httpd
# config: /etc/httpd24/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
  echo -n $"Stopping $prog: "
  killproc -p ${pidfile} -d 10 $httpd
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
        RETVAL=$?
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  status)
        status -p ${pidfile} $httpd
  RETVAL=$?
  ;;
  restart)
  stop
  start
  ;;
  condrestart)
  if [ -f ${pidfile} ] ; then
    stop
    start
  fi
  ;;
  reload)
        reload
  ;;
  graceful|help|configtest|fullstatus)
  $apachectl $@
  RETVAL=$?
  ;;
  *)
  echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  exit 1
esac

exit $RETVAL
-----------------------------------------------
5.4 添加脚本的执行权限
chmod +x /etc/rc.d/init.d/httpd
service httpd start | stop



二,安装nginx
6,安装zlib
1
2
3
4
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make && make install



7,安装openssl
1
2
3
tar zxvf openssl-1.0.2-latest.tar.gz
tar zxvf nginx-1.7.12.tar.gz
cp -R openssl-1.0.2a/ /usr/local/src/nginx-1.7.12



8,安装nginx
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
groupadd www
whereis nologin
useradd -g www -s /sbin/nologin www
mkdir /usr/local/nginx/
cd nginx-1.7.12
./configure --prefix=/usr/local/nginx --user=www --group=www --sbin-path=/usr/local/nginx/sbin --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --error-log-path=/usr/local/nginx/nginx-error.log  --with-http_ssl_module --with-pcre=/soft/lamp_linux/pcre-8.32 --with-zlib=/soft/lamp_linux/zlib-1.2.8 --with-openssl=/soft/lamp_linux/openssl-1.0.2e
make && make install
mkdir /usr/local/nginx/access 保持日志
mkdir /usr/local/nginx/vhost 保持虚拟配置文件
vi /etc/rc.d/init.d/nginx
启动脚本:
----------------------------------
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin
nginx_config=/usr/local/nginx/nginx.conf
nginx_pid=/usr/local/nginx/nginx.pid
RETVAL=0
prog="nginx"

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0

# Start nginx daemons functions.
start() {
    if [ -e $nginx_pid ] ;then
        echo "nginx already running...."
        exit 1
    fi
    echo -n $"Starting $prog: "
    daemon $nginxd -c ${nginx_config}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

    return $RETVAL
}

# Stop nginx daemons functions.
stop() {
    echo -n $"Stopping $prog: "
    killproc $nginxd
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginx_pid
}

reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    reload)
        reload
        ;;
    restart)
        stop
        start
        ;;
    status)
        status $prog
        RETVAL=$?
        ;;
    *)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1
esac

exit $RETVAL
--------------------------------------
授权:
chmod 755 /etc/rc.d/init.d/nginx
chkconfig nginx on
service nginx restart



三,安装MySQL
    9,安装MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
tar zxvf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz  -C /usr/local/
cd /usr/local/
ln -sv mysql-5.6.15-linux-glibc2.5-x86_64/ mysql
groupadd -r mysql
useradd -g mysql -r -s /sbin/nologin  -M -d /usr/local/mysql/data mysql
chown  -R mysql:mysql .
cd mysql
cp support-files/my-default.cnf  /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
yum -y install libaio-devel
scripts/mysql_install_db --user=mysql
service mysqld start
./bin/mysqladmin -u root password 'hadoop123'
./bin/mysql -u root -p



四,安装php
    10,安装bzip2
1
yum -y install bzip2-devel



       11,安装libmcrypt
1
2
3
4
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make && make install



    12,安装libiconv
1
2
3
4
  tar xf libiconv-1.14.tar.gz
  cd libiconv-1.14
  ./configure --prefix=/usr/local/libiconv
  make && make install



        13,安装libxml
1
2
3
  cd libxml2-2.9.0
  ./configure --prefix=/usr/local/libxml2 --with-zlib=/usr/local/zlib/
  make && make install



    14,安装curl
1
2
3
4
tar zxvf curl-7.42.0.tar.gz
cd curl-7.42.0
./configure --prefix=/usr/local/curl
make && make install



    15,安装php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/local/libxml2 --enable-xml --enable-sockets   --with-mcrypt=/usr/local/libmcrypt/ --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d  --with-bz2 --enable-maintainer-zts --enable-fpm --disable-fileinfo  --with-iconv=/usr/local/libiconv --with-curl=/usr/local/curl
make && make install
cp php.ini-production /usr/local/php5.4/php5.4.ini
ln -sv  /usr/local/php5.4/php5.4.ini /etc/php5.4.ini
vi /etc/php5.4.ini
------------------------------------------------------------------------
修改为:date.timezone = PRC #设置时区
-----------------------------------------------------------------------
cp /usr/local/php5.4/etc/php-fpm.conf.default  /usr/local/php5.4/etc/php-fpm.conf
rm -rf /etc/php.d/*
vi /usr/local/php5.4/etc/php-fpm.conf
----------------------------------------------------------------------------
pid = run/php-fpm5.4.pid #取消前面的分号
--------------------------------------------------------------------------
cp  sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php5.4-fpm
chmod +x /etc/rc.d/init.d/php5.4-fpm

vi /etc/rc.d/init.d/php5.4-fpm



QQ截图20160530011139.jpg

16,附上 nginx 与php整合配置
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
nginx.conf
----------------------------------
#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 8m;
        sendfile on;
        tcp_nopush     on;
        keepalive_timeout 60;
        tcp_nodelay 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;
        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.0;
        gzip_comp_level 2;
        gzip_types       text/plain application/x-javascript text/css application/xml;
        gzip_vary on;
        #limit_zone  crawler  $binary_remote_addr  10m;
        log_format '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    include /usr/local/nginx/vhost/*.conf;
}
-----------------------------------------------------
vhost/test.conf
------------------------------------------------------
server{   
    listen 80;
    #ssl on;
        server_name  localhost;
     #ssl_certificate      /ssl/server.crt;
     #ssl_certificate_key  /ssl/server.key;
    #error_page 404 /404.html;
    location /404.html{
    }   
     location / {
            autoindex on;
        root   /opt/php/php_test/;
        index  index.php index.html index.htm;
            if (-e $request_filename) {
                       break;
               }
               if (!-e $request_filename) {
                       rewrite ^/(.*)$ /index.php/$1 last;
                       break;
               }
        }
    location ~ .+\.php($|/) {
            root       /opt/php/php_test/;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param   PATH_INFO               $fastcgi_path_info;
            fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_pass   127.0.0.1:9000;
            include        fastcgi_params;
        }
             location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
                root /opt/php/php_test/;
                if (-f $request_filename) {
                        expires 1d;
                        break;
                        }
                }   
    #include /alidata/server/nginx/conf/rewrite/phpwind.conf;
        access_log  /usr/local/nginx/access/localhost.log;
}



----------------------------END--------------------------------



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-223617-1-1.html 上篇帖子: LAMP- CentOS 7平台三机FastCGI模型 下篇帖子: lnmp常见的502错误解决
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表