yum安装:
yum相当于是自动化安装,你不用管软件的依赖关系,在yum安装过程是帮你把软件的全部依赖关系帮你一键完成。而且现在Centos7的服务启动已经换成systemctl命令来控制了。通过yum安装会帮你自动注册服务,你可以通过systemctl start xxx.service启动服务,方便快捷。但是缺点是yum安装你没办法干预,安装的目录也是分散的。你可能要执行whereis或者find命令去查找yum安装的路径。有时候yum安装的软件版本比较低,比如centos7默认情况下系统给你安装的php版本为5.4版本,这时候你不得不去找其他的yum源,或者rpm包来安装最新版本的软件。
1.安装源. https://blog.csdn.net/qq_35845964/article/details/110246464
yum installe pel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2.安装YUM管理工具
yum install yum-utils
3. 查看PHP(可忽略此步骤)
yum search php73
yum search php74
4.安装PHP
yum install php74-php-gd php74-php-pdo php74-php-mbstring php74-php-cli php74-php-fpm php74-php-mysqlnd
5.启动FPM
service php74-php-fpmstart
systemctl enable php74-php-fpm
#查看php7.4的安装路径whereis php
#链接php文件ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php
配置文件的路径:
# The current PHP memory limit is below the recommended value of 512MB.vi/etc/opt/remi/php74/php.ini
memory_limit = 512M
#如果你运行的是nginx而不是apache,修改vi/etc/opt/remi/php74/php-fpm.d/www.conf
user = apache
group = apache
# Replace the values with
user = nginx
group = nginx
卸载 php7.4
yum remove php74-php*
配置nginx,同时可以访问443和80端口
#
# The default server
#
server {
listen 80;
listen 443 ssl;
server_name blog.pianhuangw.com;
root /data/web/blog.pianhuangw.com;
index index.php;
ssl_certificate /etc/nginx/cert/blog.pianhuangw.com.pem;
ssl_certificate_key /etc/nginx/cert/blog.pianhuangw.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ~ \.php$ {
root /data/web/blog.pianhuangw.com;
fastcgi_pass unix:/var/opt/remi/php74/run/php-fpm/www.sock;
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 {
}
}
Nginx 操作
usr/local/nginx/sbin/nginx -t # 检测配置文件是否正确
/usr/local/nginx/sbin/nginx # 启动
/usr/local/nginx/sbin/nginx -s stop # 关闭
/usr/local/nginx/sbin/nginx -s reload #平滑重启
安装MySQL
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
1)首先启动MySQL
[root@localhost ~]# systemctl start mysqld.service
(2)查看MySQL运行状态,运行状态如图:
[root@localhost ~]# systemctl status mysqld.service
(3)此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的密码,通过如下命令可以在日志文件中找出密码:
[root@localhost ~]# grep"password"/var/log/mysqld.log
(4)如下命令登录数据库:
[root@localhost ~]# mysql -uroot -p
(5)此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库,如下命令修改密码:
mysql> ALTER USER'root'@'localhost'IDENTIFIED BY'new password';
其中‘new password’替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功。
如果出现如下错误:
是以为密码的复杂度不符合默认规定,如下命令查看mysql默认密码复杂度:
SHOW VARIABLES LIKE'validate_password%';
如需修改密码复杂度参考如下命令:
setglobalvalidate_password_policy=LOW;
setglobalvalidate_password_length=6;
3 开启mysql的远程访问
执行以下命令开启远程访问限制(注意:下面命令开启的IP是 192.168.19.128,如要开启所有的,用%代替IP):
grant all privileges on *.* to'root'@'192.168.0.1'identified by'password'with grant option;
注:password--是你设置你的mysql远程登录密码。
然后再输入下面两行命令
mysql> flush privileges;
此步操作,退出mysql也可以。具体参考:
创建MYSQL 数据库
CREATE DATABASE IF NOT EXISTS test_db_char DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_chinese_ci;