Baza znanja
Instalacija Apache, PHP, MySQL, phpMyAdmin na CentOS 6 LAMP
Postavio modifikovano 29 January 2014 12:43

LAMP je skraćenica za Linux, Apache, MySQL, PHP . Ovo uputstvo pokazuje kako možete da instalirate web server Apache2 na CentOS 6 serveru sa PHP5 (mod_php) i MySQL podrškom.

Za instalaciju je potrebno da imate root pristup preko SSH konzole na vašem serveru.

 Instalacija MySQL 5 servera

Pokrećemo instalaciju MySQL-a sledećom komandom

yum install mysql mysql-server

Postavljamo da se MySQL automatski startuje prilikom podizanja operativnog sistema.

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

Postavljamo lozinku za MySQL root nalog

[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: <-- ukucajte novu lozinku
Re-enter new password: <-- ukucajte ponovo novu lozinku
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!

Instalacija Apache 2

Pokrećemo instalaciju Apache servera

yum install httpd

Konfigurišemo sistem da pokreće Apache prilikom startovanja servera

chkconfig --levels 235 httpd on

Pokrećemo Apache

/etc/init.d/httpd start

Ukucajte IP adresu vašeg servera u browseru. Trebalo bi da prikaže testnu stranu Apache servera.

Instalacija PHP

Možemo instalirati PHP5 i Apache modul na sledeći način:

yum install php

Potrebno je restartovati Apache

/etc/init.d/httpd restart

Instaliranje MySQL podrške za PHP

Da biste instalirali MySQL podršku za PHP, možemo instalirati php-mysql paket. Dobra je ideja da instalirate još neke PHP module koji će vam biti potrebni za vaše aplikacije. Dostupne PHP module možete pretražiti ovako:

yum search php

Izaberite one koje su vam potrebni i instalirajte ih na sledeći način:

yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

Ponovo restartujte Apache

/etc/init.d/httpd restart

Instalacija phpMyAdmin

phpMyAdmin je web interfejs preko koga možete da upravljate bazama podataka.

Prvo, moramo omogućiti RPMforge repozitorijum jer phpMyAdmin nije dostupan kroz zvanični CentOS repozitorijum.

Importujte RPMforge GPG key:

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

Instalacija za 64-bitne sisteme

yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Instalacija za 32-bitne sisteme

yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

Instaliramo phpMyAdmin sledećom komandom:

yum install phpmyadmin

Sada smo konfigurisali phpMyAdmin. Menjamo konfiguraciju Apache-a tako da phpMyAdmin omogućava konekcije ne samo sa localhost-a (iskomentarišite liniju <Directory "/usr/share/phpmyadmin">).
Možete koristiti bilo koji editor. U nasem slučaju koristimo nano (možete ga instalirati komandom yum install nano)

nano /etc/httpd/conf.d/phpmyadmin.conf
#
#  Web application to manage MySQL
#

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Ostaje da promenimo tip autentifikacije u phpMyAdmin sa cookie na http:

nano /usr/share/phpmyadmin/config.inc.php
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

Potrebno je restartovati Apache

/etc/init.d/httpd restart

Sada možete pristupiti phpMyAdmin-u preko adrese http://ip-adresa/phpmyadmin/

 

ČESTITAMO! uspešno ste instalirali LAMP

(9 glas(ova))
Koristan
Nije koristan