准备工作,安装依赖库

yum -y install gcc automake autoconf libtool make gcc-c++ glibc libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel pcre pcre-devel libmcrypt libmcrypt-devel cmake

1、编译安装nginx

1.1、下载解压nginx(stable版本)

wget http://nginx.org/download/nginx-1.13.8.tar.gz
tar zxf nginx-1.13.8.tar.gz
cd nginx-1.13.8

1.2、安装nginx

useradd www
./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module
make
make install

1.3、以服务的方式启动nginx

vim /etc/rc.d/init.d/nginx
#! /bin/bash
# chkconfig:
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME (这里是nginx安装是 --sbin-path指定的路径)
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit
d_start(){
$DAEMON || echo -n " already running"
}
d_stop() {
$DAEMON -s quit || echo -n " not running"
}
d_reload() {
$DAEMON -s reload || echo -n " counld not reload"
}
case "$1" in
start)
echo -n "Starting $DESC:$NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC:$NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&
exit
;;
esac
exit
chmod  u+x /etc/rc.d/init.d/nginx
chkconfig --add nginx
service nginx start
service nginx stop
service nginx restart
service nginx reload firewall-cmd --zone=public --add-port=80/tcp --permanent #添加tcp 80端口
firewall-cmd --zone= public --remove-port=80/tcp --permanent #移除tcp 80端口

1.4

[root@centos7 conf]# cat nginx.conf

user  www www;

#企业中一般 -  或者 auto
worker_processes ;
worker_cpu_affinity ;
worker_rlimit_nofile ;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
use epoll;
worker_connections ;
multi_accept on; #尽可能多接受请求
} 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 logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ;
#fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=:
#keys_zone=TEST:10m
#inactive=5m;
#fastcgi_connect_timeout ;
#fastcgi_send_timeout ;
#fastcgi_read_timeout ;
#fastcgi_buffer_size 4k;
#fastcgi_buffers 4k;
#fastcgi_busy_buffers_size 8k;
#fastcgi_temp_file_write_size 8k;
#fastcgi_cache TEST;
#fastcgi_cache_valid 1h;
#fastcgi_cache_valid 1d;
#fastcgi_cache_valid any 1m;
#fastcgi_cache_min_uses ;
#fastcgi_cache_use_stale error timeout invalid_header http_500;
open_file_cache max= inactive=20s;
open_file_cache_min_uses ;
open_file_cache_valid 30s;
tcp_nodelay on; gzip on;
gzip_min_length 1k;
gzip_buffers 16k;
gzip_http_version 1.1;
gzip_comp_level ; #压缩级别大小,最大9,值越小,压缩比例越小,cpu处理更快,消耗低
gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on;
client_max_body_size 10m; #允许客户端请求的最大文件字节数
client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数 proxy_connect_timeout ; #nginx 跟后端服务器连接超时时间(代理连接超时)
proxy_send_timeout ; #后端服务器数据回传时间(代理发送超时)
proxy_read_timeout ; #连接成功后,后端服务器响应时间(代理接收超时) server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
}
} server {
listen ;
server_name zabbix; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html/zabbix/;
index zabbix.php; #index.html index.htm index.php;
}
} server {
listen ;
server_name www.cccc.com; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html/b;
index index.html index.htm;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

2、安装php7

2.1安装依赖

yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

2.2、下载解压安装

wget http://si1.php.net/get/php-7.2.1.tar.gz/from/this/mirror
mv mirror php-7.2.1.tar.gz
tar -zxf php-7.2.1.tar.gz
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
make 
make install

2.3、设置环境变量

vim /etc/profile
PATH=$PATH:/usr/local/php/bin
export PATH
source /etc/profile [root@centos7 php-7.2.1]# php -v
PHP 7.2.1 (cli) (built: Jan 25 2018 20:47:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

2.4、设置php-fpm

cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
vim /usr/local/php/etc/php-fpm.d/www.conf
user = www
group = www

2.5、启动php-fpm

/etc/init.d/php-fpm start

[root@centos7 php-7.2.]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
tcp 127.0.0.1: 0.0.0.0:* LISTEN /php-fpm: mas

https://www.cnblogs.com/tongl/p/7217283.html

2.6、配置支持PHP

cd /usr/local/nginx/conf/
vim nginx.conf
user  www www;
user   www  www;  #修改nginx运行账号为:www组的www用户
index index.php index.html index.htm; #增加index.php location ~ \.php$ {
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;
}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_ro
ot

//验证nginx配置语法

/usr/sbin/nginx -t
/usr/sbin/nginx -s reload
//测试
cd/usr/local/nginx/html
vim index.php
//内容如下
<?php phpinfo(); ?>
//如果能显示出php的环境信息,则表示配置成功

源码安装mariadb

 

centos下配置LNMP环境(源码安装)的更多相关文章

  1. CentOs下MySQL5.6.32源码安装

    . 安装好--安装MySQL需要的包 yum install -y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c+ ...

  2. linux下MySQL 5.6源码安装

    linux下MySQL 5.6源码安装 1.下载:当前mysql版本到了5.6.20 http://dev.mysql.com/downloads/mysql 选择Source Code 2.必要软件 ...

  3. Centos下配置php环境

    Centos下配置php环境   目录[-] 环境: GD2 2 安装PHP 5.2.14(FastCGI模式) 1)编译安装PHP 5.2.14所需的支持库: 2)编译安装MySQL 5.5.3-m ...

  4. centos环境源码安装postgresql9.4

    源码安装简要步骤 下载PostgreSQL 源码包  下载根目录地址:http://ftp.postgresql.org/  本人选择的是当前最新版本v9.4.1:http://ftp.postgre ...

  5. CentOS Linux release 7.3源码安装zabbix

    CentOS Linux release 7.3安装zabbix 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 前言: 我去年用用centos6的环境搭建了一下 zabbix3.0 ...

  6. RHEL Server 6.3下MySQL5.5.25a源码安装

    OS:RHEL Server 6.3 MySQL:mysql-5.5.25a.tar.gz 相关依赖包: ncurses-5.9.tar.gz bison-2.5.tar.gz 安装MySQL 一.安 ...

  7. Redis集群生产环境源码安装

    安装redis集群  根据各人单位生产环境用户搭建一.安装环境    操作系统:centos7.6 关闭防火墙.关闭selinux redis1:192.168.26.128 redis2:192.1 ...

  8. Centos 6.5升级gcc : 源码安装 + rpm安装

    1. 前言 采用Centos 6.5默认的gcc版本为4.4.7,不支持c++ 11,需要升级: 首先想到用yum命令:执行yum update gcc-c++或yum update g++ 显示没有 ...

  9. Linux 系统安装配置PHP服务(源码安装)

    简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要 ...

