사이트 등록

학교의 모든 지식. SMwiki
둘러보기로 이동 검색으로 이동

개요[편집 | 원본 편집]

구글 콘솔 서치나 네이버 서치어드바이저 등에 사이트를 등록해야 검색엔진에 노출된다.

구글[편집 | 원본 편집]

구글 서치콘솔.[편집 | 원본 편집]

사이트맵 등록.[편집 | 원본 편집]

과정 설명 비고
디렉토리 제작
  • sudo mkdir -p /var/www/html/sitemap
  • sudo chown -R www-data:www-data /var/www/html/sitemap
  • sudo chmod -R 775 /var/www/html/sitemap
사이트맵 생성 php maintenance/run.php generateSitemap \

  --memory-limit=50M \

  --fspath=/var/www/html/sitemap/ \

  --identifier=smwiki.info \

  --urlpath=/sitemap/ \

  --server=https://smwiki.info \

  --compress=yes \

  --skip-redirects

  • mediawiki 디렉토리에서 실행.
  • 이렇게 하면 html/sitemap 디렉토리에 sitemap-index-smwiki.info.xml 형식으로 파일이 생성된다.
사이트맵 권한 설정 이상하게 계정에 귀속된 파일들이 생성된다. 권한 다시 설정.
  • sudo chown -R www-data:www-data /var/www/html/sitemap
  • sudo chmod -R 775 /var/www/html/sitemap
nginx 설정
    # sitemap.xml 파일 제공(bot의 크롤링을 위해.)
    location /sitemap/ {
        root /var/www/html;
        autoindex on;
        allow all;
        log_not_found off;
        access_log off;
    }
  • root /var/www/html/mediawiki; 라면 미디어위키 설치파일 안에 둔다.
  • 웹서버 설정에서 주소의 깔끔함을 위해 / 경로를 index로 해두는 경우가 있는데, 이땐 robots.txt 설정을 따로 해주어야 한다.(위키 백업과 복구#nginx 설정 참고.)

명령이 제대로 기입되면 "https://smwiki.info/sitemap/sitemap-index-smwiki.info.xml"가 사이트맵 주소가 된다.

robots.txt 등록[편집 | 원본 편집]

구글 봇이 크롤링을 할 수 있게 설정.

https://search.google.com/search-console/settings/robots-txt?resource_id=sc-domain%3Asmwiki.info&hl=ko

과정 설명 비고
웹서버 설정 루트 디렉토리에 robots.txt를 작성한다.
  • 웹서버 설정에서 주소의 깔끔함을 위해 / 경로를 index로 해두는 경우가 있는데, 이땐 robots.txt 설정을 따로 해주어야 한다.(위키 백업과 복구#nginx 설정 참고.)
robots.txt 작성
User-agent: *
# 불필요한 스크립트 파일 직접 접근 차단
Disallow: /index.php
Disallow: /load.php
Disallow: /api.php
Disallow: /rest.php
# 특수 문서 등 검색 불필요 페이지 차단
Disallow: /wiki/Special:
# 민감한 폴더 접근 차단 (Nginx 설정에서도 막았지만 robots.txt에서도 알려주는 게 좋음)
Disallow: /cache/
Disallow: /includes/
Disallow: /languages/
Disallow: /maintenance/
Disallow: /serialized/
Disallow: /store/
Disallow: /vendor/
# 이미지 폴더 자체 접근(목록) 차단 (images 폴더 안의 개별 이미지는 당연히 허용됨)
Disallow: /images/

# 미디어위키 리소스, 확장 기능, 스킨 등 필요한 파일 접근 허용 (Disallow보다 Allow 우선)
# Allow: 는 Disallow 규칙에 의해 막혔더라도 이 경로는 허용하겠다는 의미
# 루트(smwiki.info/)에서 바로 시작하는 경로로 수정
Allow: /resources/
Allow: /extensions/
Allow: /skins/

# 사이트맵 위치
Sitemap: https://smwiki.info/sitemap/sitemap-index-smwiki.info.xml
  • sitemap.xml은 설정하기 나름이니... 참고참고.
  • 웹서버 설정에서 미디어위키 서버를 루트로 잡고, index를 거치게 들어오게 해도 적절히 설정했다면 이처럼 접속해도 문제 없다.(try_files $uri $uri/ @rewrite; 따위로, 실제 파일이 있으면 그 파일을 반환해주고, 없으면 index를 거치게 되어 있다.)