centos 7.4安装nginx + php7.2 +mysql5.6
1、 查看centos 版本
cat /etc/redhat-release
2、 安装nginx
yum install nginx
3、设置nginx开启起动
systemctl start nginx
4、测试访问http://你的域名或IP/
如果访问不了,查看一下阿里云的开放端口是否含有80端口。
5、 查看nginx安装位置
sudo find / -name nginx
6、 安装php
通过yum list php*查看是否有自己需要安装的版本,如果没有就需要添加第三方yum源
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
7、 选择自己需要的php版本号
yum install php72w-common
8、 安装mysql
CentOS 7的yum源中没有正常安装mysql时的mysql-sever文件,需要去官网上下载
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
成功安装之后重启mysql服务
# service mysqld restart
初次安装mysql是root账户是没有密码的
设置密码的方法
# mysql -u root
mysql > set password for 'root'@'localhost' = password('666');
mysql> exit
9、安装php-fpm
sudo yum search php72
yum install php72w-fpm
10、配置php处理器
vim /etc/php.ini
查找cgi.fix_pathinfo
将 ;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0
11、配置www.conf
vim /etc/php-fpm.d/www.conf
将
user = nobody
group = nobody
改为
user = nginx
group = nginx
前提是已经创建了nginx用户和nginx组。
11、起动php-fpm
systemctl start php-fpm
12、设置php-fpm开机启动
systemctl enable php-fpm
13、配置nginx
打开/etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
index index.php index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ~ .php$ {
try_files $uri =404;
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
13、访问http://你的IP/index.php,正常情况下会出现
14、开启php报错信息
vim /etc/php.ini
15、重启php-fpm
service php-fpm restart
推荐阅读
-
CentOS 7.4下安装Oracle 11.2.0.4数据库的方法
-
CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档
-
CentOS7 下nginx与PHP的安装与配置
-
如何在CentOS中安装PHP7.4的方法步骤
-
centos7 中安装 mysql5.6 的过程
-
CentOS 7 离线环境安装nginx时报错:./configure: error: C compiler cc is not found
-
centos7系统下nginx安装并配置开机自启动操作
-
CentOS下编译安装nginx及配置缩略图插件的方法教程
-
Linux(CentOS)环境下安装下载Nginx并配置
-
Centos7下编译安装配置Nginx+PHP+MySql环境