LNMP源码编译安装实录

Nginx

[[email protected] ~]# rpm -ivh epel-release-6-8.noarch.rpm 
[[email protected] ~]# yum install -y pcre pcre-devel openssl openssl-devel
[[email protected] ~]# useradd nginx -s /sbin/nologin -M
[[email protected] ~]# tar zxvf nginx-1.10.3.tar.gz
[[email protected] ~]# cd nginx-1.10.3
[[email protected] nginx-1.10.3]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module

[[email protected] nginx-1.10.3]# make
[[email protected] nginx-1.10.3]# make install
[[email protected] ~]# 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
[[email protected] ~]# 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;
    }
}
[[email protected] ~]# chmod +x /etc/init.d/nginx
[[email protected] ~]# chkconfig --add nginx
[[email protected] ~]# service nginx start
Starting nginx:                                            [  OK  ]

[[email protected] ~]# service nginx status
nginx (pid 30829 30827) is running...

[[email protected] ~]# netstat -tupln |grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      30827/nginx
         
[[email protected] ~]# /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 (略)

PHP

[[email protected] ~]# yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel
[[email protected] ~]# tar zxvf php-5.5.30.tar.gz 
[[email protected] ~]# cd php-5.5.30
[[email protected] 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

[[email protected] php-5.5.30]# make
[[email protected] php-5.5.30]# make install
[[email protected] php-5.5.30]# cp php.ini-production /etc/php.ini
[[email protected] ~]# vi /etc/php.ini 
date.timezone = Asia/Shanghai

[[email protected] php-5.5.30]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[[email protected] php-5.5.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 

[[email protected] ~]# chmod +x /etc/init.d/php-fpm
[[email protected] ~]# chkconfig --add php-fpm
[[email protected] ~]# service php-fpm start
[[email protected] ~]# netstat -tupln |grep php-fpm
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      30771/php-fpm

测试

[[email protected] ~]# 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  ]
[[email protected] ~]# cd /usr/local/nginx/html
[[email protected] html]# mv index.html index.php
[[email protected] html]# vi index.php 
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
<?php
$link=mysql_connect('127.0.0.1','root','abcd.1234');
if($link)
echo "success";
else
echo "failed";
phpinfo();
?>

原文地址:http://blog.51cto.com/13598811/2105140

时间: 2024-12-18 04:57:18

LNMP源码编译安装实录的相关文章

LNMP源码编译安装

系统环境为Centos6.5 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables  #编辑防火墙配置文件,将下面两条规则添加到22端口规则下面 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(允许80端口通过防火墙) -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT(允许3306端口通过

LNMP源码编译安装之PHP-5.5.32

一.FastCGI快速通用网关接口(socket),为HTTP服务器与其他机器上的程序服务通信交流工具常规web程序都支持. LNMP运行过程和解析原理原理白话用户访问NginxWeb服务器-Ngixn负责解析静态数据(jpg,gif,css,js,avi,html)也接受动态数据(.php)动态数据通过FastCGI接口后抛(fastcgi_pass监听 http://x.x.x.x:9000)给PHP服务器(php-fpm多个进程监听9000端口)[进程配置文件php-fpm.conf设置进

lnmp源码编译安装zabbix

软件安装 Mysql 安装 tar xf mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar -C mysql rpm -e --nodeps  mysql-libs-5.1.73-7.el6.x86_64 rpm -vih mysql-community-* service mysqld start 初始化root grep 'temporary password' /var/log/mysqld.log 2017-05-05T11:50:26.980187Z 1

LNMP源码编译安装之Mysql

Mysql 数据库是一种关系型数据库管理软件,关系型数据库特点是将数据库保存在不同的二维表(Excel)中,并且将这些表放入不同的数据库中,而不是把所有数据统一放在一个大仓库里,这样的设计增加了Mysql的读取速度,灵活性和可管理性也得到了很大提高.访问及管理Mysql数据库的最常用标准化语言为SQL结构化查询语言. Mysql安装 [[email protected] ~]# useradd -s /sbin/noligin mysql -M [[email protected] tools]

LAMP源码编译安装实录

[[email protected] ~]# rpm -ivh epel-release-6-8.noarch.rpm [[email protected] ~]# yum install -y expat-devel openssl openssl-devel pcre pcre-devel [[email protected] ~]# groupadd apache [[email protected] ~]# useradd apache -g apache -s /bin/nologin

CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境

什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/Perl/Python组合成的动态Web应用程序和服务器,它是一组Web应用程序的基础软件包,在这个基础环境上我们可以搭建任何使用PHP/Perl/Python等语言的动态网站,如商务网站.博客.论坛和开源Web应用程序软件等,它是互联网上被广泛使用的Web网站架构之一. 部署方式 从网站规模大小(访问流量.注册用户等)角度来看,LNMP架构可以使用单机部署方式和集群部署方式.单机部

源码编译安装lnmp架构

lnmp的架构 lnmp架构为:linux +nginx +mysql+php/perl/python,我们将只用linux(rhel6.5)+nginx+mysql+php构建企业web架构 环境:RHEL6.5 iptables -F selinux is  disabled 注意:在搭建lnmp环境前,必须检测系统内部不能存在相关的软件:(纯净搭建) #rpm -qa | grep php #rpm -qa | grep httpd #rpm -qa | grep mysql 1.ngin

lnmp环境源码编译安装记录

系统:Cenos 6.5 X64 软件: tengine-2.0.3.tar.gz pcre-8.33.tar.bz2 mysql-5.6.12.tar.gz php-5.5.14.tar.bz2 一.安装nginx 1.1 安装nginx所需的pcre-devel库,使nginx支持HTTP Rewrite模块 [[email protected]]# ./configure --prefix=/home/webserver/pcre  && make && make i

CentOS6.5 从源码编译安装 GCC-4.9.1 全程实录《第二部分:编译,安装,测试》

前言 GCC(GNU Compiler Collection,GNU编译器合集)是linux以及其他类UNIX平台上进行开源项目,软件开发等必不可少的工具链组成之一(工具链的其他成员包括 binutils,Glibc,libstdc++ 等) 另 外,对于程序员以及系统管理员而言,经常需要从软件的源码手动编译安装,而不论是configure脚本,还是make工具/makefile文件,最终 都需要调用gcc(或者其它编译器)来进行实际的编译工作,因此,经常需要使用gcc的新版特性,并且与旧版gc