Установка Nginx с поддержкой PHP5 (PHP-FPM) и MySQL на CentOS 6.0

Опубликовано 15.09.2011

Оригинал:Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On CentOS 6.0
Перевод:Сгибнев Михаил

 Nginx (произносится как «engine x») — это открытый, свободно распространяемый, высокопроизводительный HTTP сервер. Nginx известен своей стабильностью, простотой конфигурации и нетребовательностью к ресурсам.

 Примечание переводчика. От себя добавлю, что в 2004 году мой сайт работал под управлением самой первой версии этого HTTP-сервера на платформе PA-RISC c 64Mb RAM и обслуживал до 1000 посетителей в сутки.

 Как обычно, не дается никаких гарантий.

 1. Предварительные шаги

 В этом примере используется имя сервера server1.example.com с IP адресом 192.168.0.100, Вы должны использовать своё имя и адрес.

 2. Подключаем дополнительные репозитарии

 php-fpm не доступен в официальном репозитарии CentOS, но есть в репозитории Remi RPM, зависящего от репозитария EPEL . Нам необходимо подключить оба.

rpm --import https://fedoraproject.org/static/0608B895.txt
rpm -ivh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm

rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

yum install yum-priorities

 Редактируем /etc/yum.repos.d/epel.repo:

vi /etc/yum.repos.d/epel.repo

 И добавляем в файл строку priority=10 в секцию [epel]:

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
priority=10
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
[...]

 Делаем то же самое для секции [remi] в /etc/yum.repos.d/remi.repo и изменяем параметр enabled на 1.

 3 Устанавливаем MySQL 5

yum install mysql mysql-server

 Создаем ссылки на запуск MySQL при загрузке и запускаем демон:

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

 Проверяем создался ли порт:

netstat -tap | grep mysql

 Мы должны увидеть нечто подобное:

[root@server1 ~]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 2302/mysqld
[root@server1 ~]#

 Если подобного не наблюдается, то в файле /etc/my.cnf необходимо закомментировать опцию skip-networking и перезапустить демон командой /etc/init.d/mysqld restart.

 Выполняем команду mysql_secure_installation:

[root@server1 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <-- ENTER OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] <-- ENTER New password: <-- yourrootsqlpassword Re-enter new password: <-- yourrootsqlpassword Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] <-- ENTER ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] <-- ENTER ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] <-- ENTER - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] <-- ENTER ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! [root@server1 ~]#
 4 Установка Nginx

 Nginx доступен в пакетах CentOS 6.0 (из репозитария EPEL):

yum install nginx

 Создаем ссылки и запускаем сервер:

chkconfig --levels 235 nginx on
/etc/init.d/nginx start

 На этом установка закончена. Введите в браузере IP адрес или имя вашей машины ( например http://192.168.0.100) и насладитесь приветственной заставкой.


[ad name="Google Adsense"]



 Уважайте труд автора, сохраняйте копирайты.
Реклама на сайте висит не просто так и если статья Вам понравилась, с ее помощью Вы можете отблагодарить автора за проделанную работу. Спасибо!

2 комментария в Установка Nginx с поддержкой PHP5 (PHP-FPM) и MySQL на CentOS 6.0

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

*