CentOS7yum安装nginx+php7+mysql
相关笔记:
CentOS7源码编译安装nginx+php7.2+mysql5.7并使用systemctl管理
CentOS6.9源码编译安装nginx+php7+mysql环境
CentOS6.9yum安装nginx+php7+mysql环境
1.安装nginx
设置nginx安装源
vim /etc/yum.repos.d/nginx.repo
输入如下配置
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
查看nginx版本
yum list nginx
nginx.x86_64 1:1.14.2-1.el7_4.ngx
安装nginx
yum -y install nginx
查看安装版本和configure参数
[root@jmsiteos7 ~]# nginx -v
nginx version: nginx/1.14.2
[root@jmsiteos7 ~]# nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
启动nginx
systemctl start nginx
查看nginx状态
systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since 四 2019-01-03 13:36:25 CST; 11s ago
Docs: http://nginx.org/en/docs/
Process: 7376 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 7377 (nginx)
CGroup: /system.slice/nginx.service
├─7377 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─7378 nginx: worker process
1月 03 13:36:25 jmsiteos7 systemd[1]: Starting nginx - high performance web server...
1月 03 13:36:25 jmsiteos7 systemd[1]: Started nginx - high performance web server.
设置开机启动
systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
nginx详细配置请移步(nginx的configure参数,配置文件,虚拟主机配置,信号控制)
2.安装mysql
设置mysql5.7安装源
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
安装mysql
yum -y install mysql-community-server
启动mysql
systemctl start mysqld
设置开机启动
systemctl enable mysqld
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改
cat /var/log/mysqld.log | grep "A temporary password is generated for root"
2019-01-03T05:41:47.164940Z 1 [Note] A temporary password is generated for root@localhost: zMnep.TsF3tE
zMnep.TsF3tE便是root密码,修改root密码
mysql -uroot -pzMnep.TsF3tE
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.24
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'jmsite.cn';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jmsite.cn:80';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
设置编码
vim /etc/my.cnf
如下设置
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
重启mysql
systemctl restart mysqld
3.安装php7.2
设置centos7的php7安装源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php7.2和各种扩展
yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
启动php
systemctl start php-fpm
设置开机启动
systemctl enable php-fpm
4.配置nginx支持php
修改配置
vim /etc/nginx/conf.d/default.conf
server段中去掉下面的注释,并更改成如下配置
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
创建测试php文件
vim /usr/share/nginx/html/test.php
写入下面的php代码
<?php
phpinfo();
?>
重新加载nginx配置
systemctl reload nginx
浏览器输入:你的ip地址/test.php
关注公众号
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
CentOS6.9安装RabbitMQ和源码编译安装php的RabbitMQ扩展
1.安装依赖 yum install make gcc gcc-c++ build-essential openssl openssl-devel unixODBC unixODBC-devel kernel-devel m4 ncurses-devel 2.安装Erlang 查看yum中Erlang版本 yum list erlang erlang.x86_64 R14B-04.3.el6 RabbitMQ3.7.9要求Erlang版本不低于19.3.6.4,因此要么设置新的yum源,要么下载新版源码包自己安装 wget -c http://erlang.org/download/otp_src_21.2.tar.gz tar -zxvf otp_src_21.2.tar.gz cd otp_src_21.2 配置检查 ./configure --prefix=/usr/local/erlang 配置检查后若提示 xsltproc is missing. yum install libxslt 配置检查后若提示 fop is missing. yum install fop 编译,安...
-
下一篇
清除过期日志的py脚本
本篇和大家分享的是一个清除过期日志的python脚本,年后第二篇希望对大家有帮助; 该python脚本创建的由来 代码及分析 crontab定时任务 该python脚本创建的由来 此由来,是在过年假期时突然被反馈告警服务器磁盘空间占用比例增大,当时通过df等命令定位到,是使用了某个开源任务调度框架日志增大并之前很多历史日志没有自动删除导致的; 因此,查看该框架的文档是否有自动清除配置,暂时没有找到自动清除日志的配置说明,于是乎浏览源码就是log4来记录的,本来打算扩展重写下log4让其具有自动清除日志的功能,但是想到以后可能还有其他项目的日志无法自动清除,于是乎有了本篇分享的python产出,仅仅配置下检测路径即可删除自定义n天之前的日志 代码及分析 先来上代码,具体如下: #! /usr/bin/python #coding=utf-8 imp
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- MySQL数据库中FOR UPDATE的使用
- Docker容器配置,解决镜像无法拉取问题
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS6,CentOS7官方镜像安装Oracle11G
- CentOS8编译安装MySQL8.0.19
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- Linux系统CentOS6、CentOS7手动修改IP地址
- CentOS7,CentOS8安装Elasticsearch6.8.6


微信收款码
支付宝收款码