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

[经验分享] Centos 6.5 部署 LNMP

[复制链接]

尚未签到

发表于 2019-2-17 07:03:43 | 显示全部楼层 |阅读模式
Nginx
[root@king01 ~]# rpm -ivh epel-release-6-8.noarch.rpm
[root@king01 ~]# yum install -y pcre pcre-devel openssl openssl-devel
[root@king01 ~]# useradd nginx -s /sbin/nologin -M
[root@king01 ~]# tar zxvf nginx-1.10.3.tar.gz
[root@king01 ~]# cd nginx-1.10.3
[root@king01 nginx-1.10.3]# ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module
[root@king01 nginx-1.10.3]# make
[root@king01 nginx-1.10.3]# make install
[root@king01 ~]# vim /etc/init.d/nginx
#!/bin/sh  
#  
# nginx - this script starts and stops the nginx daemin  
#  
# chkconfig:   - 85 15   
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \  
#               proxy and IMAP/POP3 proxy server  
# processname: nginx  
# config:      /usr/local/nginx/conf/nginx.conf  
# pidfile:     /usr/local/nginx/logs/nginx.pid  
# Source function library.  
. /etc/rc.d/init.d/functions
# Source networking configuration.  
. /etc/sysconfig/network
# Check that networking is up.  
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "  
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo  
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
stop() {
    echo -n $"Stopping $prog: "  
    killproc $prog -QUIT
    retval=$?
    echo  
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
restart() {
    configtest || return $?
    stop
    start
}
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "  
    killproc $nginx -HUP
    RETVAL=$?
    echo  
}
force_reload() {
    restart
}
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
    status $prog
}
rh_status_q() {
    rh_status >/dev/null 2>&1
}
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
       rh_status_q || exit 0
           ;;
    *)
       echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"  
        exit 2
esac
[root@king01 ~]# vim /usr/local/nginx/conf/nginx.conf
worker_processes  1;
error_log logs/error.log;
pid       logs/nginx.pid;
events {
    use epoll;
    worker_connections  1024;
}
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"';
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    keepalive_timeout  60;
    client_header_timeout  15;
    client_body_timeout  15;
    send_timeout  25;
    client_max_body_size  8m;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
            root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        access_log  logs/access.log  main;
    }
}
[root@king01 ~]# chmod +x /etc/init.d/nginx
[root@king01 ~]# chkconfig --add nginx
[root@king01 ~]# service nginx start
Starting nginx:                                            [  OK  ]
[root@king01 ~]# service nginx status
nginx (pid 30829 30827) is running...
[root@king01 ~]# netstat -tupln |grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      30827/nginx
[root@king01 ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.10.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module  
MySQL Server
http://blog.运维网.com/13598811/2069680  

PHP
[root@king01 ~]# yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel
[root@king01 ~]# tar zxvf php-5.5.30.tar.gz
[root@king01 ~]# cd php-5.5.30
[root@king01 php-5.5.30]# ./configure --prefix=/usr/local/php \
--with-config-file-path=/etc \
--with-zlib \
--with-bz2 \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--without-sqlite3 \
--without-pdo-sqlite \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-xml \
--enable-sockets \
--enable-mbstring \
--disable-ipv6
[root@king01 php-5.5.30]# make
[root@king01 php-5.5.30]# make install
[root@king01 php-5.5.30]# cp php.ini-production /etc/php.ini
[root@king01 ~]# vi /etc/php.ini
date.timezone = Asia/Shanghai
[root@king01 php-5.5.30]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@king01 php-5.5.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@king01 ~]# chmod +x /etc/init.d/php-fpm
[root@king01 ~]# chkconfig --add php-fpm
[root@king01 ~]# service php-fpm start
[root@king01 ~]# netstat -tupln |grep php-fpm
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      30771/php-fpm
[root@king01 ~]# service nginx restart
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]验证
[root@king01 ~]# cd /usr/local/nginx/html
[root@king01 html]# mv index.html index.php
[root@king01 html]# vi index.php




运维网声明 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-673314-1-1.html 上篇帖子: centos 7安装docker 下篇帖子: Centos7配置 SNMP服务
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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