随机推荐

  1. 如何在云开发静态托管中使用Hugo

    如何在云开发静态托管中使用Hugo 介绍 hugo是一个用Go编写的静态站点生成器,由于具有丰富的主题资源和有比较丰富的主题资源和较好的生成速度. 云开发(CloudBase)是一款云端一体化的产品方 ...

  2. Spring Cloud 系列之 Consul 注册中心(一)

    Netflix Eureka 2.X https://github.com/Netflix/eureka/wiki 官方宣告停止开发,但其实对国内的用户影响甚小,一方面国内大都使用的是 Eureka ...

  3. ES5与ES6 this 指向详细解析(箭头函数)

    首先要明白箭头函数的作用: 箭头函数除了让函数的书写变得很简洁,可读性很好外:最大的优点是解决了this执行环境所造成的一些问题.比如:解决了匿名函数this指向的问题(匿名函数的执行环境具有全局性) ...

  4. 精彩的jquery弹幕效果

    html页面如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

  5. stand up meeting 11/20/2015

    3组员 今日工作 工作耗时/h 明日计划 计划耗时/h 冯晓云 将输出string里的翻译合理取分为动名词等各种词性,按约定格式返回,按热度排列,但每一个词性下的解释仍然是由“$$”分词:对于查询词为 ...

  6. C. Standard Free2play --div

    https://codeforces.com/contest/1238/problem/C 题意:下台阶的时候只有一种方式,拉动当前台阶x的 level,然后当前的台阶关闭,调到下边的台阶x-1,如果 ...

  7. 实现一个简单的基于动态代理的 AOP

    实现一个简单的基于动态代理的 AOP Intro 上次看基于动态代理的 AOP 框架实现,立了一个 Flag, 自己写一个简单的 AOP 实现示例,今天过来填坑了 目前的实现是基于 Emit 来做的, ...

  8. Charles抓包——弱网测试(客户端)

    基础知识 网络延迟:网络延时指一个数据包从用户的计算机发送到网站服务器,然后再立即从网站服务器返回用户计算机的来回时间.通常使用网络管理工具PING(Packet Internet Grope)来测量 ...

  9. jarvisoj MISC 取证2

    打开之后一个文件和一个镜像 TrueCrypt....记住他了,再看一眼那个文件,好的,TrueCrypt加密..找密码 把Truecrypt.exe直接dump下来,用efdd解密就行了

  10. 【题解】P2480 [SDOI2010]古代猪文 - 卢卡斯定理 - 中国剩余定理

    P2480 [SDOI2010]古代猪文 声明:本博客所有题解都参照了网络资料或其他博客,仅为博主想加深理解而写,如有疑问欢迎与博主讨论✧。٩(ˊᗜˋ)و✧*。 题目描述 猪王国的文明源远流长,博大精 ...