Korak 1: Preuzimanje/instalacija Apachea 2.4
Korak 2: Preuzimanje/instalacija MySQL-a
Korak 4: Pokretanje/zaustavljanje snopa LAMP
Zaključak
Sastavljanje vlastitog LAMP stoga omogućuje vam korištenje najnovijih verzija Apachea, MySQL-a i PHP-a. Korištenjem upravitelja paketa CentOS 6 dobivate Apache 2.2, MySQL 5.1 i PHP 5.3. Upravitelj paketa instalira samo sigurnosna ažuriranja od CentOS tima.
Kao administrator sustava, znate da je ažuriranje softvera ključno. S obzirom da je vaš web poslužitelj okrenut prema internetu, morate provjeriti je li softver web poslužitelja ažuriran kako biste spriječili ranjivosti.
Ovaj članak vas uči kako sastaviti vlastiti LAMP stog. Svaka od naredbi bit će objašnjena u sljedećem formatu.
# Commands will be listed here
An explanation of the commands will be stated here.
Korak 1: Preuzimanje/instalacija Apachea 2.4
Za ovaj članak koristit ćemo unaprijed postavljeno zrcalo; ali ako želite, možete koristiti drugo zrcalo sa Apache stranice zrcala uz poziv s vašeg VPS-a.
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.
Vidjet ćete zrcalnu vezu sadržanu u odjeljku. Samo zamijenite sve veze navedene u ovom članku tim zrcalom.
Preuzmite izvor na Apache 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.
Budući da Apache zahtijeva APR i APR-util, učinite sljedeće:
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.
Budući da nam je potreban odgovarajući C prevodilac, morat ćemo ga instalirati pomoću upravitelja paketa.
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.
Odličan posao! Sada je vrijeme da konfigurirate i izgradite Apache.
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.
Dopustite sustavu da konfigurira izvor za instalaciju, to ne bi trebalo dugo trajati. Kada završite, izvršite:
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.
Čestitamo, uspješno ste instalirali Apache 2.4!
Korak 2: Preuzimanje/instalacija MySQL-a
Sada, instalirajmo MySQL, bazu podataka koju koriste mnoge web aplikacije. Budući da MySQL već nudi najnoviju verziju u obliku RPM-a, lakše je koristiti njihovu unaprijed izgrađenu instalacijsku datoteku, a zatim je konfigurirati. Koristit ćemo službeni MySQL repozitorij.
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.
Korak 3: Preuzimanje/instalacija PHP-a
PHP ima neke ovisnosti koje moramo instalirati, pa prijeđimo na to prvo.
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.
Preuzmite izvor za PHP, što se radi izvršavanjem sljedećih naredbi:
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.
Imajte na umu da ako primite poruku koja sadrži "/path/to/perl", morat ćete urediti datoteku /usr/local/apache2/bin/apxs.
nano /usr/local/apache2/bin/apxs
Promijenite prvi redak u:
#!/usr/bin/perl -w
Korak 4: Pokretanje/zaustavljanje snopa LAMP
Kako smo Apache izgradili od nule, on ne uključuje unaprijed izgrađenu uslugu. Morat ćemo sami postaviti init skriptu.
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.
Gotovo, i gotovo!
Sada, krenimo Apache + MySQL + PHP:
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.
PHP se pokreće s Apacheom, ne pokreće se putem usluge.
Zaključak
U ovom članku pokrili smo kako postaviti LAMP stog od nule koristeći ažurirane verzije Apache/PHP/MySQL. Iako zahtijeva više administracije za upravljanje, ova tehnika je korisna kada želimo noviji stog od onoga što nudi dobavljač operativnog sustava.