编译安装Nginx
yum install gcc gcc-c++ pcre-devel openssl openssl-devel -y
groupadd nginx
useradd -W -g nginx -s /sbin/nologin nginx
mkdir /usr/local/nginx
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_gzip_static_module --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --add-module=../headers-more-nginx-module-0.30/
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/var/run/nginx/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
编译项解释:
--add-module=../headers-more-nginx-module-0.30/
添加第三方模块,用于自定义请求头。
make
make install
/usr/local/nginx/sbin/nginx
ln -s
安装PHP
//移除旧版php
[root@nginx ~]# yum remove php-mysql-5.4 php php-fpm php-common
//安装扩展源
[root@nginx ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@nginx ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
//安装php72版本
[root@nginx ~]# yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache
//启动php
[root@nginx ~]# systemctl start php-fpm
[root@nginx ~]# systemctl enable php-fpm
安装Mariadb
二进制安装
# 在Centos7中默认安装了Mysql的分支mariadb,需要卸载
[root@sirliu_web opt]# rpm -qa |grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@sirliu_web opt]# rpm -e mariadb-libs --nodeps
# 官方下载并解压、移动到工作目录
[root@sirliu_web opt]# tar xf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
[root@sirliu_web opt]# mv mysql-5.7.32-linux-glibc2.12-x86_64 /usr/local/mysql
# 创建用户、用户组、工作目录
[root@sirliu_web opt]# groupadd mysql && useradd -r -g mysql -s /bin/false mysql
[root@sirliu_web opt]# cd /usr/local/mysql/
[root@sirliu_web mysql]# mkdir data log
[root@sirliu_web mysql]# chmod +755 data/
# 创建Mysql主配置文件
[root@sirliu_web mysql]# vim /etc/my.cnf
[root@sirliu_web mysql]# cat /etc/my.cnf
[client]
socket=/usr/local/mysql/mysql.sock
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
pid-file=/usr/local/mysql/data/mysqld.pid
socket=/usr/local/mysql/mysql.sock
log_error=/usr/local/mysql/log/mysql.err
# 设置环境变量
[root@sirliu_web mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile && source /etc/profile
# 设置权限并初始化Mysql
[root@sirliu_web mysql]# chmod 750 data/ && chown -R mysql . && chgrp -R mysql . && bin/mysqld --initialize --user=mysql
# 创建启动脚本并启动
[root@sirliu_web mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld && service mysqld start
Starting MySQL. SUCCESS!
[root@sirliu_web mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4451/php-fpm: maste
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 862/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1769/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1125/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1382/master
tcp6 0 0 :::3306 :::* LISTEN 4800/mysqld
tcp6 0 0 :::111 :::* LISTEN 862/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1125/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1382/master
[root@sirliu_web mysql]#
//如果mysql登陆需要密码,请查看该文件
[root@nginx ~]# grep 'temporary password' /var/log/mysqld.log
数据库密码找回
# 1.在配置文件中插入如下内容
[root@yankerp ~]# cat /etc/my.cnf
skip-grant-tables
# 2.重启数据库
[root@web mysql]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
# 3.登录数据库
[root@web mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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>
mysql> update mysql.user set authentication_string=password('123456') where user='root';
添加php测试页面
1.配置Nginx
实现动态请求转发至php
[root@nginx ~]# cat /etc/nginx/conf.d/php.conf
server {
server_name _;
listen 80;
root /soft/code;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /soft/code$fastcgi_script_name;
include fastcgi_params;
}
}
2.添加php
测试页面
//测试phpinfo
[root@nginx ~]# cat /soft/code/info.php
<?php
phpinfo();
?>
最新评论
# 这只是一个创建远程登录并授权的语句、仅作为记录 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Fit2cloud!' WITH GRANT OPTION;
当MGR集群初始化结束后,需要开启MGR集群自启动(需要有一台节点是自动开启引导) loose-group_replication_start_on_boot = ON #设置节点是否在启动时自动启动 MGR 集群 loose-group_replication_bootstrap_group = ON #设置节点是否作为初始引导节点启动集群
密码:blog.sirliu.com
本内容密码:blog.sirliu.com 最新整理的文章在这里喔:https://blog.sirliu.com/2018/11/shell_lian_xi_ti.html