a6266318 发表于 2019-2-17 07:03:43

Centos 6.5 部署 LNMP

Nginx
# rpm -ivh epel-release-6-8.noarch.rpm
# yum install -y pcre pcre-devel openssl openssl-devel
# useradd nginx -s /sbin/nologin -M
# tar zxvf nginx-1.10.3.tar.gz
# cd nginx-1.10.3
# ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module
# make
# make install
# 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
# vim /usr/local/nginx/conf/nginx.conf
worker_processes1;
error_log logs/error.log;
pid       logs/nginx.pid;
events {
    use epoll;
    worker_connections1024;
}
http {
    include       mime.types;
    default_typeapplication/octet-stream;
    log_formatmain'$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_timeout60;
    client_header_timeout15;
    client_body_timeout15;
    send_timeout25;
    client_max_body_size8m;
    server {
      listen       80;
      server_namelocalhost;
      location / {
            root   html;
            indexindex.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_loglogs/access.logmain;
    }
}
# chmod +x /etc/init.d/nginx
# chkconfig --add nginx
# service nginx start
Starting nginx:                                          
# service nginx status
nginx (pid 30829 30827) is running...
# netstat -tupln |grep nginx
tcp      0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      30827/nginx
# /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
# yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel
# tar zxvf php-5.5.30.tar.gz
# cd 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
# make
# make install
# cp php.ini-production /etc/php.ini
# vi /etc/php.ini
date.timezone = Asia/Shanghai
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
# chkconfig --add php-fpm
# service php-fpm start
# netstat -tupln |grep php-fpm
tcp      0      0 127.0.0.1:9000            0.0.0.0:*                   LISTEN      30771/php-fpm
# 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:                                          
Starting nginx:                                          验证
# cd /usr/local/nginx/html
# mv index.html index.php
# vi index.php



页: [1]
查看完整版本: Centos 6.5 部署 LNMP