Cài đặt Apache, Mysql, PHP, PhpMyadmin trên CentOS

Article ID: 265
Cập nhật gần nhất: 02 Th03, 2019

1. Cài đặt Apache:

yum -y install httpd

+ Chỉnh sửa file cấu hình:

vi /etc/httpd/conf/httpd.conf

Dòng 402: Thêm index.php

DirectoryIndex index.php index.html index.html.var

Dòng 990: Bỏ dấu #

NameVirtualHost *:80

Thêm dòng sau vào cuối file:

Include /etc/httpd/conf/domains/*.conf

+ Tạo thư mục domains chứa file cấu hình của vhost:

mkdir /etc/httpd/conf/domains

+ Tạo vhost: user demo, domain demo.com

Thêm user demo:

useradd demo

passwd demo

mkdir -p /home/demo/public_html

chmod 755 -R /home/demo

chown demo:demo -R /home/demo

Thêm file cấu hình cho domain demo.com

vi /etc/httpd/conf/domains/demo.com.conf

<VirtualHost *:80>
ServerAdmin webmaster@demo.com
DocumentRoot /home/demo/public_html
ServerName demo.com

<Directory "/home/demo/public_html">
Option FollowSymLinks
AllowOverride All

</Directory>

ErrorLog /home/demo/error_log
# CustomLog /home/demo/access_log common
</VirtualHost>

2. Cài đặt Mysql:

Thêm repo:

32bit:

rpm -Uvh http://repo.webtatic.com/yum/el6/i386/webtatic-release-6-5.noarch.rpm

64bit:

rpm -Uvh http://repo.webtatic.com/yum/el6/x86_64/webtatic-release-6-5.noarch.rpm

Cài đặt mysql 5.5:

yum install mysql55w-server

service mysqld start

mysql_secure_installation

3. Cài đặt PHP:

+ PHP 5.3:

yum install php php-mysqlnd php-mbstring php-mcrypt php-gd php-xml

+ PHP 5.4:

yum --enablerepo=webtatic install php54w php54w-mysqlnd php54w-mbstring php54w-mcrypt php54w-gd php54w-xml

+ Chỉnh sửa file cấu hình:

vi /etc/php.ini

post_max_size 200M
upload_max_filesize =  200M

4. Cài đặt PhpMyadmin:

+ Cài đặt repo:

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

+ Cài đặt phpMyAdmin:

yum --enablerepo=remi install phpMyAdmin

+ Chỉnh sửa file phpmyadmin.conf:

vi /etc/httpd/conf.d/phpmyadmin.conf

<Directory /usr/share/phpMyAdmin/>
<IfModule !mod_authz_core.c>
Order Deny,Allow
Allow from All
Allow from ::1
</IfModule>
</Directory>

5. Khởi động lại các dịch vụ:

service httpd restart

service mysqld restart

chkconfig httpd on

chkconfig mysqld on

Article ID: 265
Cập nhật gần nhất: 02 Th03, 2019
Lần sửa đổi: 5
Lượt xem: 110