初始化系统

设置软件源

  • aliyun , remi, mysql
# 设置aliyun库
$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo# 设置 remi 库, 设置 mysql 库
$ yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm# 由于mysql 版权方面的限制, centos 7 没有内置mysql 服务器, 必须从mysql 官方进行安装
$ yum install http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
复制代码
  • 设置 nginx 源

源地址: nginx: Linux packages 创建 vi /etc/yum.repos.d/nginx.repo , 并且填充以下内容来安装 yum repository 库

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
复制代码

替换 OS 为 “rhel” 或 “centos” 替换 OSRELEASE 为 5”, “6”, 或“7”

更新元数据

# 更新元数据
$ yum makecache
复制代码

安装软件

常用软件和nmp 软件

# 更新系统
$ yum update# 安装常用软件
$ yum install vim git supervisor redis# 安装 php 基于 remi , 所以需要安装 remi 源
# 如果需要安装其他版本, 则需要将 repo=remi-php7x
$ yum install --enablerepo=remi-php70 php php-pdo php-fpm php-mbstring php-mcrypt php-gd php-mysqli php-zip# 安装 nginx
$ yum install nginx --enablerepo=nginx# 安装 mysql server
$ yum install mysql-server
复制代码

启动服务

# 启动服务
$ systemctl start php-fpm mysqld nginx supervisord
复制代码

开机自启动

# 开机启动
$ systemctl enable php-fpm mysqld nginx supervisord
复制代码

初始化数据库

启动mysql并且获取密码

$ systemctl start mysqld# mysql 5.7 在安装完成的时候会生成一个临时密码, 我们需要找到错误日志 `/var/log/mysqld.log`来获取这个临时密码
# use below command to see the password:
$ grep 'temporary password' /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: _ab3BAKulW?r复制代码

**初始化 mysql **

$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: ******New password: ******Re-enter new password: ******The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : *Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) :  YSuccess.Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : YSuccess.All done!
复制代码

设置密码的方法

$ mysql -uroot -p******
mysql> set password for 'root'@'localhost' = password('markzhao123456');
mysql> exit
复制代码

软件配置

配置nginx

配置 nginx 时候的运行组

# /etc/nginx/nginx.conf
user nginx nginx;
复制代码

配置nginx虚拟主机

server{listen 80;# 如果这里是 IP, 则才会允许访问, 否则, 扯破牛蛋也访问不到server_name www.domain.com ;index index.php index.html index.htm default.html default.htm default.php;root /webdata/www/domain/public;# 这里注意和服务器自带不同的是# fastcgi_param  SCRIPT_FILENAME  /scripts/$fastcgi_script_name;# fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;# 会导致 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstreamlocation ~ \.php$ {fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;include        fastcgi_params;}location / {try_files $uri $uri/ /index.php?$query_string;}location ~ .*\.(js|css)?$ {expires 12h;}access_log /webdata/logs/domain_access.log;error_log /webdata/logs/domain_error.log;
}复制代码

配置php

配置 php-fpm

# /etc/php-fpm.d/www.conf
user = nginx
group = nginx
复制代码

配置 php.ini

# 时区
date.timezone = Asia/Shanghai
复制代码

配置 session 是可写状态

$ chown -R nginx:nginx /var/lib/php/session/
复制代码

配置系统允许访问

# 配置 http
$ firewall-cmd --permanent --zone=public --add-service=http
# 配置 3306
$ firewall-cmd --permanent --zone=public --add-port=3306/tcp
# 重启 防火墙
$ firewall-cmd --reload
复制代码

配置数据库用户

CREATE USER 'remote'@'%' IDENTIFIED WITH mysql_native_password AS 'U*OSy)iKk$XO9dMB';
GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT ALL PRIVILEGES ON `1dailian\_v2`.* TO 'remote'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES
复制代码

补充

下载安装mysql

获取最新下载地址: http://dev.mysql.com/downloads/mysql/

下载地址: http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.13-1.el7.i686.rpm http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.13-1.el7.i686.rpm

# 下载
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.13-1.el7.i686.rpm
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.13-1.el7.i686.rpm# 安装
yum localinstall mysql-community-client**.rpm
yum localinstall mysql-community-server**.rpm
复制代码

参考文章

  • How To Install Nginx on CentOS 7(很及时, 解决了无法使用IP连接上服务器的问题)
  • Nginx安装(官网翻译)
  • nginx FastCGI错误Primary script unknown解决办法

