2.1.1
在这个时候我们需要安装依赖包
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.1.2
下载并且解压到(/usr/local/src目录当中去)
cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
2.1.3 编译安装
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx
make && make install
2.1.4添加账号
groupadd nginx
useradd -M -g nginx -s /sbin/nologin nginx
cd /usr/local/nginx/conf
编辑 vim nginx.conf
user nginx nginx;
2.1.5设置nginx为系统服务
vim /lib/systemd/system/nginx.service
文件内容
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
2.1.6启动nginx
systemctl restart nginx
2.1.7在虚拟机中访问127.0.0.1
出现nginx的画面就是成功了
2.1.8如果需要在windos上看见
关闭防火墙
systemctl stop firewall.service
[root@server1 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@server1 ~]# uname -r
3.10.0-693.el7.x86_64
rpm -qa | grep mysql
可能出现一到多个结果,也可能没有
rpm -e --nodeps {file-name}
{file-name}
中是第一步中查询到的名字,没查到旧版本,可以跳过本步骤
访问官网,选自适合自己操作系统的yum源:MySQL :: Download MySQL Yum Repository
wget -P /tmp https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
需要安装wget软件
yum install -y wget
rpm -ivh /tmp/mysql80-community-release-el7-3.noarch.rpm
方法一:使用命令选择版本
# 关闭8.0版本
yum-config-manager --disable mysql80-community
# 开启5.6版本
yum-config-manager --enable mysql56-community
需要安装 yum-utils 软件
yum install -y yum-utils
方法二:手动编辑yum文件
vi /etc/yum.repos.d/mysql-community.repo
找到您要配置的子存储库的条目,然后编辑该enabled
选项。指定 enabled=0
禁用子存储库,或 enabled=1
启用子存储库
例如,要安装 MySQL 5.6,请确保 enabled=0
在mysql80 的子存储库条目上,以及enabled=1
在mysql56 的子存储库条目上:
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
yum install -y mysql-community-server
方法一:centos7
# 启动服务
systemctl start mysqld
# 查看服务状态
systemctl status mysqld
# 停止服务
systemctl stop mysqld
# 重启服务
systemctl restart mysqld
方法二:centos6
# 启动服务
service mysqld start
# 查看服务状态
service mysqld status
# 停止服务
service mysqld stop
# 重启服务
service mysqld restart
mysql5.6版本安装后root默认密码为空,可通过命令查看
mysql> select user,host,password from mysql.user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | server1 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | server1 | |
+------+-----------+----------+
方法一:使用mysqladmin为账户分配密码
shell> mysqladmin -u root password "new_password"
shell> mysqladmin -u root -h host_name password "new_password"
方法二:使用语句为root账户分配密码
shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('new_password')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
FLUSH
语句使服务器重新读取授权表,没有它,服务器不会注意到密码更改,直到您重新启动它。mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'new_password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
step1: 查看编码集
mysql> SHOW VARIABLES LIKE 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
step2: 修改配置文件/etc/my.cnf
[root@server1 ~]# >/etc/my.cnf
cat >> /etc/my.cnf << EOF
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8
EOF
systemctl restart mysqld
step3: 重新查看编码集
mysql> SHOW VARIABLES LIKE 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
yum install 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
若没有libmcrypt包的话可以去下载安装
cd /usr/local/src
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make
make install
cd /usr/local/src
软件包可以在windos上利用xshell上传
cd php-7.2.0
./configure --prefix=/usr/local/php --disable-fileinfo --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-xmlrpc --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-zip --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --enable-bcmath
make
make install
cp php.ini-development /etc/php.ini
groupadd www-data
useradd -M -g www-data -s /sbin/nologin www-data
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d
cp www.conf.default www.conf
vim www.conf
user=www-data
group=www-data
vim /usr/local/nginx/conf/nginx.conf
第一步修改的
第二步修改配置文件,然后开启php
vim /etc/systemd/system/php-fpm.service
文件内容:
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
PrivateTmp=True
[Install]
WantedBy=multi-user.target
启动服务
systemctl start php-fpm.service
然后创建测试访问的页面
然后在浏览器里面输入地址访问
然后就ok啦嘻嘻嘻有什么问题可以私聊我