<span>linux centos8 安装php nginx mysql 运行phpcms网站</span>
重新换vps,用centos8,重新配置系统环境,记下笔记:
安装nginx与php
首先安装nginx php ,安装默认版本的nginx,php默认安装7
yum install nginx php
系统罗列安装详细信息,输入yes即可
nginx状态设置
启动nginx
systemctl start nginx.service
查看nginx状态
systemctl status nginx
设置开机启动
systemctl enable nginx.service
显示 enbaled 则设置开机启动成功
systemctl is-enabled nginx.service;echo $?
php状态设置
启动php
systemctl start php-fpm
查看php 当前版本
php -v
设置php开机启动
systemctl enable php-fpm
如果要运行phpcms 还要安装gd json mysql库
yum install php-gd php-msyql php-json
如果不知道名字,yum search php ,查看相关扩张库
安装以下扩张库
yum -y install php-json php-xml php-mysqlnd php-mbstring php-common php-gd
## yum -y install php72w-cli php72w-common php7php2w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
如果需要安装php5.6
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
yum install php56w php56w-opcache php56w-fpm
查看php版本
php -V
mysql安装
centos 默认安装的mysql8.0,我希望安装5.6,需要收手工安装。
首先参考下网上的方法:
centos7 安装mysql5.6 https://www.cnblogs.com/lulin9501/p/11069093.html
需要编译,放弃,推荐,参考此篇方法,安装。精炼如下:
按照此篇方法 安装,CentOS 7系统安装nginx+php+mysql https://blog.csdn.net/YZJ0517/article/details/85542304
启动mysql,报 Failed to start mysqld.service: Unit mysqld.service not found. 错误
推荐: CentOS7下使用YUM安装MySQL5.6 https://blog.csdn.net/pengjunlee/article/details/81212250
查看是否安装MySQL
rpm -qa | grep mysql
下载安装包文件
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
查看可用安装包
yum repolist all | grep mysql
安装mysql
yum install mysql-server
检查mysql是否安装成功。
rpm -qa | grep mysql
启动 mysql 服务
systemctl start mysqld.service
设置密码
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("这里输入root用户密码") where User='root';
mysql> flush privileges;
设置mysql字符集
character_set_server = utf8
default-character-set = utf8
或者 vim /etc/my.cnf
设置为 :
character_set_server=utf8
init_connect='SET NAMES utf8'
参考文章:
How to Install Apache/PHP 7 on CentOS/RHEL 7.5/6.9 and Fedora 28-26 https://tecadmin.net/install-apache-php-on-centos-fedora/
CentOS7下使用YUM安装MySQL5.6 https://blog.csdn.net/pengjunlee/article/details/81212250
centos7 安装mysql5.6 https://www.cnblogs.com/lulin9501/p/11069093.html
Failed to start mysqld.service: Unit not found https://blog.csdn.net/miaodichiyou/article/details/99289160
总结:
安装mysql 推荐:CentOS 7系统安装nginx+php+mysql https://blog.csdn.net/YZJ0517/article/details/85542304