Ubuntu 10.04.3 LTS Nginx php-fpm mysql — различия между версиями
Admin (обсуждение | вклад) |
Admin (обсуждение | вклад) |
||
Строка 96: | Строка 96: | ||
sed -i "s/\;pm./pm./" /usr/local/php/etc/php-fpm.conf | sed -i "s/\;pm./pm./" /usr/local/php/etc/php-fpm.conf | ||
sed -i "s/\;pid/pid/" /usr/local/php/etc/php-fpm.conf | sed -i "s/\;pid/pid/" /usr/local/php/etc/php-fpm.conf | ||
+ | cp ./php.ini-production /usr/local/php/lib/php.ini | ||
+ | sed -i "s/short_open_tag/\;short_open_tag/" /usr/local/php/lib/php.ini | ||
/etc/init.d/php-fpm start | /etc/init.d/php-fpm start | ||
</geshi> | </geshi> | ||
Строка 124: | Строка 126: | ||
} | } | ||
+ | </geshi> | ||
+ | Для проверки создаем простейший phpinfo: | ||
+ | <geshi lang="bash"> | ||
+ | echo "<? phpinfo(); ?>" > /var/www/index.php | ||
+ | </geshi> | ||
+ | |||
+ | перезапускаем nginx | ||
+ | <geshi lang="bash"> | ||
+ | /etc/init.d/nginx restart | ||
</geshi> | </geshi> |
Версия 02:02, 13 ноября 2011
Включаем bash-completion
bash-completion включает расширенное автодополнение команды по нажатию клавиши [Tab]
устанавливаем bash-completion и попутно текстовый редактор Vim: <geshi lang="bash"> apt-get install bash-completion vim -y </geshi>
В отличии от CentOS/RHEl, в debian/ubuntu недостаточно поставить пакет bash-completion для того чтобы получить желаемый функционал, нужно его ещё и в bash.bashrc раскомментировать. Открываем /etc/bash.bashrc <geshi lang="bash"> vim /etc/bash.bashrc </geshi>
и раскомментируем блок: <geshi lang="bash">
- enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi </geshi>
Устанавливаем nginx
Переходим к установке nginx, тут всё просто: <geshi lang="bash"> apt-get update apt-get install nginx </geshi>
Запускаем nginx <geshi lang="bash"> /etc/init.d/nginx start </geshi>
Проверяем, слушает ли наш новый nginx порт 80: <geshi lang="bash"> netstat -tnlp | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1205/nginx </geshi>
Всё нормально, можем открыть в браузере и порадоваться:
Установка php-fpm
Переходим к установки php-fpm. Ставить будем свежайшую версию, соберем собственный deb-пакет из официальных исходников.
Для сборки нам понадобятся пакеты:
<geshi lang="bash"> apt-get install libxml2-dev libssl-dev bzip2 libbz2-dev libcurl4-openssl-dev libjpeg62-dev libpng12-dev \ libfreetype6-dev libt1-dev libc-client2007e-dev libmcrypt-dev libmysqlclient-dev libidn11-dev libltdl-dev \ checkinstall automake autoconf libicu-dev </geshi>
Скачиваем тарбол с исходниками php:
<geshi lang="bash">
wget http://ru.php.net/get/php-5.3.8.tar.gz/from/this/mirror -O php-5.3.8.tar.gz
</geshi>
Распаковываем его и переходим в папку с исходниками php <geshi lang="bash"> tar zxf php-5.3.8.tar.gz cd php-5.3.8/ </geshi>
Начинаем сборку из исходников: <geshi lang="bash"> ./configure --enable-fpm --enable-soap --with-mcrypt --enable-mbstring --with-openssl --with-mysql --with-mysql-sock \ --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --with-sqlite=shared --with-pdo-mysql --with-libxml-dir=/usr/lib \ --with-mysqli --with-curl --enable-zip --with-bz2 --with-imap --with-imap-ssl --enable-sockets --with-zlib --enable-exif \ --enable-ftp --with-iconv --with-gettext --enable-gd-native-ttf --with-t1lib --with-freetype-dir --with-kerberos \ --prefix=/usr/local/php --with-fpm-user=www-data --with-fpm-group=www-data </geshi>
Компилируем php: <geshi lang="bash"> make </geshi>
После того как компиляция успешно завершится с сообщением Build complete переходим к сборке и установке .deb пакета:
<geshi lang="bash"> checkinstall -D </geshi>
В итоге php-fpm установлен и у нас есть готовый пакет /root/php-5.3.8/php-fpm_5.3.8-1_i386.deb для тех кто не хочет заморачиваться со сборкой или ресурсов VPS для сборки недостаточно, в конце статьи я дам ссылку на собраный пакет.
Создадим init-скрипт и добавим php-fpm в автозапуск:
<geshi lang="bash"> cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm update-rc.d php-fpm defaults cp ./sapi/fpm/php-fpm.conf /usr/local/php/etc/ sed -i "s/\;pm./pm./" /usr/local/php/etc/php-fpm.conf sed -i "s/\;pid/pid/" /usr/local/php/etc/php-fpm.conf cp ./php.ini-production /usr/local/php/lib/php.ini sed -i "s/short_open_tag/\;short_open_tag/" /usr/local/php/lib/php.ini /etc/init.d/php-fpm start </geshi>
Теперь займемся настройкой nginx. Приведите файл /etc/nginx/sites-enabled/default к виду: <geshi lang="bash"> server { listen 80 default; server_name localhost;
access_log /var/log/nginx/localhost.access.log;
location / { root /var/www/; index index.php index.html index.htm; }
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name; include fastcgi_params; }
location ~ /\.ht { deny all; } }
</geshi>
Для проверки создаем простейший phpinfo: <geshi lang="bash"> echo "<? phpinfo(); ?>" > /var/www/index.php </geshi>
перезапускаем nginx <geshi lang="bash"> /etc/init.d/nginx restart </geshi>