Корак 1: Преузимање/инсталирање Апацхе 2.4
Корак 2: Преузимање/инсталирање МиСКЛ-а
Корак 4: Покретање/заустављање скупа ЛАМП
Закључак
Састављање сопственог ЛАМП стека омогућава вам да користите најновије верзије Апацхе-а, МиСКЛ-а и ПХП-а. Коришћењем менаџера пакета ЦентОС 6 добијате Апацхе 2.2, МиСКЛ 5.1 и ПХП 5.3. Менаџер пакета инсталира само безбедносне исправке од ЦентОС тима.
Као систем администратор, знате да је ажурирање софтвера кључно. А када је ваш веб сервер окренут ка интернету, морате се уверити да је софтвер веб сервера ажуриран да бисте спречили рањивости.
Овај чланак вас учи како да саставите свој ЛАМП стог. Свака од наредби ће бити објашњена у следећем формату.
# Commands will be listed here
An explanation of the commands will be stated here.
Корак 1: Преузимање/инсталирање Апацхе 2.4
За овај чланак ћемо користити унапред подешено огледало; али ако желите, можете користити друго огледало са Апацхе стране огледала уз позив са вашег ВПС-а.
curl -q -s apache.org/dyn/closer.cgi > /tmp/closer
sed -e 151b -e '$!d' /tmp/closer
The curl command sends an HTTP request to the URL, and retrieves its contents. We redirect the output to /tmp/closer, and then the sed command cuts it down to something you can read.
Видећете везу огледала која се налази у одељку. Само замените све везе наведене у овом чланку тим огледалом.
Преузмите извор у Апацхе 2.4.
cd /usr/src && wget http://apache.mirrors.ionfish.org/httpd/httpd-2.4.17.tar.gz && tar xvf httpd-2.4.17.tar.gz
The first part of this command will change our current directory to /usr/src, then the wget section will download the source. The last part of this command unzips the source.
Пошто Апацхе захтева АПР и АПР-утил, урадите следеће:
wget http://apache.mirrors.ionfish.org/apr/apr-1.5.2.tar.gz && tar xvf apr-1.5.2.tar.gz && mv apr-1.5.2 httpd-2.4.17/srclib/apr
wget http://apache.mirrors.ionfish.org/apr/apr-util-1.5.4.tar.gz && tar xvf apr-util-1.5.4.tar.gz && mv apr-util-1.5.4 httpd-2.4.17/srclib/apr-util
These commands will download the sources for APR and APR-util, and unzip them. Then, we move the source into Apache's build directory so that Apache will build properly.
Пошто нам је потребан одговарајући Ц компајлер, мораћемо да га инсталирамо помоћу менаџера пакета.
yum groupinstall 'Development Tools' -y
yum install gcc-c++ -y
yum install pcre-devel -y
yum install bison bison-devel -y
yum install ncurses-devel -y
yum install perl-devel -y
As I've mentioned above, we still need to obtain Apache's prerequisites, so we'll be installing them using the package manager.
Сјајан посао! Сада је време да конфигуришете и изградите Апацхе.
cd httpd-2.4.17 && ./configure
The cd httpd-2.4.17 part changes our current working directory to httpd-2.4.17/. When we run ./configure, we're configuring our system to build Apache.
Дозволите систему да конфигурише извор за инсталацију, то не би требало да траје предуго. Када завршите, извршите:
make && make install
cp support/apachectl /usr/sbin
chmod 755 /usr/sbin/apachectl
The make section of these commands will build the software. When we run make install, we effectively install Apache onto our system. Now, we need to copy it to the secure bin directory (cp signifies copy). Finally, we'll give it permissions to execute with chmod 755.
Честитамо, успешно сте инсталирали Апацхе 2.4!
Корак 2: Преузимање/инсталирање МиСКЛ-а
Сада, хајде да инсталирамо МиСКЛ, базу података коју користе многе веб апликације. Пошто МиСКЛ већ нуди најновију верзију у облику РПМ-а, лакше је користити њихову унапред направљену инсталациону датотеку, а затим је конфигурисати. Користићемо званично МиСКЛ спремиште.
cd /usr/src && wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm && rpm -i mysql57-community-release-el6-7.noarch.rpm
yum install mysql-community-server -y
The first command is where we download the RPM file to enable the MySQL repository on our system. Then, rpm -i installs the RPM file. Finally, we'll install MySQL from the official MySQL repository.
Корак 3: Преузимање/инсталирање ПХП-а
ПХП има неке зависности које морамо да инсталирамо, па хајде да прво пређемо на то.
yum install -y libxml2-devel libcurl-devel libmcrypt libmcrypt-devel
We're using the package manager once more - but this time, we're installing some components to allow PHP applications to run properly.
Преузмите извор за ПХП, што се ради извршавањем следећих команди:
wget http://docs.php.net/distributions/php-5.6.15.tar.gz && tar xvf php-5.6.15.tar.gz
cd php-5.6.15
./configure --with-pear=/usr/lib/pear --enable-libxml --with-pdo-mysql --with-mysqli --with-mysql --enable-mbstring --with-mcrypt --with-apxs2=/usr/local/apache2/bin/apxs --enable-maintainer-zts --with-curl=/lib
make && make install
The first part, wget, is where we download the source to PHP 5.6.15. Then, we change our working directory to php-5.6.15. Finally, we configure PHP with the features required to run various web applications, such as e-commerce websites.
Имајте на уму да ако добијете поруку која садржи „/патх/то/перл“, мораћете да уредите датотеку /usr/local/apache2/bin/apxs.
nano /usr/local/apache2/bin/apxs
Промените први ред у:
#!/usr/bin/perl -w
Корак 4: Покретање/заустављање скупа ЛАМП
Пошто смо Апацхе направили од нуле, он не укључује унапред изграђену услугу. Мораћемо да сами подесимо инит скрипту.
cd /usr/src && wget https://gist.githubusercontent.com/anonymous/62b0b788f86e7773e901/raw/6bcc88f9354f7139916272ac7a4eb998b1f26fdd/httpd-init
mv httpd-init /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
The first part, where we cd, changes our working directory to the directory where we build/compile software. Then, with &&, we execute anything after it as well, which in this case, downloads the service file for Apache. Finally, we give permission for it to be executed with the chmod command.
Готово, и готово!
Сада, почнимо Апацхе + МиСКЛ + ПХП:
service httpd start
service mysqld start
With the service commands, we can manage the status of services. In this case, we've started the services httpd and mysqld.
ПХП се покреће са Апацхе-ом, не почиње преко сервиса.
Закључак
У овом чланку смо покрили како да подесите ЛАМП стек од нуле користећи ажуриране верзије Апацхе/ПХП/МиСКЛ. Иако захтева више администрације за управљање, ова техника је корисна када желимо новији стек од онога што нуди добављач оперативног система.