1. 下载nginx:http://nginx.org/en/download.html

2. 在usr/local文件夹中新建一个lnmp的文件夹,下载nginx压缩包并解压

[root@VM_48_141_centos ~]# cd usr/local

[root@VM_48_141_centos local]# mkdir lnmp

[root@VM_48_141_centos local]# cd lnmp

[root@VM_48_141_centos lnmp]# wget http://nginx.org/download/nginx-1.12.2.tar.gz

[root@VM_48_141_centos nginx-1.12.2]# ./configure --prefix=/usr/local/lnmp/nginx

出错

原因:没有gcc的编译库

解决办法:[root@VM_48_141_centos nginx-1.12.2]# yum install gcc gcc-c++ kernel-devel

继续,又出错

原因:没有正则库

解决办法:[root@VM_48_141_centos nginx-1.12.2]# yum install pcre-devel

继续,又出错

原因:没有zlib库

解决办法: [root@VM_48_141_centos nginx-1.12.2]# yum install -y zlib-devel

继续,OK

3.编译并安装 [root@VM_48_141_centos nginx-1.12.2]# make && make install

4启动nginx

[root@VM_48_141_centos lnmp]# cd Nginx

进入刚才自定义的安装目录Nginx 有4个文件爱夹

conf:配置文件   html:网页文件     logs:日志文件    sbin:主要进程文件

[root@VM_48_141_centos Nginx]# ./sbin/nginx

在浏览器中访问:

关闭Nginx:[root@VM_48_141_centos Nginx]# kill -INT 28024

查看nginx主进程号:[root@VM_48_141_centos Nginx]# ps aux|grep nginx

中间用到的命令

grep 'nginx' /etc/group

awk -F":" '{print $1"\t\t"$4}' /etc/passwd | grep '1000'

Nginx.Conf

#user  nobody;

//全局区

work_processes 1 ;   //有一个工作的子进程,可以自行修改,但太大无益,因为要争夺CPU,一般设置为CPU数*核数

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

//一般是配置nginx连接的特性

//如一个word能同时允许多少连接

worker_connections  1024;   //这里指一个子进程最大允许1024个连接

}

