Local webserver mac os

Setting up a local web server on macOS 10.15 “Catalina”

Here is my definitive guide to getting a local web server running on macOS 10.15 “Catalina”. This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip only contains instructions for configuring the Apache server, PHP module, and Perl module. I have another User Tip for installing and configuring MySQL and email servers.

Note: This user tip is specific to macOS 10.15 “Catalina”. Pay attention to your OS version. There have been significant changes since earlier versions of macOS. Another note: These instructions apply to the client versions of OS X, not Server. Server does a few specific tricks really well and is a good choice for those. For things like database, web, and mail services, I have found it easier to just setup the client OS version manually.

  1. Basic understanding of Terminal.app and how to run command-line programs.
  2. Basic understanding of web servers.
  3. Basic usage of vi. You can substitute nano if you want.

Optional: Xcode is required for adding PHP modules.

Lines in bold are what you will have to type in. Lines in bold courier should be typed at the Terminal.Replace with your short user name.

Here goes. Enjoy!

To get started, edit the Apache configuration file as root:

sudo vi /etc/apache2/httpd.conf

Enable PHP by uncommenting line 186, changing:

#LoadModule php7_module libexec/apache2/libphp7.so

LoadModule php7_module libexec/apache2/libphp7.so

(If you aren’t familiar with vi, go to line 186 by typing «186G» (without the quotes). Then just press ‘x’ over the ‘#’ character to delete it. Then type ‘:w!’ to save, or just ‘ZZ’ to save and quit. Don’t do that yet though. More changes are still needed.)

If you want to run Perl scripts, you will have to do something similar:

Enable Perl by uncommenting line 187, changing:

#LoadModule perl_module libexec/apache2/mod_perl.so

LoadModule perl_module libexec/apache2/mod_perl.so

Enable personal websites by uncommenting the following at line 183:

#LoadModule userdir_module libexec/apache2/mod_userdir.so

LoadModule userdir_module libexec/apache2/mod_userdir.so

and do the same at line 520:

Now save and quit.

Open the file you just enabled above with:

sudo vi /etc/apache2/extra/httpd-userdir.conf

and uncomment the following at line 16:

Lion and later versions no longer create personal web sites by default. If you already had a Sites folder in Snow Leopard, it should still be there. To create one manually, enter the following:

Источник

Setting up a local web server on macOS 10.14 “Mojave”

Here is my definitive guide to getting a local web server running on macOS 10.14 “Mojave”. This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip only contains instructions for configuring the Apache server, PHP module, and Perl module. I have another User Tip for installing and configuring MySQL and email servers.

Читайте также:  Hidetoolz windows 10 64 bit

Note: This user tip is specific to macOS 10.14 “Mojave”. Pay attention to your OS version. There have been significant changes since earlier versions of macOS. Another note: These instructions apply to the client versions of OS X, not Server. Server does a few specific tricks really well and is a good choice for those. For things like database, web, and mail services, I have found it easier to just setup the client OS version manually.

  1. Basic understanding of Terminal.app and how to run command-line programs.
  2. Basic understanding of web servers.
  3. Basic usage of vi. You can substitute nano if you want.

Optional: Xcode is required for adding PHP modules.

Lines in bold are what you will have to type in. Lines in bold courier should be typed at the Terminal.Replace with your short user name.

Here goes. Enjoy!

To get started, edit the Apache configuration file as root:

sudo vi /etc/apache2/httpd.conf

Enable PHP by uncommenting line 177, changing:

#LoadModule php7_module libexec/apache2/libphp7.so

LoadModule php7_module libexec/apache2/libphp7.so

(If you aren’t familiar with vi, go to line 177 by typing «177G» (without the quotes). Then just press ‘x’ over the ‘#’ character to delete it. Then type ‘:w!’ to save, or just ‘ZZ’ to save and quit. Don’t do that yet though. More changes are still needed.)

If you want to run Perl scripts, you will have to do something similar:

Enable Perl by uncommenting line 178, changing:

#LoadModule perl_module libexec/apache2/mod_perl.so

LoadModule perl_module libexec/apache2/mod_perl.so

Enable personal websites by uncommenting the following at line 174:

#LoadModule userdir_module libexec/apache2/mod_userdir.so

LoadModule userdir_module libexec/apache2/mod_userdir.so

and do the same at line 511:

Now save and quit.

Open the file you just enabled above with:

sudo vi /etc/apache2/extra/httpd-userdir.conf

and uncomment the following at line 16:

Lion and later versions no longer create personal web sites by default. If you already had a Sites folder in Snow Leopard, it should still be there. To create one manually, enter the following:

Источник

Setting up a local web server on macOS 10.13 "High Sierra"

Here is my definitive guide to getting a local web server running on macOS 10.13 “High Sierra”. This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip only contains instructions for configuring the Apache server, PHP module, and Perl module. I have another User Tip for installing and configuring MySQL and email servers.

Note: This user tip is specific to macOS 10.13 “High Sierra”. Pay attention to your OS version. There have been significant changes since earlier versions of macOS. Another note: These instructions apply to the client versions of OS X, not Server. Server does a few specific tricks really well and is a good choice for those. For things like database, web, and mail services, I have found it easier to just setup the client OS version manually.

  1. Basic understanding of Terminal.app and how to run command-line programs.
  2. Basic understanding of web servers.
  3. Basic usage of vi. You can substitute nano if you want.
Читайте также:  Как правильно установить linux mint рядом с windows 10

Xcode is required for adding PHP modules.

Lines in bold are what you will have to type in. Lines in bold courier should be typed at the Terminal.

Replace with your short user name.

Here goes. Enjoy!

To get started, edit the Apache configuration file as root:

sudo vi /etc/apache2/httpd.conf

Enable PHP by uncommenting line 177, changing:

#LoadModule php7_module libexec/apache2/libphp7.so

LoadModule php7_module libexec/apache2/libphp7.so

(If you aren’t familiar with vi, go to line 177 by typing «176G» (without the quotes). Then just press ‘x’ over the ‘#’ character to delete it. Then type ‘:w!’ to save, or just ‘ZZ’ to save and quit. Don’t do that yet though. More changes are still needed.)

If you want to run Perl scripts, you will have to do something similar:

Enable Perl by uncommenting line 178, changing:

#LoadModule perl_module libexec/apache2/mod_perl.so

LoadModule perl_module libexec/apache2/mod_perl.so

Enable personal websites by uncommenting the following at line 174:

#LoadModule userdir_module libexec/apache2/mod_userdir.so

LoadModule userdir_module libexec/apache2/mod_userdir.so

and do the same at line 511:

Include /private/etc/apache2/extra/httpd-userdir.confNow save and quit.

Open the file You just enabled above with:

sudo vi /etc/apache2/extra/httpd-userdir.conf

and uncomment the following at line 16:

Lion and later versions no longer create personal web sites by default. If you already had a Sites folder in Snow Leopard, it should still be there. To create one manually, enter the following:

Источник

Устанавливаем веб-сервер на Mac OS

Инструкция по установке локального веб-сервера на Mac OS.

Далее ниже будем настраивать веб-сервер самостоятельно, без использования сторонних программ. Благо Mac OS является UNIX системой и настройка веб-сервера почти не отличается от Linux серверов.

Для установки веб-сервера можно воспользоваться готовыми решениями. Например, MAMP PRO. Но если хочется hardcor-а или не хочется платить за готовые решения, то это статья для вас.

Ставим менеджер пакетов для Mac OS

Ставим apache на Mac OS

Работаем через командную строку, но правки в файлах намного быстрее делать через сторонние редакторы, например, Sublime Text.

Устанавливаем apache

Перенастроим дефолтный конфигурационный файл:

1. Меняем директорию для сайтов

2. Меняем порт

Теперь сможем заходить на локальные сайты без указания порта

3. Меняем директиву AllowOverride

Обяжем Apache использовать файлы .htaccess.

4. Раскомментируем строку mod_rewrite

5. Поменяем стандартного пользователя

на нашего в системе и меняем его группу на stuff

Пользователь группы может быть другой. Для того чтобы это узнать, открываем свойство любой папки и смотрим что там указано. В примере ниже указан пользователь everyone.

В этом случае в строке указываем именного этого пользователя:

6. Изменим ServerName

Сохраняем файл, но не закрываем, скоро он снова понадобится.

Ставим последнюю версию PHP на Mac OS

Вернемся к файлу настроек апача и сообщим ему, чтобы тот использовал наш PHP. Файл:

В нем переходим к разделу загрузки модулей, видим там

Добавляем после этого

Также заменяем в этом файле

DirectoryIndex index.php index.html

Сохраняем, но опять не закрываем файл, он понадобится и дальше.

Запустить сервис PHP

Посмотреть все сервисы

Настройки для PHP указанной выше версии будут здесь:

После изменения обязательно надо перегрузить все сервисы (не только PHP)

Устанавливаем PostgreSQL на Mac OS

Устанавливаем MySQL на Mac OS

Для управления базой данных через веб-интерфейс также можно установить phpMyAdmin:

Или использовать сторонние программы, типа Sequel Pro

Если был установлен phpmyadmin, то допишем в файл:

Если после этого сразу зайти в phpmyadmin или через любое другое приложение, будет ошибка:

mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client

В MySQL 8 изменили аутентификацию с mysql_native_password на caching_sha2_password, как на более безопасную. Если мы хотим входить как и раньше, то внесем изменения.

Читайте также:  Курсор mac os lion для windows 10

Перегрузим все сервисы:

Войдем внутрь MySQL

Должны зайти на сервер:

Добавим старую авторизацию и пароль: password

Но и этого не достаточно, будут ошибки:

mysqli_real_connect(): (HY000/2002): No such file or directory
mysqli_real_connect (): (HY000 / 2002): нет такого файла или каталога

а) Изменим там false на true

2. В конфиг MySQL

Теперь всё должно работать! Осталось всё запустить.

По умолчанию адрес доступа в phpmyadmin

Запуск

или также для mysql подойдет

Команды для перезапуска:

Посмотреть все сервисы:

Логи ошибок в веб-сервере на Mac OS

Если что-то пошло не так, можно посмотреть логи ошибок. Например, почему не открывается та или иная страница:

Ошибки при перезагрузке apache

Если ничего не работает, обязательно надо попробовать перезагрузить apache именно так:

Дальше будут показаны ошибки. По этим сообщениям станет ясно в чем причина.

H00544: httpd: bad group name stuff

Значит в конфигурации httpd.conf указан неверный пользователь. Как поправить смотрите в этой статье выше.

Cannot load /usr/local/opt/php/lib/httpd/modules/ into server

httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php/lib/httpd/modules/libphp7.so, 10): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib\n Referenced from: /usr/local/opt/php/lib/httpd/modules/libphp7.so\n Reason: image not found

httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php/lib/httpd/modules/libphp7.so, 10): image not found

