2019独角兽企业重金招聘Python工程师标准>>>

阿里云CentOS 7.4 基本环境配置

添加 yum 第三方源

常用的第三方源有两个:EPEL 和 IUS,可在 https://ius.io/GettingStarted/ 查看到最新的安装方法

自动安装

curl -L https://setup.ius.io | sh

手动安装(用了自动安装,这个就省略)

$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ wget https://centos7.iuscommunity.org/ius-release.rpm$ rpm -ivh epel-release-latest-7.noarch.rpm
$ rpm -ivh ius-release.rpm

安装完成更新yum源缓存

$ yum clean all
$ yum makecache

安装开发工具包

$ yum -y groupinstall "Development Tools"

升级系统软件包

$ yum -y upgrade

安装 jemalloc

$ yum -y install jemalloc

安装 redis

$ yum -y install redis

启动redis服务并设置为自动启动

$ systemctl enable redis
$ systemctl start redis

安装 Mariadb 5.5.56

安装 mariadb

$ yum -y install mariadb mariadb-server

将mariadb的数据目录移动到自定义位置

创建mariadb数据目录

# -p 参数可以自动生成完整路径,比如上面不存在/data目录,会自动创建
mkdir -p /data/mariadb#修改目录所有者
chown -R mysql:mysql /data/mariadb

配置 mariadb

#备份 mariadb-libs生成的my.cnf
mv /etc/my.cnf /etc/my.cnf.libs.back
#从mariadb复制配置文件
cp /usr/share/mysql/my-large.cnf /etc/my.cnf

修改 /etc/my.cnf

[mysqld]
#设置数据目录
datadir=/data/mariadb#添加字符集设置utf8
# setting character set
init_connect = 'SET NAMES utf8'
character-set-server = utf8
collation-server = utf8_unicode_ci
skip-character-set-client-handshake#修改thread_concurrentcy为CPU数量*2
thread_concurrency = 2#添加mysqld_safe设置
[mysqld_safe]
log-error = /var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#添加jemalloc支持
malloc-lib=/usr/lib64/libjemalloc.so.1#最末尾添加包含配置目录
!includedir /etc/my.cnf.d

启动 mariadb

$ systemctl start mariadb

设置mariadb服务开机启动

$ systemctl enable mariadb

初始化mariadb

#修改mysql_secure_installation,否则会出现找不到sock文件的问题
#找到make_config函数在有[mysql]这句下方增加
echo "socket=/data/mariadb/mysql.sock" >> $config
#保存退出$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] y... Success!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? [Y/n] y... Success!By default, MariaDB 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? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n] y... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!

安装 Nginx

$ yum -y install nginx
#设置开机启动
$ systemctl enable nginx

修改systemctl启动设置,避免无法找到pid文件的问题

$ mkdir -p /etc/systemd/system/nginx.service.d
$ printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
$ systemctl daemon-reload 

启动 nginx

$ systemctl start nginx

安装 PHP 7.1

$ yum -y install php71u-fpm php71u-fpm-nginx
$ yum -y install php71u-mbstring php71u-common php71u-gd php71u-mcrypt
$ yum -y install php71u-mysqlnd php71u-xml php71u-cli php71u-devel
$ yum -y install php71u-pecl-redis php71u-opcache

修改/etc/nginx/conf.d/php-fpm.conf

upstream php-fpm {#server 127.0.0.1:9000;server unix:/run/php-fpm/www.sock;
}

修改/etc/php-fpm.d/www.conf

#修改php-fpm进程用户
user = nginx
group = nginx#修改网络方式
;listen = 127.0.0.1:9000
listen = /run/php-fpm/www.sock#修改生成sock的用户
listen.owner = nginx
listen.group = nginx
listen.mode = 0666

启动php-fpm

$ systemctl enable php-fpm
$ systemctl start php-fpm

配置nginx虚拟主机

设置虚拟主机

# 添加虚拟主机配置目录
$ mkdir -p /etc/nginx/vhosts.d

修改nginx配置文件/etc/nginx/nginx.conf

