CentOS/RHEL 7.1 & 6.7下安装PHP 7, NGINX & MySQL 5.6

分类 建站知识  最后修订: 2018年09月11日 11:22:17  浏览: 258 次

适用于有洁癖、重视安全的人。一般建议使用:OneinStack:自助安装lnmp、lamp、lnmpa等(支持HHVM)
建议CentOS 7.均为SSH下、root用户。

一、升级系统,更换更新源
适用于CentOS / RHEL 7系统

yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

适用于CentOS / RHEL 6系统

yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

二、安装PHP 7
1、安装PHP 7

yum install php70w

2、安装PHP 7组件
查找组件

yum search php70w

安装组件

yum install php70w-mysql php70w-xml php70w-soap php70w-xmlrpc
yum install php70w-mbstring php70w-json php70w-gd php70w-mcrypt

三、安装NGINX
1、安装NGINX

yum install nginx

2、启动NGINX

systemctl enable nginx.service
systemctl start nginx.service

四、安装MySQL 5.6
1、安装MySQL

yum install mysql-server

2、安全设置

systemctl start mysqld.service
mysql_secure_installation

3、启动MySQL

systemctl restart mysqld.service
systemctl enable mysqld.service

五、设置PHP-FPM

yum install php70w-fpm

六、创建网站

nano /etc/nginx/conf.d/example.conf

粘贴如下内容:

server {
        listen   80;

        root /var/www;
        index index.php index.html index.htm;
        server_name  example.com www.example.com;

        location / {
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        location ~ .php$ {
                try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

根据需要更改为自己的域名、文件存放目录。

七、重启服务

systemctl restart nginx.service
systemctl restart php-fpm.service

八、防火墙开放http (80) 和 https (443)端口

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

via:https://servercheap.net/crm/index.php?rp=/knowledgebase/1/Install-PHP-7-NGINX-and-MySQL-56-on-CentOSorRHEL-71-and-67.html

年付10美金,洛杉矶KVM VPS

HiFormance,美国KVM VPS,年付10美金,1TB月流量
https://zhujiwiki.com/13229.html

超大流量 不限版权

Hostsolutions,罗马尼亚VPS,30TB月流量,无版权限制
https://zhujiwiki.com/12883.html

温馨提示:文章内容系网络信息分享,不代表 主机百科 对观点赞同或支持。

版权声明:本文为原创文章,版权归 主机百科 所有,转载请注明出处!

联系站长:广告、发Offer等联系:admin@zhujiwiki.com | TG:https://t.me/t66y_net

添加新评论