1. lépés: Az Apache letöltése/telepítése 2.4
2. lépés: A MySQL letöltése/telepítése
4. lépés: A LAMP stack indítása/leállítása
Következtetés
A saját LAMP-verem összeállítása lehetővé teszi az Apache, a MySQL és a PHP legújabb verzióinak használatát. A CentOS 6 csomagkezelő használatával az Apache 2.2, a MySQL 5.1 és a PHP 5.3. A csomagkezelő csak a CentOS csapatának biztonsági frissítéseit telepíti.
Rendszergazdaként tudja, hogy a szoftver frissítése kulcsfontosságú. Ha pedig a webszerver az internet felé néz, meg kell győződnie arról, hogy a webszerver szoftvere frissítve van a sebezhetőségek megelőzése érdekében.
Ebből a cikkből megtudhatja, hogyan állíthatja össze saját LAMP veremét. A parancsok mindegyikét a következő formátumban ismertetjük.
# Commands will be listed here
An explanation of the commands will be stated here.
1. lépés: Az Apache letöltése/telepítése 2.4
Ebben a cikkben egy előre beállított tükröt fogunk használni; de ha szeretné, használhat egy másik tükröt az Apache tüköroldaláról a VPS hívásával.
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.
Látni fog egy tükörhivatkozást a szakaszban. Cserélje ki a cikkben megadott hivatkozásokat ezzel a tükörrel.
Töltse le a forrást az Apache 2.4-be.
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.
Mivel az Apache APR-t és APR-util-t igényel, tegye a következőket:
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.
Mivel szükségünk van egy megfelelő C fordítóra, telepítenünk kell egyet a csomagkezelő segítségével.
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.
Nagyszerű munka! Itt az ideje az Apache konfigurálásának és elkészítésének.
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.
Hagyja, hogy a rendszer konfigurálja a forrást a telepítéshez, ez nem tarthat túl sokáig. Ha elkészült, hajtsa végre:
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.
Gratulálunk, sikeresen telepítette az Apache 2.4-et!
2. lépés: A MySQL letöltése/telepítése
Most telepítsük a MySQL-t, egy sok webalkalmazás által használt adatbázist. Mivel a MySQL már biztosítja a legújabb verziót RPM formájában, egyszerűbb az előre elkészített telepítőfájl használata, majd konfigurálása. A hivatalos MySQL adattárat fogjuk használni.
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. lépés: A PHP letöltése/telepítése
A PHP-nek van néhány függősége, amelyeket telepítenünk kell, ezért először térjünk rá erre.
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.
Töltse le a PHP forrását, amely a következő parancsok végrehajtásával történik:
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.
Vegye figyelembe, hogy ha olyan üzenetet kap, amely tartalmazza a "/path/to/perl" elemet, akkor módosítania kell a fájlt /usr/local/apache2/bin/apxs.
nano /usr/local/apache2/bin/apxs
Módosítsa az első sort a következőre:
#!/usr/bin/perl -w
4. lépés: A LAMP stack indítása/leállítása
Mivel az Apache-t a semmiből építettük, nem tartalmaz előre elkészített szolgáltatást. Az init szkriptet magunknak kell beállítanunk.
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.
Kész, és kész!
Most kezdjük el az Apache + MySQL + PHP kombinációt:
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.
A PHP Apache-val indul, nem szolgáltatáson keresztül indul.
Következtetés
Ebben a cikkben bemutattuk, hogyan állíthat be LAMP-vermet a semmiből az Apache/PHP/MySQL frissített verzióival. Bár több adminisztrációt igényel a kezelés, ez a technika akkor hasznos, ha újabb veremre van szükségünk, mint amit az operációs rendszer gyártója kínál.