Centos8 安装apache
1:su root
2: yum –y install httpd
3: 设置自启动:systemctl enable httpd.service
4:启动: systemctl start httpd.service
5:访问你的虚拟ip:见右图
Centos8 安装php7.0
apache安装
dnf install httpd httpd-tools
开机启动
systemctl enable httpd
立即启动
systemctl start httpd
查看状态
systemctl status httpd
php安装
CentOS 8是用PHP 7.2发布的。该版本支持大多数现代PHP应用程序,但从2019年11月起将不再积极维护。较新的PHP版本可以从Remi存储库中获得。
如果您要安装发行版稳定的PHP版本7.2,请跳过这一步。如果您希望安装PHP 7.3或7.4,则通过以root用户或具有sudo特权的用户运行以下命令来启用Remi存储库:
dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
上面的命令还将启用EPEL存储库。
安装完成后,请运行以下命令以获取所有可用PHP版本的列表:
dnf module list php
输出将显示所有可用模块的列表,包括关联的AppStream(软件应用流),版本和安装配置文件。
默认的PHP模块设置为PHP 7.2。 要安装较新的PHP版本,请启用适当的版本:
PHP 7.3(不装也可以)
sudo dnf module reset php
sudo dnf module enable php:remi-7.3
PHP 7.4(不装也可以)
sudo dnf module reset php
sudo dnf module enable php:remi-7.4
您现在可以在CentOS服务器上安装PHP。
安装PHP
以下命令将安装PHP和一些最常见的PHP模块:
sudo dnf install php php-opcache php-gd php-curl php-mysqlnd
PHP使用FPM作为依赖安装,并用作FastCGI服务器。 启动FPM服务,并使它能够在启动时自动启动:
sudo systemctl enable --now php-fpm
Centos8安装mysql代替品mariadb
Centos8安装Nginx
Nginx 依赖 安装
安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
首先要安装 PCRE
PCRE 作用是让 Nginx 支持 Rewrite 功能。
yum install -y pcre pcre-devel
查看版本:pcre-config –version
安装nginx
1.创建文件夹——mkdir /home/你的用户/nginx
2.转到创建的文件夹——cd /home/你的用户/nginx
3.获取安装——wget http://nginx.org/download/nginx-1.18.0.tar.gz
解压缩——tar zxf nginx-1.18.0.tar.gz
查看——ll 或者ls -l
编译安装
• 指定编译安装目录 --prefix=/home/work/nginx
• 监控模块 --with-http_stub_status_module
• SSL模块 --with-http_ssl_module模块
• 1.转入文件夹: cd nginx-1.18.0
• 2. 获取: ./configure --prefix=/home/work/nginx --with-http_stub_status_module --with-http_ssl_module
• 3.编译: make
• 4。编译安装: make install
• 查看版本:/home/work/nginx/sbin/nginx –v
Nginx 其他命令启动 /home/你的用户/nginx/sbin/nginx
重载配置文件 /home/你的用户/nginx/sbin/nginx -s reload
重启 /home/你的用户/nginx/sbin/nginx -s reopen
停止 /home/你的用户/nginx/sbin/nginx -s stop
配置systemctl 管理
创建 nginx.service
1.vi /etc/systemd/system/nginx.service
2.cat /etc/systemd/system/nginx.service
• 启动 systemctl start nginx
• 停止 systemctl stop nginx
• 状态 systemctl status nginx
• 打开开机自启 systemctl enable nginx
• 关闭开机自启 systemctl disable nginx