# 在server配置后面添加
include /etc/nginx/vhosts.d/*.conf;

到/etc/nginx/vhosts.d目录创建 aaa.conf文件,假设www.aaa.com为域名

server {listen       80;server_name  www.aaa.com;access_log  /data/aaa/logs/access.log main;error_log   /data/aaa/logs/error.log;charset utf-8;location / {try_files $uri $uri/ /index.php?q=$uri&$args;root   /data/aaa/www;index  index.php index.html index.htm;}# pass the PHP scripts to FastCGI server listening on Unix socketlocation ~ \.php$ {root           /data/aaa/www;fastcgi_pass   php-fpm;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;include        fastcgi_params;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's onelocation ~ /\.ht {deny  all;}
}

创建虚拟主机网页存放目录和日志目录

$ mkdir -p /data/aaa/{logs,www}

创建一个测试文件

echo "<?php phpinfo();" > /data/aaa/www/index.php

重启动nginx和php-fpm

$ systemctl restart nginx
$ systemctl restart php-fpm

用浏览器访问域名看看是否看到phpinfo页面

转载于:https://my.oschina.net/u/2357619/blog/1612120

阿里云CentOS 7.4 配置Nginx、PHP、Mariadb相关推荐

  1. 在阿里云centos7.4上配置nginx免费的https证书,支持泛解析

    在阿里云centos7.4上配置nginx免费的https证书,支持泛解析 一 原理说明: 使用acme.sh工具来生成证书,但为了方面采用的使用dns添加TXT记录验证方式,跟传统的webroot有 ...

  2. 阿里云centos 安装和配置 DokuWiki

    DokuWiki 是一个开源的 wiki 项目, 可方便进行知识和内容的管理和分享,不用安装数据库,内置权限管理,书写直观方便,有大量的插件支持. 特别适用于企业内部的内容和知识管理,只允许内部员工编 ...

  3. (转)阿里云CentOS 7下配置及使用mysql

    一.安装 1 正确的安装方法: 众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本.所以我们需要先安装带 ...

  4. 2020-11-25 阿里云CentOS linux源配置脚本 https://mirrors.aliyun.com/repo/

    https://developer.aliyun.com/mirror/centoshttps://mirrors.aliyun.com/repo/ 查看全文 http://www.taodudu.c ...

  5. 阿里云centos 7 apache 配置虚拟站点

    1.修改 httpd.conf文件 一般情况位置 位于 /etc/httpd/conf a.打开 # Include conf/extra/httpd-vhosts.conf 可能不存在,不存在则自己 ...

  6. 阿里云centos7怎么查看mysql_(转)阿里云CentOS 7下配置及使用mysql

    一.安装 1正确的安装方法: 众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本.所以我们需要先安装带有 ...

  7. 阿里云 Centos 7 PHP7环境配置 LNMP

    阿里云 Centos 7 PHP7环境配置 LNMP (centos7+nginx+MySQL5.7.9+PHP7) 首先更新系统软件$ yum update 安装nginx 1.安装nginx源 1 ...

  8. 阿里云centos环境之Let's Encrypt SSL证书配置十一

    阿里云centos环境之Let's Encrypt SSL证书配置<十一> 1.目标 Let's Encrypt是国外一个公共的免费SSL项目.这里记录的是可执行的生成免费SSL证书Let ...

  9. 阿里云CentOS环境之-实战docker集群swarm(十五)

    前言 docker1.12版本之前版本配置 准备工作 开始 拉取swarm 开放2375远程访问端口 创建集群的token 向集群里添加结点 查看集群里有哪些结点 创建管理者容器 使用集群 离开集群 ...

最新文章

  1. 软件开发人员需要的不仅是技术,也不是文档,也不是管理,而是……
  2. 三星note4 N9100刷回4.4.4系统后无法usb连接电脑
  3. 移动支付php,银联手机支付服务端PHP端代码
  4. java简单的事务处理_JAVA之JDBC简单事务处理
  5. 移动端web自适应解决方案: adaptive.js
  6. Saltstack之自定义grains
  7. C中遇到错误error: jump to label [-fpermissive]的解决办法
  8. Java SVN管理工具的使用
  9. mac下安装wxPython2.8.12.1方法
  10. 主动降噪ANC 耳机的传参设计
  11. 使用IP地址连接网络打印机
  12. matlab画图时如何将坐标设置为中文宋体,英文新罗马字体
  13. vijos 1540 月亮之眼 并查集
  14. 京豆薅羊毛新姿势-docker方式
  15. Python绘制玫瑰花
  16. centos添加桌面快捷方式
  17. Synergy v1.10版本跨平台鼠键共享资源
  18. 计算机全屏显示快捷键,最全电脑快捷键,电脑全屏按哪个键 原来是这样的
  19. 该结束这忙忙碌碌却又碌碌无为的生活了
  20. Python笔记之不可不练

热门文章

  1. C#中Path类的常用方法
  2. Jquery中发送ajax请求示例代码
  3. SpringData核心数据访问接口--PagingAndSortingRepository
  4. Netty4服务端和客户端实现
  5. 【TensorFlow】笔记4:图像识别与CNN
  6. 将文本计算机应用能力的样式设置为标题1,计算机应用基础期末考试试题
  7. leetcode 28. Implement strStr() 实现strStr()
  8. Java GUI:将JPanel添加进JScrollPane
  9. python搭建django
  10. rrnDB数据库简介-16S基因多拷贝数的证据