1. 当前位置:网站首页 > PHP环境

Centos7安装nginx、iptables、netstat、php7及配置


编辑网络

vi /etc/sysconfig/network-script/网卡名

安装iptables防火墙

yum install iptables-services
#编辑
vi /etc/sysconfig/iptables
#加入80 和 3306 远程端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
#重启防火墙
systemctl restart iptables.service
#设置开机启动
systemctl enable iptables.service
#修改配置文件
vi /etc/selinux/config

#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled 增加
:wq! #保存退出
#使配置立即生效
setenforce 0

安装net-tools、wget

yum -y install wget net-tools

安装mysql

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install -y  mysql-server
sudo chown -R root:root /var/lib/mysql
systemctl restart mysql.service
 初入安装 root用户没有密码:
[root@linux]# mysql -u root
#设置msyql密码为 123456
mysql> set password for \'root\'@\'localhost\' =password(\'123456\');
#远程连接设置,所有以root账号连接的远程用户,设其密码为 123456
mysql> grant all privileges on *.* to root@\'%\'identified by \'123456\';
#更新权限
mysql>flush privileges;
mysql > exit;

安装nginx

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx
systemctl start nginx.service

php7

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 -y php70w
 #安装扩展
yum install -y  php70w-mysql.x86_64   php70w-gd.x86_64   php70w-ldap.x86_64   php70w-mbstring.x86_64  php70w-mcrypt.x86_64
#安装php-fpm
yum install -y php70w-fpm

配置nginx

#nginx配置文件
vi /etc/nginx/conf.d/default.conf

 server {
    listen       80;
    default_type text/plain;
    root /var/www/html;
    index index.php index.htm index.html;
#错误配置

    error_page   404 500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/html;
    }
#隐藏index.php
    location / {
          if (!-e $request_filename) {
                   #一级目录
                  # rewrite ^/(.*)$ /index.php/$1 last;
                   #二级目录
                  #rewrite ^/MYAPP/(.*)$ /MYAPP/index.php/$1 last;
                  rewrite ^/index.html/?$ /index.php?s= last;
                  rewrite  ^(.*)$  /index.php?s=$1 last;
                  break;
             }
    }
#pathinfo设置
        location ~ \\.php($|/) {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\\.php)(.*)$;
            fastcgi_param   PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
   }
}

#修改php-fpm文件
vi /etc/php-fpm.d/www.conf
user = nginx
group= nginx

#重启nginx
systemctl restart nginx.service
systemctl status nginx
systemctl restart php-fpm.service //或者开启
systemctl status php-fpm.service

本文最后更新于2019-4-21,已超过 3个月没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
版权说明

本文地址:http://www.liuyangdeboke.cn/?post=17
未标注转载均为本站远程,转载请注明文章出处:

发表评论

联系我们

在线咨询:点击这里给我发消息

微信号:17721538135

工作日:9:00-23:00,节假日休息

扫码关注