[root@localhost ~]# yum -y install httpd httpd-devel php php-devel php-mysql
Installed:
httpd-devel.x86_64 0:2.4.6-88.el7.centos
php.x86_64 0:5.4.16-46.el7
php-devel.x86_64 0:5.4.16-46.el7
php-mysql.x86_64 0:5.4.16-46.el7
Complete!
2.安装配置mysql5.7 需要先卸载maiiadb数据库,因为centos默认安装的是mariadb (1)卸载mariadb
[root@bogon ~]# rpm -qa |grep mariadb
mariadb-devel-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@bogon ~]# yum -y remove mariadb
Removed:
mariadb.x86_64 1:5.5.60-1.el7_5
Complete!
使用rpm卸载,语法:
rpm -e --nodeps 文件名 # --nodeps 解除依赖性
[root@localhost ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-devel-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-devel-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -qa |grep mariadb
[root@localhost ~]#
(2)安装mysql 在Mysql官网获取rpm源 : https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
[root@localhost ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
[root@localhost ~]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
warning: mysql57-community-release-el7-11.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
package mysql57-community-release-el7-11.noarch is already installed
[root@localhost ~]# yum -y install mysql mysql-devel mysql-server
...
Dependency Installed:
mysql-community-common.x86_64 0:5.7.25-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.60-1.el7_5
Complete!
[root@bogon ~]# rpm -qa |grep mysql
mysql-community-libs-5.7.25-1.el7.x86_64
mysql-community-libs-compat-5.7.25-1.el7.x86_64
php-mysql-5.4.16-46.el7.x86_64
mysql57-community-release-el7-11.noarch
mysql-community-client-5.7.25-1.el7.x86_64
mysql-community-server-5.7.25-1.el7.x86_64
mysql-community-common-5.7.25-1.el7.x86_64
mysql-community-devel-5.7.25-1.el7.x86_64
[root@bogon ~]#
OK,Mysql安装成功 3.启动apache apache对应的服务是httpd,并加入开机自启。
[root@bogon ~]# systemctl start httpd[root@bogon ~]# systemctl enable httpd
4.创建php测试页面 apache发布页面的存放目录在 /var/www/html。
[root@bogon ~]# cd /var/www/html[root@bogon html]# ls[root@bogon html]# vim index.php[root@bogon html]#
5.修改apache配置文件httpd.conf 修改apache配置文件 /etc/httpd/conf/httpd.conf ,在大约285行左右的地方添加一行内容,使得apache能够读懂.php文件,不然会无法访问php测试页面。
[root@bogon ~]# vim /etc/httpd/conf/httpd.conf283 AddType application/x-compress .Z284 AddType application/x-gzip .gz .tgz285 AddType application/x-http-php .php .phtml
6.重启apache并测试php 重启httpd服务,并打开浏览器,访问php测试页面。
[root@bogon ~]# systemctl restart httpd
访问成功。
[root@bogon ~]# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm #到官网下载rpm包[root@bogon ~]# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm 1:nginx-release-centos-7-0.el7.ngx ################################# [100%][root@bogon ~]# yum -y install nginx...Complete![root@bogon ~]#
2.安装Mysql5.7
[root@bogon ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm[root@bogon ~]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm[root@bogon ~]# yum -y install mysql mysql-serverComplete![root@bogon ~]#
3.安装部署php 安装php、php-mysql和php-fpm。
[root@bogon ~]# yum -y install php php-mysql php-fpm
4.启动相关服务 启动nginx、mysql和php-fpm,并加入开机自启。 为什么要安装php-fpm? 因为 php-fpm,是nginx和php的桥梁 ,php-fpm(快速进程管理),php-fpm默认进程为127.0.0.1:9000,一会php和php-fpm安装完成后,要配置nginx的配置文件,让其遇到客户端php请求是,转发给php-fpm(127.0.0.1:9000),php-fpm再让php解析完成,最后又给nginx。
[root@bogon ~]# systemctl start nginx && systemctl enable nginx[root@bogon ~]# systemctl start mysqld && systemctl enable mysqld[root@bogon ~]# systemctl start php-fpm && systemctl enable php-fpm[root@bogon ~]# netstat -nltpActive 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 16736/php-fpm: masttcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16689/nginx: mastertcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6831/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7188/master tcp6 0 0 :::3306 :::* LISTEN 6910/mysqld tcp6 0 0 :::22 :::* LISTEN 6831/sshd tcp6 0 0 ::1:25 :::* LISTEN 7188/master [root@bogon ~]#
5.创建php测试文件 进入到nginx发布目录/usr/share/nginx/html/,创建php测试文件。
[root@bogon ~]# cd /usr/share/nginx/html/[root@bogon html]# vim index.php
6.修改default.conf文件 修改nginx配置文件 /etc/nginx/conf.d/default.conf ,添加index.php,去掉以下注释并修改 fastcgi_param ,使得nginx能够读懂php文件
[root@bogon ~]# vim/etc/nginx/conf.d/default.conf...location / { root /usr/share/nginx/html; index index.php index.html index.htm; }...location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params; }...
7.浏览器测试访问 重启nginx服务,浏览器访问:http://IP/index.php。
[root@bogon ~]# systemctl restart nginx[root@bogon ~]#
测试成功。
更多文章请前往:
https://blog.csdn.net/qq_41490561
更多精彩内容请关注我们往期推荐
PanDownload复活了,听说60Mb/s ,你信吗?
宝塔面板未授权访问漏洞复现