Причина в том, что была обновлена php версия, а модуль не был изменен. Можно исправить двумя вариантами:

а) Попробовать обновить homebrew:

Обновить php или установить новую версию php:

И еще раз перезагрузить сервисы

б) Заменить вручную.

Проверим версию php:

Дальше меняем правим строки в файле /usr/local/etc/httpd/httpd.conf:

httpd not running, trying to start

Если покажет что-то вроде:

И снова запустим:

(48)Address already in use: AH00072

Ошибка появилась в Mac OS Big Sur

httpd not running, trying to start
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down

Меняем значение в Listen на такое:

Ошибка при импорте базы данных

phpMyAdmin — Ошибка
Incorrect format parameter

Надо увеличить лимиты:

Которые устанавливаются в файл php.ini:

Версия php может быть любой другой, которая была установлена.

Снова перезагрузим все сервисы

После этого (не всегда), чтобы сразу заработало нужно выйти и заново зайти в phpMyAdmin.

Другие ошибки

И воспользоваться подсказками. Например:

Локальное подключение к БД

Подключиться можно разными сторонними программами. На примере программы DataGrip:

В поле password пароль будет password.

Читайте также

Кстати, на сайте нет рекламы. У сайта нет цели самоокупаться, но если вам пригодилась информация можете задонатить мне на чашечку кофе в макдаке. Лайкнуть страницу или просто поблагодарить. Карма вам зачтется.

Комментарии к статье “ Устанавливаем веб-сервер на Mac OS ” (8)

Добрый день, как связаться с автором статьи?

Что именно вас интересует?

У меня на моменте:
«Войдем внутрь MySQL»

И
«Должны зайти на сервер»

Никаких ошибок не выдает, кроме синтаксической и файла по адресу «/usr/local/etc/phpmyadmin.config.inc.php
» нет.

Проблема может быть в кавычке. Посмотрите совет в конце этой статьи.

Та же проблема, мак ос биг сур.
как правильно прописать? Я пробую заменить все ковычки на скошенную все равно синтаксическая ошибка

В каком месте ошибка? Скиньте что конкретно вы вводите и куда.

А Nginx, как же он?

Зачем на локальном сервере nginx? В любом случае не подскажу, не ставил из-за ненадобности.

Источник

Оцените статью