惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
W
WeLiveSecurity
IT之家
IT之家
A
About on SuperTechFans
B
Blog
L
LangChain Blog
H
Help Net Security
Engineering at Meta
Engineering at Meta
Recent Announcements
Recent Announcements
Google Online Security Blog
Google Online Security Blog
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
GbyAI
GbyAI
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
S
SegmentFault 最新的问题
Cloudbric
Cloudbric
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
S
Security Affairs
The Last Watchdog
The Last Watchdog
H
Heimdal Security Blog
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Privacy & Cybersecurity Law Blog
V
Visual Studio Blog
H
Hacker News: Front Page
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
L
Lohrmann on Cybersecurity
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
C
Cybersecurity and Infrastructure Security Agency CISA
AWS News Blog
AWS News Blog
Jina AI
Jina AI
N
News | PayPal Newsroom
S
Schneier on Security

Rat's Blog - Nginx

使用Nginx反向代理,自建CDN加速节点 - Rat's Blog LNMP环境下,利用Nginx反代Google网站的方法 - Rat's Blog Nginx环境下对部分网站做防盗链设置及外链的跳转 - Rat's Blog 利用Nginx反向代理来简单镜像HTTP(S)网站的方法 - Rat's Blog LNMP环境下使用CDN后获取访客真实IP的方法 - Rat's Blog Nginx给网站添加用户认证配置( Basic HTTP authentication) - Rat's Blog Nginx环境使用auth_basic密码保护wordpress后台登录界面 - Rat's Blog Nginx环境开启ssl后强制https 301全部指向www的方法 - Rat's Blog 防止Linux VPS主机Nginx环境根目录被解析的方法 - Rat's Blog
CentOS 7安装配置Nginx 1.10、PHP 5.6、MySQL 5.7教程
博主: Rat's · 2017-10-07 · via Rat's Blog - Nginx

说明:本教程就是通过一些yum源安装的,挺简单的,喜欢折腾的人可以试试。

安装Nginx

1、建立nginx的yum仓库

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

nginxyum仓库地址:http://nginx.org/en/linux_packages.html

2、下载并安装nginx

yum install nginx

3、启动nginx服务

systemctl start nginx

4、测试和配置
访问IP地址,出现nginx欢迎界面。
默认的配置文件在/etc/nginx路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的nginx.conf等文件即可。

安装php 5.6

1、配置yum源

rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

remi源默认并没有启用,可以通过修改repo 文件来启用它。

vi /etc/yum.repos.d/remi.repo

修改以下位置:

[remi]
......
enabled=1
 
[remi-php56]
......
enabled=1

如果需要安装php 7,请编辑/etc/yum.repos.d/remi-php70.repo启用相应yum源。

2、确认安装的php版本

yum list | grep php

3、安装php5.6

yum install php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common

上面这条命令安装了一大堆东西,实际请按需安装。启用php-opcachephp-pecl-apcu能有效的提高php执行速度。

4、确认php版本

# php -v
PHP 5.6.22 (cli) (built: May 26 2016 15:36:45) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

5、配置php.ini

vi /etc/php.ini

理论上配置一下时区就够了:

date.timezone = Asia/Chongqing

6、配置php-fpm

vi /etc/php-fpm.d/www.conf

修改以下位置:

; 配置php所属用户
user = nginx
group = nginx
 
listen.owner = nginx
listen.group = nginx
 
; 通过sock方式通信
listen = /var/run/php-fpm/php-fpm.sock

7、启动php

systemctl start php-fpm

安装MySQL 5.7

1、配置yum源

rpm -Uvh http://repo.mysql.com/mysql57-community-release-el7.rpm

其他所有rpm文件可以在这里找到:http://repo.mysql.com/
如果你需要安装MySQL5.6

rpm -ivh http://repo.mysql.com/mysql-community-release-el7.rpm

2、安装mysql

yum install mysql-community-server

3、启动mysql

systemctl start mysqld

4、查看默认密码
MySQL安装之后默认root密码不是为空了,会生成一个随机密码保存在root目录下。

cat /root/.mysql_secret

如果没有找到文件,可以查看MySQL的日志文件:

cat /var/log/mysqld.log
 
# [Note]  A temporary password is generated for root@localhost: ******

5、登录mysql

mysql -u root -p

输入前面查看到的密码。

6、修改root默认密码
现在mysql有密码强度验证,需要输入一个强一点的密码。

mysql> set password=password('NEWPASSWORD');

或者:

update mysql.user set authentication_string=password('NEWPASSWORD') where user='root';

现在已经没有password字段了。

7、配置文件
mysql的默认配置文件在/etc/my.cnf
如果忘记密码,可以在最后添加一句skip-grant-tables,重启mysql之后登录就不需要账号密码了,然后再修改root密码。

如何正确配置Nginx+PHP

网上有一篇介绍Nginx配置PHP的文章,感觉挺不错的,下面就是他最后给出的配置模版。

server {
    listen 80;
    server_name www.moerats.com;
 
    root /path;
    index index.html index.htm index.php;
 
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
 
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        # fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    }
}

版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/343/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。