Nginx安装后由于默认的conf文件而导致404错误

时间:2018-08-12 19:17:39

标签: php nginx

我已经在CentOS 7的最新版本上安装了nginxphp-fpmmariadb,但是出现404错误。

我要安装WordPress,安装是否正确,或者是否有更简单的方法来安装LEMP环境?

这是我遵循的安装步骤:

******************************************************************************************
***********************************  SYSTEM UPDATE  **************************************
******************************************************************************************
sudo yum -y update
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum -y install nano

******************************************************************************************
***********************************  NGINX INSTALL  **************************************
******************************************************************************************
sudo nano /etc/yum.repos.d/nginx.repo
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
    gpgcheck=0
    enabled=1
sudo yum -y install nginx
sudo systemctl start nginx
sudo systemctl enable nginx

******************************************************************************************
**********************************  MARIADB INSTALL  *************************************
******************************************************************************************
sudo nano /etc/yum.repos.d/MariaDB.repo
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.3/centos7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
sudo yum -y install MariaDB-server MariaDB-client
sudo systemctl start mariadb
sudo mysql_secure_installation   {ENTER - Y - NEW PASSWORD - Y - Y - Y - Y}
sudo systemctl enable mariadb

******************************************************************************************
**********************************  PHP-FPM INSTALL  *************************************
******************************************************************************************
sudo yum-config-manager --enable remi-php72
sudo yum -y install php
sudo yum -y install php-common php-fpm php-mysql php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
sudo nano /etc/php.ini
    cgi.fix_pathinfo=0       {1 OLAN DEĞERİ 0 YAP}
sudo nano /etc/php-fpm.d/www.conf
    listen = /var/run/php-fpm/php-fpm.sock      {";" VARSA SIL, LISTEN'I DEĞIŞTIR}
    listen.owner = nobody               {";" VARSA SIL, LISTEN.OWNER DEĞIŞTIR}
    listen.group = nobody               {";" VARSA SIL, LISTEN.GROUP DEĞIŞTIR}
    user = nginx                    {";" VARSA SIL, USER NGINX YAP}
    group = nginx                   {";" VARSA SIL, GROUP NGINX YAP}
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
sudo nano /etc/nginx/conf.d/default.conf        {DEFAULT.CONF DOSYASINI KLASÖRDEKI ILE DEĞISTIR, GEREKLI ALANLARI DOLDUR}
sudo systemctl restart nginx

******************************************************************************************
**********************************  PHPMYADMIN INSTALL  **********************************
******************************************************************************************
sudo yum --enablerepo=remi install phpMyAdmin
    {SESSION HATASI VERIRSE: chown -R nginx:nginx /var/lib/php/session}
sudo systemctl restart php-fpm
sudo systemctl restart nginx

******************************************************************************************
***********************************  FIREWALL INSTALL  ***********************************
******************************************************************************************
sudo yum -y install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

******************************************************************************************
*********************************  MODPAGESPEED INSTALL  *********************************
******************************************************************************************
sudo yum -y install gcc-c++ pcre-devel zlib-devel make unzip libuuid-devel

这是default.conf文件及其内容:

server {
    listen       80;
    server_name  muhammetdemirel.com.tr www.muhammetdemirel.com.tr;

    location / {
        root   /var/www/html;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    }

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
    }

    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }

    location ~ /\. {
        deny all;
    }

    location ~ ^/wp-content/uploads/.*\.php$ {
        deny all;
    }

    location ~* /(?:uploads|files)/.*\.php$ {
        deny all;
    }

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

    location /phpMyAdmin {
           root /usr/share/;
           index index.php index.html index.htm;
           location ~ ^/phpMyAdmin/(.+\.php)$ {
        root /usr/share/;
                try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
           }
           location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                root /usr/share/;
           }
    }

    location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
    }
}

0 个答案:

没有答案