Βήμα 1: Λήψη/εγκατάσταση του Apache 2.4
Βήμα 2: Λήψη/εγκατάσταση MySQL
Βήμα 4: Εκκίνηση/διακοπή της στοίβας LAMP
συμπέρασμα
Η μεταγλώττιση της δικής σας στοίβας LAMP σάς επιτρέπει να χρησιμοποιείτε τις πιο πρόσφατες εκδόσεις των Apache, MySQL και PHP. Χρησιμοποιώντας τον διαχειριστή πακέτων CentOS 6, λαμβάνετε Apache 2.2, MySQL 5.1 και PHP 5.3. Ο διαχειριστής πακέτων εγκαθιστά μόνο ενημερώσεις ασφαλείας από την ομάδα του CentOS.
Ως διαχειριστής συστήματος, γνωρίζετε ότι είναι σημαντικό να διατηρείτε το λογισμικό ενημερωμένο. Και με τον διακομιστή ιστού σας να βλέπει στο Διαδίκτυο, πρέπει να βεβαιωθείτε ότι το λογισμικό του διακομιστή ιστού είναι ενημερωμένο για την αποφυγή ευπάθειας.
Αυτό το άρθρο σάς διδάσκει πώς να μεταγλωττίσετε τη δική σας στοίβα LAMP. Κάθε μία από τις εντολές θα εξηγηθεί χρησιμοποιώντας την παρακάτω μορφή.
# Commands will be listed here
An explanation of the commands will be stated here.
Βήμα 1: Λήψη/εγκατάσταση του Apache 2.4
Για αυτό το άρθρο, θα χρησιμοποιήσουμε έναν προκαθορισμένο καθρέφτη. αλλά αν θέλετε, μπορείτε να χρησιμοποιήσετε έναν άλλο καθρέφτη από τη σελίδα καθρέφτη του Apache με μια κλήση από το VPS σας.
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.
Θα δείτε έναν σύνδεσμο καθρέφτη που περιέχεται στην ενότητα. Απλώς αντικαταστήστε τυχόν συνδέσμους που καθορίζονται σε αυτό το άρθρο με αυτόν τον καθρέφτη.
Κατεβάστε την πηγή στο 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.
Εφόσον το Apache απαιτεί APR και APR-util, κάντε τα εξής:
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.
Καθώς χρειαζόμαστε έναν κατάλληλο μεταγλωττιστή C, θα χρειαστεί να εγκαταστήσουμε έναν χρησιμοποιώντας τον διαχειριστή πακέτων.
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.
Καλή δουλειά! Τώρα, ήρθε η ώρα να διαμορφώσετε και να δημιουργήσετε το 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.
Επιτρέψτε στο σύστημα να διαμορφώσει την πηγή για εγκατάσταση, δεν θα χρειαστεί πολύς χρόνος. Μόλις ολοκληρωθεί, εκτελέστε:
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.
Συγχαρητήρια, εγκαταστήσατε με επιτυχία το Apache 2.4!
Βήμα 2: Λήψη/εγκατάσταση MySQL
Τώρα, ας εγκαταστήσουμε τη MySQL, μια βάση δεδομένων που χρησιμοποιείται από πολλές εφαρμογές Ιστού. Επειδή η MySQL παρέχει ήδη την πιο πρόσφατη έκδοση με τη μορφή RPM, είναι πιο εύκολο να χρησιμοποιήσετε το προκατασκευασμένο αρχείο εγκατάστασης και στη συνέχεια να το ρυθμίσετε. Θα χρησιμοποιήσουμε το επίσημο αποθετήριο MySQL.
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: Λήψη/εγκατάσταση PHP
Η PHP έχει κάποιες εξαρτήσεις που πρέπει να εγκαταστήσουμε, οπότε ας πάμε πρώτα σε αυτό.
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.
Κατεβάστε την πηγή για την PHP, η οποία γίνεται με την εκτέλεση των παρακάτω εντολών:
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.
Λάβετε υπόψη ότι εάν λάβετε ένα μήνυμα που περιέχει "/path/to/perl", θα χρειαστεί να επεξεργαστείτε το αρχείο /usr/local/apache2/bin/apxs.
nano /usr/local/apache2/bin/apxs
Αλλάξτε την πρώτη γραμμή σε:
#!/usr/bin/perl -w
Βήμα 4: Εκκίνηση/διακοπή της στοίβας LAMP
Καθώς έχουμε δημιουργήσει το Apache από την αρχή, δεν περιλαμβάνει προκατασκευασμένη υπηρεσία. Θα χρειαστεί να ρυθμίσουμε μόνοι μας το σενάριο init.
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.
Έγινε, και έγινε!
Τώρα, ας ξεκινήσουμε το 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 ξεκινά με Apache, δεν ξεκινά μέσω μιας υπηρεσίας.
συμπέρασμα
Σε αυτό το άρθρο, καλύψαμε πώς να ρυθμίσετε μια στοίβα LAMP από την αρχή χρησιμοποιώντας ενημερωμένες εκδόσεις του Apache/PHP/MySQL. Αν και απαιτεί περισσότερη διαχείριση για τη διαχείριση, αυτή η τεχνική είναι χρήσιμη όταν θέλουμε μια νεότερη στοίβα από αυτή που προσφέρει ο προμηθευτής του λειτουργικού συστήματος.