centos下配置LNMP环境(源码安装)
准备工作,安装依赖库
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
View Code
1、编译安装nginx
1.1、下载解压nginx(stable版本)
wget http://nginx.org/download/nginx-1.13.8.tar.gztar zxf nginx-1.13.8.tar.gzcd 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_modulemakemake install
1.3、以服务的方式启动nginx
vim /etc/rc.d/init.d/nginx
#! /bin/bash# chkconfig: 35 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverseset -ePATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binDESC="nginx daemon"NAME=nginxDAEMON=/usr/local/nginx/sbin/$NAME (这里是nginx安装是 --sbin-path指定的路径)SCRIPTNAME=/etc/init.d/$NAMEtest -x $DAEMON || exit 0d_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" instart)echo -n "Starting $DESC:$NAME"d_startecho ".";;stop)echo -n "Stopping $DESC:$NAME"d_stopecho ".";;reload)echo -n "Reloading $DESC configuration..."d_reloadecho "reloaded.";;restart)echo -n "Restarting $DESC: $NAME"d_stopsleep 2d_startecho ".";;*)echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2exit 3;;esacexit 0
View Code
chmod u+x /etc/rc.d/init.d/nginxchkconfig --add nginxservice nginx startservice nginx stopservice nginx restartservice 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.confuser www www;#企业中一般 8-16 或者 auto worker_processes 4; worker_cpu_affinity 00000001 00000010 00000011 00000100; worker_rlimit_nofile 65535; #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 65535;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 0;keepalive_timeout 60;#fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2#keys_zone=TEST:10m#inactive=5m;#fastcgi_connect_timeout 300;#fastcgi_send_timeout 300;#fastcgi_read_timeout 300;#fastcgi_buffer_size 4k;#fastcgi_buffers 8 4k;#fastcgi_busy_buffers_size 8k;#fastcgi_temp_file_write_size 8k;#fastcgi_cache TEST;#fastcgi_cache_valid 200 302 1h;#fastcgi_cache_valid 301 1d;#fastcgi_cache_valid any 1m;#fastcgi_cache_min_uses 1;#fastcgi_cache_use_stale error timeout invalid_header http_500;open_file_cache max=204800 inactive=20s;open_file_cache_min_uses 1;open_file_cache_valid 30s;tcp_nodelay on;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.1;gzip_comp_level 1; #压缩级别大小,最大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 90; #nginx 跟后端服务器连接超时时间(代理连接超时)proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;} } server {listen 80;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 80;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 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1; #}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# 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 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 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;# }#}}
View Code
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/mirrormv mirror php-7.2.1.tar.gztar -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 -vPHP 7.2.1 (cli) (built: Jan 25 2018 20:47:58) ( NTS )Copyright (c) 1997-2017 The PHP GroupZend 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.confuser = wwwgroup = www
2.5、启动php-fpm
/etc/init.d/php-fpm start[root@centos7 php-7.2.1]# 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:80 0.0.0.0:* LISTEN 4045/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 848/sshd tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 16359/php-fpm: mas
https://www.cnblogs.com/tongl/p/7217283.html
2.6、配置支持PHP
cd /usr/local/nginx/conf/vim nginx.confuser 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/htmlvim index.php //内容如下<?php phpinfo(); ?>//如果能显示出php的环境信息,则表示配置成功
源码安装mariadb
转载于:https://www.cnblogs.com/blogscc/p/8352745.html
centos下配置LNMP环境(源码安装)相关推荐
- linux 安装lnmp环境,centos下配置LNMP环境(源码安装)
准备工作,安装依赖库//检查并安装组件 yum -y install gcc automake autoconf libtool make gcc-c++ glibc libxslt-devel li ...
- linux部署3proxy源码,在CentOS 7系统中从源码安装RTPProxy的方法
本文介绍在CentOS 7操作系统中从源码安装RTPProxy的方法,按照以下步骤操作即可成功. 在CentOS 7.x上安装RTPProxy 1.将目录更改为/usr/src: [root@kama ...
- centos下配置java环境,CentOS下配置Java环境变量的操作方法
AJAX开发,小编有自己的一些心得体会,也请AJAXer多多指教-那接下来先附上这篇CentOS下配置Java环境变量的操作方法,与君共勉,一起学习. rhel 和 centos linux 使用yu ...
- Windows下strongswan-5.5.3源码安装
Windows 下strongswan源码安装 网上没有一个完整版本的安装教程,只能看官方英文文档,折腾数周,成功编译.现附上安装历程供大家参考.有问题可以互相讨论. windows支持strongs ...
- Linux 系统安装配置PHP服务(源码安装)
简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于 ...
- centos7.4下安装配置PHP服务(源码安装)并配置nginx支持php
一.检查php是否已经安装,使用php -v,是否能够看到版本号,或者使用rpm -qa | grep php查看是否安装过. # yum remove php* -y 二.依赖包安装 Linux软件 ...
- centos7.4配置nginx php,centos7.4下安装配置PHP服务(源码安装)并配置nginx支持php
一.检查php是否已经安装,使用php -v,是否能够看到版本号,或者使用rpm -qa | grep php查看是否安装过. # yum remove php* -y 二.依赖包安装 Linux软件 ...
- lnmp环境搭建完全手册(四)——lnmp搭建(源码安装)
首先来介绍一下Nginx.Nginx是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器.Nginx不仅可以作为web服务器,也可以作为负载均衡器,之前也 ...
- linux 系统安装配置 zabbix服务(源码安装)
简介: zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定 ...
- centos 服务器装与python34源码安装
http://www.111cn.net/sys/CentOS/63645.htm 1.CentOS安装Python的依赖包(不安装依赖包,会导致python安装不完整) yum groupinsta ...
最新文章
- 因融资失败,应用崩溃,3 名程序员被“祭天”!
- CSS0 -- 静态、自适应、流式、响应式
- Android--PullToRefreshListView 的简单使用
- 大学计算机基础课程报告python-基于Python的“大学计算机基础”课程教学设计.doc...
- 网络流24题-魔术球问题
- docker学习4-docker安装mysql环境
- python matplotlib.pyplot 填充曲线下面积
- 文后参考文献著录规则
- centos下的umask值的更改
- 计算机无法通过无线上网,笔记本电脑突然无法使用无线网卡的多种解决方法
- Winform2、(C#) 设置编译后.exe执行文件的图标
- 极坐标弧长积分公式简单理解 极坐标求面积的公式,dθ 弧长积分公式,rd​原理; 极坐标弧积分
- oracle按序号排序,Oracle排序以及序号的显示
- SOAP实例入门(转)
- Ubuntu 18.04 桌面卡死
- AEJoy —— 详解 AE 如何将 png 序列帧导出为 SVGA 动画文件
- 【ZBH选讲·树变环】
- 一题乱作出来的题? ?
- 回文数(Java解法)
- 支付宝公钥私钥应用公钥私钥
热门文章
- 无交换机实现集群网络互联
- 进度条(5.16-5.22)
- Struts1的实现原理
- Mac 下载并使用 Adobe Audition CC 2019 分离 人物语音和背景音乐
- Kettle——简介
- Django 【第十四篇】信号
- 模拟生命_吸烟致癌?
- 算法笔记_138:稳定婚姻问题(Java)
- 安卓(Android)+苹果(Ios)仿微信、陌陌 移动社交APP系统源码,手机IM聊天软件源码,企业即时通讯APP程序源码...
- 几个清华和北邮学霸公众号,值得学习