LANMP笔记

更换aliyun的yum源、添加 epel源

# 更换aliyun的yum源
[root@VM_0_4_centos ~]# cd /etc/yum.repos.d/
[root@VM_0_4_centos ~]# cp CentOS-Base.repo CentOS-Base.repo.bak
[root@VM_0_4_centos ~]# wget -O CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo


# 添加 epel源
[root@VM_0_4_centos ~]# yum install -y epel-release  # 命令行安装
// 手动安装 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@VM_0_4_centos ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# 更新
[root@VM_0_4_centos ~]# yum clean all && yum makecache
[root@VM_0_4_centos ~]# yum -y update

预装libunwind

# 对于64位的linux系统,部分工具需要在libunwind环境下运行,如用于优化系统运行效率的tcmalloc、堆外内存分析工具google-perftools在64位linux系统下都需要libunwind才能运行
[root@VM_0_4_centos ~]# yum install libunwind

安装依赖文件

//yum install gcc gcc-c++ 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 apr apr-util pcre
//当前使用的CentOS Linux release 7.5.1804版本需要安装的依赖文件(大部分已经有了,devel版在这里不安装)
//查看下需要安装的依赖文件版本
[root@VM_0_4_centos ~]# yum list gcc gcc-c++ libmcrypt
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
gcc.x86_64                                               4.8.5-28.el7_5.1                                         updates
gcc-c++.x86_64                                           4.8.5-28.el7_5.1                                         updates
libmcrypt.x86_64                                         2.5.8-13.el7                                             epel   
[root@VM_0_4_centos ~]# yum -y install gcc gcc-c++ libmcrypt

yum源安装php7.2 安装php扩展的参考链接

添加epel源后可以使用yum源安装php5.5+的版本
[root@VM_0_4_centos ~]# yum -y install mod_php72w php72w-common php72w-fpm php72w-opcache php72w-gd php72w-mysqlnd php72w-mbstring php72w-pecl-redis php72w-pecl-memcached php72w-devel php72w-ldap php72w-mcrypt php72w-pdo php72w-xml

安装memcached 和 redis

yum install -y memcached redis

查看当前系统的release版本

[root@VM_0_4_centos ~]# more /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
或者
[root@VM_0_4_centos ~]# yum install redhat-lsb -y
[root@VM_0_4_centos ~]# lsb_release -a

安装lrzsz工具
用于windows和linux间传输文件

# yum -y install lrzsz

防火墙设置开启80端口433端口8080端口

[root@VM_0_4_centos ~]# systemctl start firewalld
[root@VM_0_4_centos ~]# firewall-cmd --permanent --zone=public  --add-service=http
[root@VM_0_4_centos ~]# firewall-cmd --permanent --zone=public  --add-service=https
[root@VM_0_4_centos ~]# firewall-cmd --permanent --zone=public --add-port=8080/tcp
[root@VM_0_4_centos ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
[root@VM_0_4_centos ~]# firewall-cmd --reload

防火墙详细配置可以参考:Linux下Centos7对外开放端口

安装apache

[root@VM_0_4_centos ~]# yum list install httpd
[root@VM_0_4_centos ~]# yum -y install httpd
[root@VM_0_4_centos ~]# httpd -v
[root@VM_0_4_centos ~]# systemctl enable httpd
//httpd-devel版本就不安装了,还不需要用到去编译httpd或开发额外模块的程度

添加CentOS 7 Nginx yum资源库

默认yum源里的Nginx版本到1.12.2,也可以直接安装,不过配置文件都放/etc/nginx/nginx.conf里面配置

[root@VM_0_4_centos ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root@VM_0_4_centos ~]# yum -y install nginx

nginx配置,设置8080端口来访问nginx服务器

[root@VM_0_4_centos ~]# vim /etc/nginx/conf.d/default.conf //将 listen 80;修改为 listen 8080;
[root@VM_0_4_centos ~]# systemctl enable nginx
[root@VM_0_4_centos ~]# systemctl restart nginx

nginx 的配置见文章
LNMP 下 Nginx 和 php-fpm 的配置
Centos 7 nginx 配置

云服务器端口的开放

云服务器上开放指定端口

开放8080端口后,一直无法访问。防火墙排查,web服务器排查都没有问题,试了下用内网访问8080端口的地址,可以正常访问。确认应该是云服务器上做的限制,找到安全组配置了8080端口,马上可以访问。

放通3306端口


放通3306端口

安装mysql

[root@VM_0_4_centos ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm    //下载mysql5.7的rpm文件
[root@VM_0_4_centos ~]# yum localinstall mysql57-community-release-el7-8.noarch.rpm    //安装rmp文件
[root@VM_0_4_centos ~]# yum install mysql-community-server  //安装MySQL数据库 约190M左右
[root@VM_0_4_centos ~]# systemctl start mysqld   //启动数据库
[root@VM_0_4_centos ~]# grep 'temporary password' /var/log/mysqld.log  //查看MySQL数据的原始密码文件
2018-06-26T03:09:32.292434Z 1 [Note] A temporary password is generated for root@localhost: xkHC:7-*axp1
[root@VM_0_4_centos ~]# mysql -u root -p     //进入数据库系统
mysql> set password for 'root'@'localhost'=password('Aa@123456'); //重新为数据库设置密码
//将MySQL设置为开机启动项
[root@VM_0_4_centos ~]# systemctl enable mysqld
[root@VM_0_4_centos ~]# systemctl daemon-reload
//设置数据的默认字符集(非必须的)
[root@VM_0_4_centos ~]# vim /etc/my.cnf
//将下面两行配置代码加入到my.cnf最后面
character_set_server=utf8
init_connect='SET NAMES utf8'

//开启mysql远程登录权限
mysql> use mysql;
mysql> grant all privileges on *.* to 'root'@'%' identified by "Aa@123456";
mysql> flush privileges;
[root@VM_0_4_centos ~]# systemctl restart mysqld  //重启MySQL

安装ssl证书,使用https协议
https://cloud.tencent.com/document/product/400/4143

参考摘录的网站有:
http://www.cnblogs.com/jimboi/p/8437788.html
https://blog.csdn.net/zhezhebie/article/details/73325663
https://www.jianshu.com/p/ed2d1820bd3e
https://www.cnblogs.com/weifeng1463/p/7941625.html
https://www.jianshu.com/p/8c9a0fabed68

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,039评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,426评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,417评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,868评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,892评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,692评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,416评论 3 419
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,326评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,782评论 1 316
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,957评论 3 337
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,102评论 1 350
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,790评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,442评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,996评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,113评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,332评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,044评论 2 355

推荐阅读更多精彩内容