转载于:https://juejin.im/post/5c876968e51d454170785745

[原] CentOS 7 安装 nginx, php mysql 套件相关推荐

  1. CentOS 7安装nginx+php+mysql环境

    0x01 安装php 1.首先得安装第三方软件库 yum install epel-release 复制代码 2.安装依赖包 yum install gcc gcc-c++ glibc libmcry ...

  2. linux slf4j.rpm,Centos下安装nginx rpm包

    1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html wget http://nginx.org/packages/centos/6 ...

  3. linux nginx rpm 安装配置,Centos下安装nginx rpm包

    1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html wget http://nginx.org/packages/centos/6 ...

  4. 在CentOS下安装apche+tomcat+mysql+php

    在CentOS下安装apche+tomcat+mysql+php 本例中所用到的软件 Apache 2.2 Sun的JDK-1_5_0_12-linux-i586 MySQL: mysql-5.0.4 ...

  5. centos 多个mysql,Centos中安装多个MySQL数据的配置实例

    这篇文章主要为大家详细介绍了Centos中安装多个MySQL数据的配置实例,具有一定的参考价值,可以用来参考一下. 感兴趣的小伙伴,下面一起跟随512笔记的小编小韵来看看吧! 注:本文档做了两个MYS ...

  6. 今天用pro安装nginx+php+mysql出现故障的解决方法

    今天用pro安装nginx+php+mysql出现故障的解决方法 by 伍雪颖 dyld: Library not loaded: @@HOMEBREW_CELLAR@@/openssl/1.0.1h ...

  7. centos下安装nginx流程

    centos下安装nginx流程 1.安装工具库: yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel ...

  8. CentOS下安装及配置MySQL

    大家好,我是中国码农摘星人. 欢迎分享/收藏/赞/在看! 欢迎提出使用本篇文章安装 MySQL 时遇到的问题,本篇文章会持续更新- MySQL 是一个关系型数据库管理系统,由瑞典 MySQL AB 公 ...

  9. CentOS 7 安装 Nginx

    CentOS 7 安装 Nginx 1.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-d ...

  10. CentOS rpm安装Nginx和配置

    CentOS rpm安装Nginx和配置 官方下载地址: http://nginx.org/en/download.html 介绍 Nginx("engine x")是一款由俄罗斯 ...

最新文章

  1. 图解八大排序算法——我见过的最详细的讲解(转)
  2. 使用python+opencv和pillow以及numpy对图像进行旋转,以及解决图像旋转过程中出现的黑边问题
  3. JDBC告警系列(一)The server time zone value 'ÖÐ' is unrecognized or represents more than one time zone....
  4. 《简明 PHP 教程》01 关于 PHP
  5. 解决VirtualBox里Ubuntu的共享文件夹无法访问(终极解决方案)
  6. 计算机专业杀毒,计算机病毒查杀
  7. 北理工爬虫课程学习记录
  8. 我们如何在Python中创建多行注释?
  9. 第四代双模5G旗舰:vivo X30系列为啥「超有梗」?
  10. java 声明数组_Java中的数组简介
  11. mysql56允许远程连接_mysql允许远程连接的方法
  12. re管理器修改音量_教你巧用RE管理器修改手机各种系统声音锁屏声音
  13. docker 容器内安装ps命令
  14. 集成微信支付后每次打开app都会跳转到微信显示正在连接
  15. IDEA的使用:4.IntelliJ IDEA的激活
  16. sv基础-数据类型(一)
  17. BERT-Whole Word Masked(WWM)
  18. Oracle 11g手动创建数据库(Linux平台)
  19. 24点游戏——C语言纯代码及MFC风格
  20. 我的第一个小程序【深车摇知】成功上线啦

热门文章

  1. 回发或回调参数无效。
  2. 重新审视SqlDataReader的使用
  3. C#中如何获取一个二维数组的两维长度,即行数和列数?
  4. python+selenium 使用for循环,遍历 定位 获取 单个元素中想要的值
  5. Layui默认表单校验规则
  6. 网站五万ip需要服务器,30万IP网站要用什么样的服务器?
  7. MAC使用CodeSign查看已签名的文件的数字签名情况
  8. Linux ldd时某个依赖库so not found的一种特殊情形
  9. 未解决:configure: error: XCode tool ‘metal‘ neither found in path nor with xcrunchecking for metal...
  10. 不同线程产生的map,会崩溃?