http {  //这是配置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  65;

#gzip  on;

server {

listen       80;

server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

root   html;

index  ab.html 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;

#    }

#}

}

 

二. 安装mysql

[root@VM_48_141_centos logs]# yum -y install mysql-server mysql mysql-devel

然后花了一下午在改mysql,装的不是mysql,而是mariadb

1.卸载:yum autoremove  mysql -y

2.wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

3.yum localinstall mysql57-community-release-el7-11.noarch.rpm

4.yum repolist enabled | grep "mysql.*-community.*"

5.yum install mysql-community-server -y

6. 启动mysql并查看其状态

命令:systemctl start mysqld

命令:systemctl status mysqld

7. 设置mysql为系统服务,随系统启动而启动

命令:systemctl enable mysqld

命令:systemctl daemon-reload

8. 查看mysql下root账号的默认密码

mysql5.7安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql。

命令:grep 'temporary password' /var/log/mysqld.log

其中Jb2h<%lp9itY部分就是默认密码

9.2. 修改my.cnf文件(/etc/my.cnf)

9.2.1. 修改密码策略

mysql的密码策略分为三种:

0或LOW:Length

1或MEDIUM:Length; numeric, lowercase/uppercase, and special characters

2或STRONG:Length; numeric, lowercase/uppercase, and special characters; dictionary file

在mysql的配置文件my.cnf文件中增加如下设置

#如果不需要密码策略,禁用密码策略
validate_password = off

# 密码选择策略 0-LOW,1-MEDIUM,2-STRONG需要提供密码字典文件
validate_password_policy = 0

9.2.2. 修改字符编码为utf8

在my.cnf中的[mysqld]下增加如下配置

character_set_server = utf8
init_connect = 'SET NAMES utf8'

命令:systemctl restart mysqld

10. 登录mysql

命令:mysql -uroot -p

输入密码:默认为刚才查到的Jb2h<%lp9itY

11. 修改密码

命令:ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
或命令:set password for 'root'@'localhost'=password('12345678');

12. 添加远程账户

命令:GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;

命令:FLUSH PRIVILEGES; 使设置生效

三.安装PHP

1. 下载地址:http://cn2.php.net/distributions/php-7.1.11.tar.gz

wget http://cn2.php.net/distributions/php-7.1.11.tar.gz

tar -zxvf php-7.1.11.tar.gz

..安装php依赖包 

yum install 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

./configure --prefix=/usr/local/lnmp/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

这里要make好久,要耐心一下

.添加 PHP命令到环境变量

# vim /etc/profile

在末尾加入

PATH=$PATH:/usr/local/php/bin

export PATH

要使改动立即生效执行

# source /etc/profile

查看环境变量

# echo $PATH

查看php版本

# php -v

配置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

启动php-fpm

# /etc/init.d/php-fpm start

.重启nginx

# service nginx reload

<?php

phpinfo();

可以查看到如下信息

Centos7+nginx1.12+mysql5.7+php7环境安装相关推荐

  1. LNMP环境搭建 centos7 nginx1.12 mysql5.6 php7

    经过一番折腾,终于将LNMP环境搭建完成了.本文介绍的LNMP环境是在windows的Oracle VM VirtualBox中的Centos虚拟机上搭建的,各个软件的版本为:Centos7 + Ng ...

  2. LNMP源码编译安装(centos7+nginx1.9+mysql5.6+php7)

    LNMP安装教程: 1.准备工作: 1)把所有的软件安装在/Data/apps/,源码包放在/Data/tgz/,数据放在/Data/data,日志文件放在/Data/logs,项目放在/Data/w ...

  3. centos php7.0 mysql_CentOS 7.3 下 安装LNMP(Nginx1.10+MySQL5.7+PHP7.0.20)

    前言:最近总是要安装服务器环境,记录这次CentOS 7.3下安装LNMP(Nginx1.10+MySQL5.7+PHP7.0.20)环境的过程,以备日后使用. 一.准备工作 1. 更新源 # yum ...

  4. lnmp环境搭建:Centos7 + Nginx1.12.2 + Mysql-5.6.38 + PHP7.2.0

    https://blog.csdn.net/ty_hf/article/details/50622888 转载于:https://www.cnblogs.com/leon2659/p/9299131. ...

  5. LNMP编译安装(centos7+nginx1.9+mysql5.6+php5.5)

    LNMP编译安装 # 需先配置IP # 软件包的路径 /usr/local/src yum install -y libjpeg-devel libpng-devel freetype-devel c ...

  6. 天翼云 centos7+下挂载磁盘和宝塔环境安装

    经常用到天翼云服务器做项目,因本人技术有限,每次都需要度娘方法,今天做一个记录,以后就方便查询了. 第一步:查看磁盘状态 # fdisk -l 第二步:创建分区 # fdisk /dev/sdb 输入 ...

  7. rox桌面环境 安装_使用ROX桌面重现Linux历史

    rox桌面环境 安装 ROX桌面不再被积极开发,但它的传统在今天得到了回响,即使它处于活动状态,它还是Linux桌面的独特之处. 尽管其他桌面感觉与旧的Unix或Windows界面大致相似,但ROX牢 ...

  8. CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7

    2019独角兽企业重金招聘Python工程师标准>>> CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7 使用 Netkiller OSCM 一 ...

  9. LNMP环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)

    一.安装MySql (本文永久地址:http://woymk.blog.51cto.com/10000269/1917133) mysql的安装请参考 LAMP环境搭建(centos6.9+apach ...

最新文章

  1. (C++)1041 考试座位号
  2. CEJ:西安理工赵亚乾组冠状病毒在水中传播特征、可能遏制策略与研究挑战
  3. NOIP 2017 提高组 K: 奶酪 (SPFA || 并查集)
  4. java list接口方法_java List集合接口的坑
  5. 搞定系统设计 01:从 0 到百万用户的系统
  6. 聊一聊和Nacos 2.0.0对接那些事
  7. JavaFX官方教程(十)之转换类型和示例
  8. GitHub for windows使用备忘录
  9. linux终端<Terminal>使用ping
  10. Spark在集群上执行代码案例(中文切词)
  11. centos 6.x下jira显示饼图乱码解决方法
  12. WinForm与WPF下跨线程调用控件
  13. Paraview:Python Calculator Filter
  14. html导航栏的渐变效果,html+css+js实现导航栏滚动渐变效果
  15. 关于安卓脚本打包apk
  16. logout退出登录该用get方法还是post方法?
  17. 【java毕业设计】基于java+SSH+jsp的网上体育商城设计与实现(毕业论文+程序源码)——网上体育商城
  18. 清蒸野猪佩奇自带LastDance
  19. 【Unity】3D模型或粒子渲染在UI上层
  20. 笔记本联想(Lenovo)G40-70M加装内存和SSD固态硬盘

热门文章

  1. php登录框注入,分享一个php的防火墙,拦截SQL注入和xss
  2. java线程死亡_java – 如何暂停main()直到所有其他线程死亡?
  3. 期末考试前的预习,科目:化工设备与反应器(3)
  4. 三十八、学Sql,不了解Sql注入怎么行?
  5. 七十四、SpringBoot 的数据缓存cache(一)
  6. 预训练永不止步,游戏问答语言模型实操
  7. 开放域知识库问答研究回顾
  8. 购物场景的对话流程如何实现?
  9. AAAI 2019 Oral | 让TA说你想听的—基于音/视频特征解离的讲述者人脸生成
  10. 回归理性 务实推进 迎接AI新时代 2018中国人工智能大会完美收官