Chcesz skonfigurować lokalne środowisko programistyczne WordPress bez przekartkowywania stron i stron dokumentacji? Nasz arkusz informacyjny na temat lokalnego rozwoju WordPressa pomoże Ci w szybkim, inteligentnym uruchomieniu!
W tym „no-fluff” praktyczny przewodnik, będziemy pokryć krótko, co WordPress lokalny rozwój jest i niektóre z kluczowych korzyści z korzystania z niego, a następnie dostaniemy się prosto do tego, jak skonfigurować lokalne środowisko, zainstalować WordPress na komputerze i przetestować swoją stronę internetową przed wyjazdem na żywo.
Ten przewodnik obejmuje następujące zagadnienia:
Co to jest WordPress Local Development?
Lokalny rozwój WordPressa umożliwia utworzenie środowiska programistycznego do budowania, pracy i testowania witryn WordPress na komputerze bez wpływu na witrynę na żywo.
Lokalne środowisko programistyczne replikuje serwer produkcyjny, umożliwiając testowanie różnych scenariuszy i rozwiązywanie problemów przed pchaniem zmian do witryny na żywo.
Korzyści
z lokalnego rozwoju
Niektóre z kluczowych korzyści z lokalnego rozwoju WordPress obejmują
:
- Bezpieczne środowisko testowe: Lokalne środowisko programistyczne zapewnia bezpieczną przestrzeń do testowania nowych funkcji, wtyczek i motywów bez wpływu na witrynę na żywo.
- Szybkość, wydajność i efektywność: Lokalne środowisko programistyczne jest szybsze i bardziej responsywne niż serwer zdalny. Dzieje się tak dlatego, że działa na twoim komputerze, więc twój komputer może uzyskać dostęp do danych i przetwarzać je znacznie szybciej niż serwer, a ponadto nie ma opóźnień w komunikacji między twoim komputerem a serwerem.
- Efektywność kosztowa: Skonfigurowanie lokalnego środowiska programistycznego eliminuje potrzebę korzystania z drogich usług hostingowych i zmniejsza koszty związane z wdrażaniem zmian w witrynie na żywo. Do rozpoczęcia pracy wystarczy komputer i edytor tekstu.
- Ulepszona współpraca: Wielu programistów może jednocześnie pracować nad jednym projektem, nie zakłócając wzajemnie swojej pracy.
- Rozwój w trybie offline: Dzięki lokalnemu środowisku programistycznemu możesz rozwijać swoją witrynę nawet wtedy, gdy jesteś offline.
- Zwiększone bezpieczeństwo: Masz „ściśle tajny” projekt, nad którym chcesz pracować? Ponieważ lokalne środowisko programistyczne działa na twoim komputerze, jest bardziej bezpieczne niż zdalny serwer, więc możesz budować i pracować nad swoją stroną z dala od ciekawskich oczu. Nie ma ryzyka nieautoryzowanego dostępu lub włamania.
Jeśli dopiero zaczynasz pracę jako deweloper WordPress, zobacz nasz artykuł wprowadzający do lokalnego rozwoju WordPress. Jeśli jesteś już nieco bardziej doświadczony, sprawdź nasz artykuł na temat sposobów poprawy przepływu pracy nad rozwojem WordPressa w środowisku lokalnym.
Konfigurowanie lokalnego środowiska
programistycznego
Zanim skonfigurujesz lokalne środowisko programistyczne WordPressa, jest kilka rzeczy, których będziesz potrzebować.
Co będziesz potrzeb
ował
Oprócz komputera z wystarczającą ilością miejsca na dysku i mocą obliczeniową do wspierania prac rozwojowych, oto wszystko, czego potrzebujesz, aby skonfigurować lokalne środowisko programistyczne:
Oprogramowanie lokalnego
serwera Do uruchomienia lokalnego środowiska programistycznego będziesz potrzebował zainstalować oprogramowanie lokalnego serwera.
XAMPP, MAMP i WAMP to trzy popularne opcje. Każdy z tych pakietów oprogramowania dla serwerów lokalnych zapewnia kompletne środowisko programistyczne dla twórców stron internetowych ze wszystkimi niezbędnymi komponentami (takimi jak serwer Apache, baza danych MySQL i język skryptowy PHP, w jednym pakiecie), panelem kontrolnym do zarządzania tymi komponentami i narzędziem do mzarządzanie bazą danych.
Każdy pakiet oprogramowania ma jednak swoje unikalne cechy i kluczowe różnice, dlatego ważne jest, aby wybrać taki, który spełnia Twoje specyficzne potrzeby.
Przyjrzyjmy się pokrótce każdemu z nich:
XAMPP
XAMPP
to darmowe, open-source i łatwe do zainstalowania oprogramowanie serwera WWW, które zapewnia lokalne środowisko programistyczne dla twórców stron internetowych. Jest to skrót od Apache, MariaDB, PHP i Perl, czterech głównych składników XAMPP.
Niektóre kluczowe cechy (i zalety) X
AMPP:
- Zawiera serwer WWW Apache, bazę danych MariaDB oraz języki skryptowe PHP i Perl.
- Obsługuje wiele systemów operacyjnych, w tym Windows, Mac i Linux.
- Łatwy w użyciu panel kontrolny do zarządzania komponentami serwera WWW i bazy danych.
- Możliwość zainstalowania dodatkowych komponentów, takich jak phpMyAdmin do zarządzania bazą danych.
Cons
:
- Nie tak popularny jak MAMP czy WAMP, więc wsparcie społeczności może nie być tak silne.
- Bardziej skomplikowana konfiguracja w porównaniu do MAMP lub WAMP, wymagająca większej wiedzy technicznej do zainstalowania i skonfigurowania komponentów.
XAMPP jest najlepszy dla programistów internetowych, którzy wymagają kompletnego środowiska programistycznego z wieloma komponentami i są zaznajomieni z konfiguracją i zarządzaniem tymi komponentami. Jest również najlepszy dla programistów, którzy pracują na wielu systemach operacyjnych i potrzebują rozwiązania międzyplatformowego.
MAMP
MAMP
to oprogramowanie serwera lokalnego, które zapewnia środowisko programistyczne dla twórców stron internetowych. Jest to skrót od Macintosh, Apache, MySQL i PHP, czyli czterech głównych składników MAMP.
Niektóre kluczowe cechy (i zalety) M
AMP:
- Zawiera serwer WWW Apache, bazę danych MySQL i język skryptowy PHP.
- Obsługiwany przez system operacyjny macOS, ale może być również używany dla systemu operacyjnego opartego na Windows.
- Łatwy w obsłudze panel kontrolny do zarządzania komponentami serwera WWW i bazy danych.
- Możliwość instalacji dodatkowych komponentów, takich jak phpMyAdmin do zarządzania bazą danych.
Cons
:
- Może używać tylko języka skryptowego PHP.
- Mniej komponentów w porównaniu do XAMPP, co może ograniczać potrzeby niektórych programistów.
MAMP jest najlepszy dla twórców stron internetowych, którzy pracują na systemie operacyjnym macOS.
Aby uzyskać więcej informacji na temat korzystania z tej opcji, sprawdź nasz samouczek o tym, jak rozwijać WordPress lokalnie za pomocą MAMP.
WampServer
WampServer
to lokalne oprogramowanie serwerowe, które zapewnia środowisko programistyczne dla twórców stron internetowych. Jest to skrót od Windows, Apache, MySQL i PHP, czyli czterech głównych składników WAMP.
Niektóre kluczowe cechy (i zalety) W
AMP:
- Zawiera serwer WWW Apache, bazę danych MySQL oraz język skryptowy PHP.
- Obsługuje system operacyjny Windows.
- Łatwy w użyciu panel kontrolny do zarządzania komponentami serwera WWW i bazy danych.
- Możliwość zainstalowania dodatkowych komponentów, takich jak phpMyAdmin do zarządzania bazą danych.
Cons
:
- Obsługuje tylko system Windows, więc programiści korzystający z macOS lub Linux mogą być zmuszeni do szukania gdzie indziej.
- Mniej komponentów w porównaniu do XAMPP, co może ograniczać potrzeby niektórych programistów.
WAMP jest najlepszy dla programistów internetowych, którzy pracują na systemie operacyjnym Windows i którzy wymagają kompletnego środowiska programistycznego z podstawowymi komponentami.
Aby uzyskać więcej informacji na temat tej opcji, sprawdź nasz samouczek o tym, jak rozwijać WordPress lokalnie za pomocą WAMP.
Podczas gdy XAMPP, MAMP i WAMP są doskonałym wyborem dla twórców stron internetowych, którzy szukają locjalne środowisko programistyczne, istnieją inne dostępne opcje, w tym Local by Flywheel, DesktopServer, AMPPS (Windows & MacOS), Laragon (tylko Windows) oraz (jeśli potrzebujesz pracować nad WordPressem lokalnie na więcej niż jednym komputerze) nawet instalacja i uruchomienie WordPressa z USB.
Edytor
tekstu
Innym elementem, który będzie Ci potrzebny, jest edytor tekstu do tworzenia WordPressa zaprojektowany specjalnie do pracy z językami programowania takimi jak PHP. Edytor tekstu jest niezbędny do edycji kodu i wprowadzania zmian na stronie.
Przyjrzyjmy się kilku popularnym opcjom edytorów tekstu:
Sublime
Text
Sublime Text
to popularny edytor tekstu, który jest szeroko stosowany przez programistów do kodowania i skryptów. Oferuje czysty, szybki i intuicyjny interfejs, co ułatwia pracę z dużymi bazami kodów.
Niektóre kluczowe cechy Sublime Text
:
- Podświetlanie składni i uzupełnianie kodu dla ponad 80 języków programowania
- Możliwość dostosowania schematów kolorów, przypisania klawiszy i makr
- Zaawansowane narzędzia wyszukiwania i edycji, takie jak wielokrotne zaznaczanie, edycja dzielona i edycja kolumnowa
- Błyskawiczne przełączanie między projektami dzięki systemowi ustawień specyficznych dla danego projektu
Sublime Text to świetne narzędzie dla programistów, którzy pracują nad projektami wymagającymi pisania kodu w HTML, CSS i JavaScript. Oferuje łatwe w użyciu podświetlanie składni, uzupełnianie kodu i narzędzia do edycji, które sprawiają, że proces pisania kodu jest szybki i wydajny.
Visual Studio Code
Visual Studio Code
to darmowy, open-source’owy edytor kodu opracowany przez firmę Microsoft. Oferuje on szereg funkcji i narzędzi, które pomagają programistom tworzyć i zarządzać projektami na dużą skalę.
Niektóre kluczowe cechy
Visual Studio Code:
- IntelliSense, inteligentne i zaawansowane narzędzie do uzupełniania i debugowania kodu
- Wbudowana obsługa Git i debugowanie
- Obsługuje wiele języków programowania i posiada dużą bibliotekę rozszerzeń
- Możliwość dostosowania interfejsu i przestrzeni roboczej
Aby uzyskać dodatkowe edytory tekstu, zobacz naszą listę najlepszych edytorów tekstu dla rozwoju WordPress.
Czy zaznaczyłeś wszystkie powyższe wymagania?
- Komputer spełnia wymagane specyfikacje
- Wybrane oprogramowanie serwera lokalnego
- Wybrany edytor tekstu
Świetnie!!!
W takim
razie przejdźmy do następnego kroku.
..
Instalacja lokalnego oprogramowania serwerowego
W tym przykładzie zainstalujemy XAMPP na systemie operacyjnym Windows. Użyj tego samego procesu opisanego poniżej, aby zainstalować wybrane oprogramowanie serwera lokalnego na swoim komputerze i postępuj zgodnie z instrukcjami zawartymi w pakiecie oprogramowania
:
- Pobierz XAMPP: Przejdź do oficjalnej strony internetowej XAMPP i pobierz najnowszą wersję XAMPP dla systemu Windows.
- Zainstaluj XAMPP: Kliknij dwukrotnie pobrany plik, aby rozpocząć proces instalacji. Uruchom pobrany plik instalatora i postępuj zgodnie z instrukcjami wyświetlanymi na ekranie, aby zainstalować XAMPP. Domyślnie, XAMPP zostanie zainstalowany w katalogu C:xampp.
- Uruchomienie XAMPP: Po instalacji, otwórz Panel sterowania XAMPP z menu Start lub skrótu na pulpicie. Uruchom moduły Apache i MySQL klikając na przyciski „Start” przy każdym module.
- Weryfikacja instalacji: Aby sprawdzić, czy XAMPP działa poprawnie, otwórz przeglądarkę internetową i przejdź do strony http://localhost. Powinna wyświetlić się strona powitalna XAMPP.
- Utwórz wirtualnego hosta: Aby utworzyć wirtualnego hosta, wykonaj poniższe kroki.
XAMPP spowinien być teraz zainstalowany i skonfigurowany na twoim komputerze. Jesteś gotowy, aby rozpocząć tworzenie i testowanie swoich stron internetowych lokalnie.
Uwaga: Proces instalacji XAMPP lub innego lokalnego oprogramowania serwerowego, takiego jak MAMP lub WAMP, może się nieco różnić w zależności od używanego systemu operacyjnego. W przypadku systemów operacyjnych Mac i Linux możesz postępować zgodnie z instrukcjami instalacji zamieszczonymi na stronie internetowej XAMPP.
Zobacz nasze inne tutoriale związane z XAMPP, aby uzyskać dodatkowe informacje na temat konfiguracji XAMPP, aktualizacji XAMPP, rozwiązywania problemów z XAMPP i migracji WordPressa z localhosta XAMPP do sieci.
Konfigurowanie
wirtualnego hosta Konfigurowanie
wirtualnego hosta w lokalnym środowisku programistycznym pozwala programistom uruchomić wiele stron internetowych na ich lokalnej maszynie, każda z własnym unikalnym adresem URL. Zapewnia to bardziej realistyczne środowisko testowe i ułatwia przełączanie się między różnymi projektami.
Aby skonfigurować wirtualnego hosta w lokalnym środowisku programistycznym i rozpocząć testowanie witryn, skorzystaj z poniższego przewodnika krok po kroku:
1. Otwórz plik konfiguracyjny Apache: Otwórz plik konfiguracyjny dla lokalnego oprogramowania serwera. Dla tego przykładu używamy XAMPP, więc otwórz plik konfiguracyjny Apache, zwykle znajdujący się w /etc/httpd/conf/httpd.conf lub C:xamppapacheconfhttpd.conf
.
2. Włącz wirtualny hosting: Zlokalizuj sekcję oznaczoną jako „# Virtual Hosts” i odkomentuj następującą linię, usuwając symbol hash (#) na początku linii: #Include conf/extra/httpd-vhosts.conf.
3. Skonfiguruj wirtualnego hosta: Otwórz plik konfiguracyjny wirtualnego hosta, zwykle znajdujący się w /etc/httpd/conf/extra/httpd-vhosts.conf lub C:xamppapacheconfextrahttpd-vhosts.conf.
4. Dodaj nowy wirtualny host: Dodaj nowy wirtualny host, tworząc nowy blok kodu o następującym formacie:
ServerName example.local DocumentRoot „/path/to/document/root” AllowOverride All Require all granted
Wykonaj
następujące czynności:
- Zastąp „example.local” pożądanym adresem URL dla wirtualnego hosta.
- Zastąp „/path/to/document/root” pełną ścieżką do katalogu głównego dokumentu dla wirtualnego hosta.
5. Uaktualnij plik hosts: Plik hosts mapuje nazwy domen na adresy IP. Aby wirtualny host był dostępny poprzez podany adres URL, musisz dodać wpis do pliku hosts. Plik hosts znajduje się zazwyczaj w /etc/hosts lub C:WindowsSystem32driversetchosts. Dodaj nową linię o następującym formacie: 127.0.0.1 example.local. Zastąp „example.local” adresem URL określonym w konfiguracji hosta wirtualnego. Zapisz zmiany w pliku konfiguracyjnym.
6. Zrestartuj Apache: Uruchom ponownie lokalny serwer WWW Apache, aby zastosować zmiany.
7. Przetestuj wirtualnego hosta: Przetestuj wirtualnego hosta odwiedzając adres URL w przeglądarce internetowej. Przeglądarka powinna wyświetlić zawartość katalogu głównego dokumentu dla hosta wirtualnego.
Tworzenie bazy danych dla lokalnej instalacji WordPress
Kolejnym krokiem przed lokalnym skonfigurowaniem projektu WordPress jest utworzenie bazy danych dla lokalnego środowiska programistycznego.
Wykonaj poniższe instrukcje krok po kroku, aby utworzyć bazę danych w XAMPP:
1. Otwórz Panel sterowania X
AMPP:
Otwórz Panel sterowania XAMPP z menu Start lub skrótu na pulpicie. Upewnij się, że moduły Apache i MySQL są uruchomione.
2. Uzyskaj dostęp do phpMyAdmin: Aby uzyskać dostęp do phpMyAdmin, otwórz przeglądarkę internetową i przejdź do http://localhost/phpmyadmin. W ten sposób otworzyszen interfejs phpMyAdmin w przeglądarce.
3. Utwórz nową bazę danych: W interfejsie phpMyAdmin kliknij na zakładkę „Bazy danych”. W sekcji „Utwórz bazę danych” wprowadź nazwę dla swojej nowej bazy danych i wybierz kolację „utf8mb4_general_ci”. Następnie kliknij na przycisk „Utwórz”.
4. Utwórz nowego użytkownika: Aby utworzyć nowego użytkownika dla bazy danych, kliknij zakładkę „Użytkownicy”, a następnie przycisk „Dodaj użytkownika”. W formularzu „Dodaj użytkownika” wprowadź nazwę użytkownika i hasło dla nowego użytkownika oraz wybierz „Local” jako host. Upewnij się, że przyznałeś użytkownikowi wszystkie uprawnienia, zaznaczając pole wyboru „Grant all privileges on database”. Na koniec kliknij na przycisk „Go”.
5. Zapisz swoje dane: Zapisz lub zapisz swoją nazwę bazy danych, nazwę użytkownika i hasło. Będą one potrzebne do późniejszego połączenia bazy danych z WordPressem.
Po wykonaniu powyższych kroków, z powodzeniem utworzysz bazę danych dla swojej lokalnej instalacji WordPress i lokalnego środowiska programistycznego.
Możesz teraz użyć tej bazy danych do przechowywania i zarządzania danymi podczas rozwijania i testowania witryny WordPress lokalnie.
Czy wykonałeś wszystkie powyższe kroki?
- Zainstalowane oprogramowanie serwera lokalnego
- Skonfigurować wirtualnego hosta
- Utworzyłeś bazę danych
Świetnie!!! W takim razie przejdźmy do kolejnego kroku.
..
Instalacja WordPressa lok
alnie
Teraz, gdy przygotowaliśmy nasze lokalne środowisko, kolejnym krokiem jest pobranie, zainstalowanie i skonfigurowanie WordPressa
.
Pobieranie i instalacja WordPressa na lokalnym serwerze
Wykonaj poniższe kroki, aby zakończyć ten proces:
- Odwiedź stronę internetową WordPress: Przejdź do oficjalnej strony WordPress.org i kliknij przycisk „Pobierz WordPress”, aby pobrać najnowszą wersję WordPressa.
- Wyodrębnij archiwum: Pobranie WordPressa będzie miało postać skompresowanego pliku ZIP. Wyodrębnij zawartość archiwum do katalogu na swoim komputerze.
- Przenieś wyodrębnione pliki na swój lokalny serwer: Przenieś zawartość wyodrębnionego katalogu do katalogu głównego swojego lokalnego serwera. Na przykład, jeśli używasz XAMPP, jest to zazwyczaj C:xampphtdocs w systemie Windows lub /Applications/XAMPP/htdocs w systemie macOS.
- Utwórz bazę danych: (Uwaga: jeśli podążałeś za tym krokiem, ten krok powinien być już wykonany) Przed zainstalowaniem WordPressa, będziesz musiał stworzyć bazę danych. Możesz to zrobić za pomocą narzędzia takiego jak phpMyAdmin, które jest dołączone do większości oprogramowania serwerów lokalnych, takich jak XAMPP i MAMP.
- Rozpocznij instalację: Otwórz przeglądarkę internetową i przejdź na stronę http://localhost/wordpress (lub równoważny adres URL dla Twojego lokalnego serwera). Spowoduje to rozpoczęcie procesu instalacji WordPressa.
- Wybierz język: Na pierwszym ekranie wybierz preferowany język i kliknij przycisk „Kontynuuj”.
- Wypełnij informacje o bazie danych: Na następnym ekranie wypełnij informacje o bazie danych, które utworzyłeś w kroku 4. Obejmuje to nazwę bazy danych, nazwę użytkownika bazy danych i hasło bazy danych.
- Wypełnij informacje o stronie: Na następnym ekranie wypełnij informacje dotyczące Twojej lokalnej witryny WordPress. Obejmuje to tytuł witryny, nazwę użytkownika, hasło i adres e-mail.
- Uruchom instalację: Po wypełnieniu wszystkich informacji, kliknij przycisk „Zainstaluj WordPress”, aby uruchomić instalację.
- Zaloguj się do swojej witryny: Po zakończeniu instalacji zaloguj się do swojej lokalnej witryny WordPress, używając utworzonej nazwy użytkownika i hasła w kroku 8, aby rozpocząć dostosowywanie i rozwijanie swojej lokalnej witryny.
Teraz udało Ci się pobrać i zainstalować WordPressa.
Możesz teraz zacząć dostosowywać i rozwijać swoją witrynę lokalnie, ze wszystkimi korzyściami lokalnego środowiska programistycznego, przed wdrożeniem witryny do serwera na żywo.
Konfiguracja pliku wp-config.php
Plik wp-config.php jest kluczowym elementem konfiguracji lokalnej instalacji WordPressa i lokalnego środowiska programistycznego. Ten plik zawiera ustawienia konfiguracyjne, które kontrolują sposób interakcji WordPressa z bazą danych i inne ważne ustawienia.
Jeśli wykonałeś powyższe instrukcje instalacji, twoje poświadczenia bazy danych zostaną automatycznie dodane do pliku wp-config.php.
Jeśli z jakiegoś powodu musisz ręcznie skonfigurować plik wp-config.php, wykonaj poniższe instrukcje:
1. Utwórz plik wp-config.php: Jeśli Twoja lokalna instalacja WordPress nie posiada jeszcze pliku wp-config.php, możesz go utworzyć, kopiując plik wp-config-sample.php i zmieniając jego nazwę na wp-config.php.
2. Zaktualizuj poświadczenia bazy danych: Otwórz plik wp-config.php i zaktualizuj następujące linie odpowiednimi informacjami:
define( 'DB_NAME’, 'database_name’ ); define( 'DB_USER’, 'database_user’ ); define( 'DB_PASSWORD’, 'database_password’ ); define( 'DB_HOST’, 'localhost’ );
Zastąp database_name, database_user, oraz database_password wartościami, których użyłeś podczas tworzenia bazy danych i użytkownika w poprzednim kroku.
3. Ustaw klucze bezpieczeństwa WordPress: Klucze bezpieczeństwa WordPress dodają dodatkową warstwę bezpieczeństwa do Twojej witryny poprzez szyfrowanie informacji przechowywanych w plikach cookie. Możesz wygenerować zestaw kluczy bezpieczeństwa na oficjalnej stronie WordPress. Skopiuj wygenerowane klucze i wklej je do swojego pliku wp-config.php, zastępując klucze placeholder, które już tam są.
4. Włącz debugowanie: W przypadku rozwoju lokalnego warto włączyć debugowanie w WordPressie. Zapewni to bardziej szczegółowe komunikaty o błędach i ostrzeżeniach, które mogą pomóc w rozwiązywaniu problemów z witryną. Aby włączyć debugowanie, dodaj następującą linię do swojego pliku wp-config.php:
define( 'WP_DEBUG’, true );
5. Zapisz zmiany: Po wprowadzeniu zmian do pliku wp-config.php, zapisz plik i zamknij go.
Pomyślne skonfigurowanie pliku wp-config.php zapewni, że lokalnie zainstalowana witryna WordPress będzie w stanie połączyć się z bazą danych, będzie bezpieczna i dostarczy pomocnych informacji o debugowaniu, gdy będziesz rozwijać i testować swoją witrynę lokalnie.
Importowanie witryny WordPress na żywo do środowiska lokalnego
Wykonaj poniższe kroki, jeśli musisz zaimportować witrynę WordPress na żywo do swojego środowiska lokalnego:
Eksportowanie bazy danych
witryny na żywo
Aby wyeksportować bazę danych witryny na żywo, będziesz musiał mieć dostęp do serwera witryny
na żywo.
Oto kroki, aby wyeksportować bazę danych witryny na żywo (uwaga: różne środowiska serwerowe wykonają to inaczej, ale większość powinna wykonać podobny proces):
- Zaloguj się do panelu sterowania swojego serwera live.
- Uzyskaj dostęp do bazy danych: Pierwszym krokiem jest uzyskanie dostępu do bazy danych witryny na żywo. Możesz to zrobić za pomocą narzędzia takiego jak phpMyAdmin, które jest często dostarczane przez dostawcę usług hostingowych. Poszukaj sekcji o nazwie „Bazy danych” i kliknij „phpMyAdmin”.
- Wybierz bazę danych: Po zalogowaniu się do phpMyAdmin, wybierz bazę danych dla swojej witryny na żywo z panelu po lewej stronie.</li>
- Eksport bazy danych: Kliknij przycisk „Eksportuj”, aby rozpocząć proces eksportu.
- Wybierz format eksportu: Na ekranie eksportu wybierz metodę eksportu „Quick”, wybierz format „SQL” i upewnij się, że opcje „Struktura” i „Dane” są wybrane.
- Pobierz plik eksportu: Kliknij przycisk „Go”, aby pobrać plik eksportu na swój komputer.
Importowanie bazy danych na serwer lokalny
Aby zaimportować bazę danych witryny live na serwer lokalny, upewnij się, że wybrane oprogramowanie serwera lokalnego jest już zainstalowane na Twoim komputerze.
Oto kroki do importu bazy danych strony live
na lokalny serwer:
- Otwórz phpMyAdmin w swoim lokalnym oprogramowaniu serwerowym: Zaloguj się do phpMyAdmin dla swojego lokalnego serwera i wybierz bazę danych, którą utworzyłeś dla swojej lokalnej instalacji WordPress.
- Zaimportuj bazę danych: Kliknij przycisk „Importuj”, aby zaimportować dane z pliku eksportu, który właśnie pobrałeś.
- Wybierz plik importu: Na ekranie importu kliknij przycisk „Wybierz plik”, wybierz plik eksportu, który właśnie pobrałeś, i kliknij przycisk „Idź”, aby rozpocząć proces importu.
Zastępowanie adresów URL w bazie
danych
Po zaimportowaniu bazy danych witryny na żywo, będziesz musiał zastąpić adresy URL w bazie danych, aby dopasować je do lokalnego środowiska programistycznego.
Oto kroki, aby zastąpić adresy URL w bazie danych:
1. Otwórz phpMyAdmin w lokalnym oprogramowaniu serwera.
2. Wybierz importowaną bazę danych z lewego panelu.
3. Kliknij zakładkę „SQL”.
4. Wprowadź następujące zapytanie w obszarze tekstowym
: UPDATE wp_options SET option_value = replace(option_value, 'http://www.livesite.com’, 'http://local.livesite.com’) WHERE option_name = 'home’ OR option_name = 'siteurl’; UPDATE wp_posts SET guid = replace(guid, 'http://www.livesite.com’,’http://local.livesite.com’); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.livesite.com’, 'http://local.livesite.com’);
5. Zamień „http://www.livesite.com” na adres URL swojej witryny na żywo, a „http://local.livesite.com” na adres URL swojego lokalnego środowiska programistycznego
.
6. Kliknij na przycisk „Go”, aby wykonać zapytanie.
Przesyłanie plików witryny live do
środowiska lokalnego
Aby przesłać pliki witryny live do środowiska lokalnego, musisz mieć dostęp FTP do serwera witryny
live.
Wykonaj poniższe kroki, aby przesłać pliki witryny live do
środowiska lokalnego:
- Połącz się z serwerem swojej witryny live za pomocą klienta FTP, np. FileZilla.
- Przejdź do katalogu głównego witryny live na serwerze.
- Pobierz wszystkie pliki na swój lokalny komputer.
- Umieść pobrane pliki w katalogu głównym swojego lokalnego środowiska programistycznego, który zazwyczaj znajduje się w folderze „htdocs” lub „www” w XAMPP lub innym lokalnym oprogramowaniu serwerowym.
Uwagi:
- Jeśli masz już instalację WordPress, powyższy folder nie będzie pusty i zostaniesz poproszony o zastąpienie istniejących plików i katalogów, więc zastąp wszystkie pliki z wyjątkiem pliku wp-config.php, aby zachować te same konfiguracje, w tym połączone bazy danych, które zostały zalane danymi witryny na żywo.
- Przed przesłaniem plików witryny live do środowiska lokalnego, może być konieczna zmiana uprawnień plików, aby pliki mogły być zapisywane przez lokalną soprogramowanie erver.
- Pamiętaj również, aby przetestować lokalną kopię zapasową WordPressa przed wprowadzeniem jakichkolwiek zmian.
To jest to!!! Teraz z powodzeniem zaimportowałeś swoją witrynę na żywo do swojej lokalnej instalacji WordPress i lokalnego środowiska programistycznego.
Rozwijanie i testowanie na lokalnej witrynie WordPress
W
końcu jesteś gotowy, aby rozwijać i testować swoją witrynę lokalnie przy użyciu tych samych danych, co twoja witryna na żywo, dając ci prawdziwe środowisko do testowania i rozwoju.
Przejdźmy przez ten proces:
Wprowadzanie zmian i testowanie
- Zaloguj się do lokalnej witryny WordPress: Otwórz swoją lokalną witrynę WordPress w przeglądarce internetowej i zaloguj się do pulpitu nawigacyjnego WordPress, używając swoich poświadczeń administratora.
- Wprowadzanie zmian w witrynie: Możesz wprowadzić zmiany w swojej lokalnej witrynie WordPress, edytując motywy, wtyczki lub niestandardowy kod. Wystarczy uzyskać dostęp do tych elementów z pulpitu nawigacyjnego WordPress.
- Przetestuj zmiany: Po wprowadzeniu zmian w lokalnej witrynie WordPress ważne jest przetestowanie zmian, aby upewnić się, że działają zgodnie z oczekiwaniami. Możesz przetestować zmiany, odwiedzając front-end swojej witryny i sprawdzając, czy zmiany weszły w życie.
Debugowanie
- Użyj trybu debugowania: WordPress ma wbudowany tryb debugowania, który ułatwia identyfikację i rozwiązywanie problemów w Twojej witrynie. Aby włączyć tryb debugowania, musisz dodać następujący kod do swojego pliku wp-config.php: define( 'WP_DEBUG’, true );.
- Sprawdź dzienniki błędów: Jeśli masz problemy z lokalną witryną WordPress, możesz sprawdzić dzienniki błędów, aby sprawdzić, czy istnieją komunikaty o błędach lub ostrzeżenia, które mogą pomóc w identyfikacji problemu. Dzienniki błędów można znaleźć w pliku dziennika debugowania WordPress, który znajduje się w katalogu wp-content.
- Użyj narzędzi do debugowania: Istnieje wiele narzędzi debugowania i wtyczek dostępnych dla WordPressa, które mogą pomóc w identyfikacji i rozwiązaniu problemów w Twojej witrynie. Na przykład wtyczka Query Monitor dostarcza szczegółowych informacji o zapytaniach do bazy danych, użyciu wtyczek i nie tylko. Zobacz ten samouczek, aby uzyskać pomoc w debugowaniu WordPressa: Debugowanie WordPressa: How To Use WP_Debug
Testowanie różnych wtyczek i
motywów Instalowanie, aktywowanie i testowanie wtyczek i motywów w lokalnej witrynie WordPress działa dokładnie w taki sam sposób, jak w każdej innej zwykłej witrynie
WordPress.
Upewnij się więc, że wykonasz następujące czynności, gdy jesteś w trybie testowym:
- Zainstaluj wtyczki: Zainstaluj wtyczki na swojej lokalnej witrynie WordPress, aby dodać nowe cechy lub funkcjonalność do swojej witryny. Aby zainstalować wtyczkę, zaloguj się do pulpitu nawigacyjnego WordPress, przejdź do sekcji Wtyczki i kliknij przycisk Dodaj nowy.
- Aktywuj wtyczki: Aktywuj testowaną wtyczkę po jej zainstalowaniu, aby użyć jej w swojej witrynie. Aby aktywować wtyczkę, przejdź do sekcji Wtyczki na desce rozdzielczej WordPress i kliknij przycisk Aktywuj obok wtyczki, której chcesz użyć.
- Testowanie wtyczek: Po aktywacji wtyczki ważne jest, aby przetestować ją, aby upewnić się, że działa zgodnie z oczekiwaniami. Przetestuj wtyczki, odwiedzając front-end swojej witryny i sprawdzając, czy wtyczka zaczęła działać.
- Zainstaluj motywy: Zainstaluj motywy na swojej lokalnej witrynie WordPress, aby zmienić wygląd swojej witryny. Aby zainstalować motyw, zaloguj się do pulpitu nawigacyjnego WordPress, przejdź do sekcji Wygląd i kliknij przycisk Motywy.
- Aktywuj motywy: Aktywuj motyw po jego zainstalowaniu, aby zmienić wygląd swojej witryny. Aby aktywować. motyw, przejdź do sekcji Wygląd w pulpicie nawigacyjnym WordPress i kliknij przycisk Aktywuj obok motywu, którego chcesz użyć.
- Testowanie motywów: Po aktywacji motywu ważne jest, aby przetestować motyw, aby upewnić się, że działa zgodnie z oczekiwaniami. Przetestuj motywy, odwiedzając front-end swojej witryny i sprawdzając, czy motyw zaczął działać.
Czy dokonałeś wszystkich potrzebnych zmian, usunąłeś błędy i przetestowałeś różne wtyczki i motywy na swojej lokalnej stronie?
Świetnie!!! Teraz jesteś gotowy, aby Twoja lokalna witryna WordPress stała się żywą.
Deploying Local WordPress Site to Live Server
Ostatnim krokiem w tym procesie jest wyeksportowanie wszystkich plików lokalnego WordPressa i bazy danych do środowiska hostingu na żywo i upewnienie się, że wszystkie zmiany w witrynie, konfiguracje i adresy URL działają w witrynie na żywo.
Eksportowanie bazy danych witryny lokalnej
Wykonaj poniższe kroki, aby wyeksportować lokalną witrynę WordPress do serwera na żywo
:
- Zaloguj się do bazy danych lokalnej witryny za pomocą PHPMyAdmin.
- Wybierz bazę danych, którą chcesz wyeksportować.
- Przejdź do zakładki „Eksport”.
- Wybierz metodę eksportu „Quick”.
- Wybierz format „SQL”.
- Kliknij „Idź”, aby pobrać plik SQL na swój komputer.
Importowanie bazy danych do serwera live
Wykonaj poniższe kroki, aby zaimportować plik eksportu lokalnej bazy danych WordPress do witryny live
:
- Zaloguj się do bazy danych serwera live za pomocą PHPMyAdmin.
- Utwórz nową bazę danych dla witryny na żywo.
- Przejdź do nowej bazy danych i wybierz zakładkę „Importuj”.
- Wybierz wyeksportowany plik SQL z Twojej lokalnej strony.
- Kliknij „Go”, aby zaimportować bazę danych.
Teraz, gdy już zmigrowałeś bazę danych z witryny lokalnej do witryny live, zróbmy to samo z plikami witryny.
Przesyłanie plików witryny lokalnej do serwera na żywo
Wykonaj poniższe kroki, aby przesłać pliki lokalnej witryny WordPress do witryny na żywo
:
- Przygotuj pliki: Przed przesłaniem plików witryny lokalnej na serwer, warto przejrzeć i oczyścić pliki. Może to obejmować usunięcie wszelkich niepotrzebnych plików, takich jak kopie zapasowe lub pliki testowe, aby zminimalizować ilość przesyłanych danych.
- Podłączenie do serwera: Możesz połączyć się z serwerem za pomocą różnych metod, takich jak FTP lub SFTP. Aby połączyć się z serwerem, będziesz musiał użyć oprogramowania klienckiego, takiego jak FileZilla. Aby się połączyć, będziesz musiał podać host serwera, nazwę użytkownika i hasło.
- Prześlij pliki: Po połączeniu z serwerem możesz przesłać pliki lokalnej witryny na serwer. Możesz przesłać pliki na kilka sposobów, w tym przesłać pojedyncze pliki lub przesłać cały folder witryny lokalnej. Przejdź do katalogu głównego witryny na żywo na serwerze. Prześlij wszystkie pliki witryny lokalnej do katalogu witryny na żywo na serwerze i zastąp istniejące pliki, jeśli zostanie wyświetlony monit.
- Zaktualizuj informacje o bazie danych: Po przesłaniu plików na serwer będziesz musiał zaktualizować informacje o bazie danych w pliku wp-config.php, aby odzwierciedlić informacje o bazie danych witryny na żywo. Otwórz plik wp-config.php w edytorze tekstu i zaktualizuj nazwę bazy danych, nazwę użytkownika i hasło, aby dopasować je do bazy danych na żywo.
- Zaktualizuj adresy URL w bazie danych: Zobacz sekcję poniżej.
- Przetestuj witrynę: Po przesłaniu plików lokalnej strony do thSerwer, to dobry pomysł, aby przetestować witrynę, aby upewnić się, że wszystko działa poprawnie. Może to obejmować testowanie funkcjonalności strony, linków i obrazów, aby upewnić się, że działają zgodnie z oczekiwaniami.
Aktualizacja adresów URL w bazie danych
Możesz aktualizować adresy URL w bazie danych za pomocą edytora tekstu lub pracując bezpośrednio w bazie danych (przed wprowadzeniem zmian upewnij się, że Twoja baza danych ma pełną kopię zapasową)
.
Aktualizacja adresów URL za pomocą edytora tekstu
Wykonaj poniższe kroki, aby zaktualizować adresy URL w bazie danych za pomocą edytora tekstu.
- Wyeksportuj bazę danych: Przed aktualizacją adresów URL w bazie danych, będziesz musiał wyeksportować bazę danych. Użyj swojego narzędzia do zarządzania bazą danych (np. phpMyAdmin).
- Znajdź i zamień adresy URL: Po wyeksportowaniu bazy danych, będziesz musiał znaleźć i zastąpić adresy URL w bazie danych. Możesz to zrobić za pomocą edytora tekstu, takiego jak Sublime lub Visual Studio Code. Wyszukaj i zastąp adresy URL i upewnij się, że zastępujesz adresy URL starannie i dokładnie, w tym adresy URL w danych serializowanych.
- Zaimportuj bazę danych: Po aktualizacji adresów URL w bazie danych, będziesz musiał zaimportować bazę danych z powrotem do lokalnego środowiska programistycznego. Możesz zaimportować bazę danych za pomocą narzędzia do zarządzania bazą danych, takiego jak phpMyAdmin.
- Przetestuj stronę: Po zaimportowaniu zaktualizowanej bazy danych dobrze jest przetestować witrynę, aby upewnić się, że wszystko działa poprawnie. Może to obejmować testowanie funkcjonalności strony, linków i obrazów, aby upewnić się, że działają zgodnie z oczekiwaniami.
Aktualizacja adresów URL w bazie danych
Wykonaj poniższe kroki, aby zaktualizować adresy URL bezpośrednio w bazie danych:
1. Zaloguj się do bazy danych strony live za pomocą PHPMyAdmin.
2. Wybierz bazę danych strony live.
3. Przejdź do zakładki „SQL”.
4. Wykonaj następujące zapytanie SQL aby zaktualiz
ować adresy URL: UPDATE wp_options SET option_value = replace(option_value, 'http://old-url’, 'http://new-url’) WHERE option_name = 'home’ OR option_name = 'siteurl’; UPDATE wp_posts SET guid = replace(guid, 'http://old-url’,’http://new-url’); UPDATE wp_posts SET post_content = replace(post_content, 'http://old-url’, 'http://new-url’);
Zastąp „old-url” adresem URL strony lokalnej, a „new-url” adresem URL strony na żywo
.
5. Kliknij „Go”, aby uruchomić zapytanie.
6. Spowoduje to aktualizację wszystkich odniesień do adresu URL lokalnej strony z adresem URL strony na żywo w bazie danych, zapewniając, że wszystkie linki i obrazy na stronie na żywo działają poprawnie
.
Jeśli prawidłowo wykonałeś powyższe kroki, adresy URL w bazie danych powinny zostać pomyślnie zaktualizowane. Po tych krokach, Twoja lokalna witryna WordPress powinna być teraz w pełni funkcjonalna na serwerze na żywo. Upewnij się, że dokładnie przetestujesz witrynę na żywo, aby upewnić się, że wszystkie funkcje działają poprawnie, i dokonaj wszelkich niezbędnych zmian, aby zapewnić płynne przejście z lokalnego środowiska programistycznego na serwer na żywo.
Lokalny rozwój vs środowisko inscenizacyjne Webhost
Podczas gdy lokalny rozwój WordPressa zapewnia bezpieczne i wydajne środowisko do budowania, edytowania i testowania witryn WordPress, możesz zdecydować się na pracę w środowisku inscenizacyjnym webhost zamiast (tutaj jest kilka dobrych powodów, dla których możesz nie chcieć rozwijać WordPressa lokalnie).
Zarówno lokalne środowiska programistyczne, jak i środowiska inscenizacyjne webhostów mają jednak swoje plusy i minusy.
Oto krótki przegląd zalet i wad korzystania z lokalnego rozwoju WordPressa w porównaniu z webhostem.środowisko inscenizacji hosta:
Zalety lokalnego środowiska programistycznego
- Łatwe w użyciu: Lokalne środowiska programistyczne są łatwe w użyciu, nawet dla początkujących programistów.
- Elastyczność: Masz pełną kontrolę nad swoim lokalnym środowiskiem programistycznym, więc możesz je skonfigurować jak tylko chcesz.
- Testowanie wszelkich zmian: Dzięki lokalnemu środowisku programistycznemu możesz przetestować wszelkie zmiany, które wprowadzisz w swojej witrynie, bez wpływu na wersję na żywo.
Wady lokalnego
środowiska programistycznego
- Nie jest to środowisko rzeczywiste: Lokalne środowisko programistyczne nie jest środowiskiem na żywo, więc nie możesz przetestować swojej witryny z danymi na żywo.
- Ograniczone zasoby: Twoja lokalna maszyna może mieć ograniczone zasoby, takie jak pamięć i moc obliczeniowa, co może mieć wpływ na wydajność witryny.
- Nie jest to prawdziwa reprezentacja: Lokalne środowisko programistyczne może nie reprezentować dokładnie środowiska serwera na żywo, więc testowanie może nie być w 100% dokładne.
Zalety środowiska testowego Webhost
- Środowisko na żywo: Środowisko inscenizacyjne webhosta jest środowiskiem na żywo, więc możesz testować swoją stronę z danymi na żywo.
- Dokładniejsze testowanie: Środowisko inscenizacji webhosta jest bardziej dokładną reprezentacją środowiska serwera na żywo, więc testowanie jest bardziej wiarygodne.
- Więcej zasobów: Środowisko inscenizacyjne webhosta ma zazwyczaj więcej zasobów dostępnych niż lokalne środowisko programistyczne, więc wydajność twojej strony będzie lepsza.
Wady
środowiska testowego hosta
- Koszt: Konfiguracja środowiska testowego webhosta może być kosztowna, ponieważ musisz zapłacić za hosting i nazwę domeny.
- Nie tak szybko: Środowisko inscenizacyjne webhost nie jest tak szybkie jak lokalne środowisko programistyczne, ponieważ działa na zdalnym serwerze.
Dla mniejszych projektów, lokalne środowisko programistyczne jest świetną opcją, ponieważ jest darmowe i łatwe w użyciu. Dla większych projektów, jednakże, środowisko inscenizacji webhost może być lepszą opcją, ponieważ jest to środowisko na żywo i zapewnia bardziej dokładne testy.
Ostatecznie, wybór pomiędzy tymi dwoma metodami będzie zależał od Twoich indywidualnych potrzeb, preferencji i opcji hostingowych.
Uwaga: Zalecamy unikanie hostingu współdzielonego i hostingu na naszym planie Quantum zamiast dla podstawowych witryn WordPress, ale jeśli masz powody, aby wybrać hosting współdzielony, to sprawdź nasz artykuł o tym, jak uruchomić lokalny rozwój WordPress na hostingu współdzielonym.
Wszystkie plany hostingowe WPMU DEV (z wyjątkiem Quantum) zawierają środowisko inscenizacji. Zapoznaj się z naszą dokumentacją dotyczącą inscenizacji, aby uzyskać więcej szczegółów na temat korzyści z używania środowiska inscenizacji do rozwijania i testowania witryn WordPress.