0

Cài đặt PHP, Apache HTTP và mysql từ source trên ubuntu

Bài lab dưới đây mình sẽ viết các bước cài đặt PHP, Apache HTTP và mysql từ source để có thể cài đặt chính xác phiên bản mình muốn thay vì cài từ apt với phiên bản mới nhất của repo.

Các phiên bản mình sử dụng trong bài lab:

  • OS: Ubuntu 14.04
  • PHP 5.3.10
  • Mysql-server 5.0.19
  • Apache HTTP 2.2.34

Tạo thư mục chứa source

$ mkdir /opt/sources
$ cd /opt/sources

Tải source

Tải mysql-server:

$ wget https://cdn.mysql.com/archives/mysql-5.0/mysql-max-5.0.19-linux-x86_64-icc-glibc23.tar.gz

Tải PHP 5

$ wget http://museum.php.net/php5/php-5.3.10.tar.gz

Tải Apache HTTP:

$ wget http://mirrors.viethosting.com/apache//httpd/httpd-2.2.34.tar.gz

Giải nén file

$ tar -xzvf httpd-2.2.34.tar.gz
$ tar -xzvf mysql-max-5.0.19-linux-x86_64-icc-glibc23.tar.gz
$ tar -xzvf php-5.3.10.tar.gz

Cài đặt các gói hỗ trợ

$ apt-get install -y build-essential"

Cài đặt mysql-server

$ apt-get install -y libstdc++5
$ cd mysql-max-5.0.19-linux-x86_64-icc-glibc23
$ groupadd mysql
$ useradd -g mysql mysql
$ scripts/mysql_install_db --user=mysql
$ chown -R root  .
$ chown -R mysql data
$ chgrp -R mysql .
$ cp support-files/my-medium.cnf /etc/mysql/my.cnf

# Start mysql-server
$ bin/mysqld_safe --user=mysql &
$ cp support-files/mysql.server /etc/init.d/mysql

Chỉnh sửa file my.cnf đoạn basedir và datadir

basedir=/usr/local/mysql datadir=/usr/local/mysql/data

Để check cần cài mysql-client

$ apt-get install -y mysql-client
$ mysql -uroot -p

thấy kết nối được và đúng version à được

Cài đặt apache HTTP

$ cd /opt/sources/httpd-2.2.34
$ apt-get install libpng-dev
$ ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all
$ make
$ make install

Thử check hoạt động của apache http bằng cách mở một trình duyệt và điền địa chỉ ip của server vào, nếu hiện như bên dưới là hoạt động tạm ổn:

Cài đặt php

$ cd /opt/sources/php-5.3.10
$ apt-get install -y libxml2-devel
$ sudo ./configure --prefix=/usr/local/php5 --with-config-file-path=/opt/source/php-5.3.10 --with-mysql --with-libdir=/lib/x86_64-linux-gnu
$ make
$ make install

Check hoạt động của web: Tạo file phpinfo để check

vim /usr/local/apache2/htdocs/index.php

Thêm đoạn code sau vào file

<?php // Show all information, defaults to INFO_ALL phpinfo(); // Show just the module information. // phpinfo(8) yields identical results. phpinfo(INFO_MODULES); ?>

Mở trình duyệt, điền địa chỉ sau: http://ipserver/phpinfo.php


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí