Bài viết sau sẽ hướng dẫn các bạn build Linux Web server nâng cao bao gồm MySQL, php và apache(LAMP) từ source trên CentOS 6.4
1. Cài đặt MySQL
Xem chi tiết tại:
UnHidden Content:
http://linux24h.com/threads/installing-mysql-on-centos-6-linux.9/
Tải gói cài đặt tại: http://fi2.php.net/get/php-5.4.15.tar.gz/from/a/mirror
Code:
[root@linux24h ~]# wget http://sg2.php.net/distributions/php-5.4.15.tar.gz
Code:
[root@linux24h ~]# tar xzvf php-5.4.15.tar.gz [root@linux24h ~]# cd php-5.4.15 [root@linux24h php-5.4.15]# ./configure --prefix=/usr/local/php --with-libdir=/lib64 --enable-fpm --with-bz2 --with-config-file-path=/usr/local/php/ --with-config-file-scan-dir=/etc/php.d/ --with-curl=/opt/curlssl/ --with-gd --with-gettext --with-jpeg-dir=/usr/local/lib --with-freetype-dir=/usr/local/lib --with-mcrypt --with-mhash --with-mysql --with-mysql-sock=/tmp/mysql.sock --with-mysqli --with-pcre-regex --with-pear=/usr/local/lib64/php --with-png-dir=/usr/local/lib64 --with-sqlite=shared --with-tidy --with-xmlrpc --with-xsl --with-zlib --with-zlib-dir=/usr/local/lib64 --with-openssl --with-iconv --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-soap --enable-sockets --enable-mbstring --enable-zip --enable-wddx --with-mysql=mysqlnd -with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd [root@linux24h php-5.4.15]# make && make install [root@linux24h php-5.4.15]# cp php.ini-production /usr/local/php/php.ini
Warning: No matches found for: mcrypt
No Matches found
Giải quyết:
Code:
[root@linux24h php-5.4.15]# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm [root@linux24h php-5.4.15]# yum install libmcrypt-devel mcrypt -y
Code:
[root@linux24h ~]# wget http://mirrors.digipower.vn/apache//httpd/httpd-2.4.4.tar.gz [root@linux24h ~]# tar xzvf httpd-2.4.4.tar.gz [root@linux24h ~]# cd httpd-2.4.4 [root@linux24h httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd.d --with-mpm=prefork --disable-charset-lite --disable-include --disable-env --disable-status --disable-asis --disable-negotiation --disable-imap --disable-actions --disable-userdir --enable-so --enable-rewrite --enable-vhosts-alias --enable-ssl --enable-modules='unique-id' --with-included-apr [root@linux24h httpd-2.4.4]# make && make install
Bạn sẽ nhận được thông báo lỗi:
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
Giải quyết:
Code:
[root@linux24h httpd-2.4.4]# wget http://apache.osuosl.org/apr/apr-1.4.6.tar.gz [root@linux24h httpd-2.4.4]# wget http://apache.osuosl.org/apr/apr-util-1.4.1.tar.gz [root@linux24h httpd-2.4.4]# tar xzvf apr-1.4.6.tar.gz [root@linux24h httpd-2.4.4]# tar xzvf apr-util-1.4.1.tar.gz [root@linux24h httpd-2.4.4]# mv apr-1.4.6 srclib/apr [root@linux24h httpd-2.4.4]# mv apr-util-1.4.1 srclib/apr-util
configure: error: pcre-config for libpcre not found. PCRE is required and available fromhttp://pcre.org/
Giải quyết:
Code:
[root@linux24h httpd-2.4.4]# yum install pcre-devel -y
Code:
[root@linux24h httpd-2.4.4]# cd /etc/httpd.d/ [root@linux24h httpd.d]# vim httpd.conf
Code:
Listen 80 ServerAdmin admin@linux24h.com UseCanonicalName Off ServerSignature Off HostnameLookups Off ServerTokens Prod
Code:
LoadModule deflate_module modules/mod_deflate.so LoadModule expires_module modules/mod_expires.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_ftp_module modules/mod_proxy_ftp.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so LoadModule proxy_scgi_module modules/mod_proxy_scgi.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule proxy_express_module modules/mod_proxy_express.soLoadModule rewrite_module modules/mod_rewrite.so Include /etc/httpd.d/extra/httpd-vhosts.conf
4. Config php-fpm
Xem thêm tại:
UnHidden Content:
http://linux24h.com/threads/configure-apache-to-use-php-fpm-centos.10/
Xem thêm tại:
UnHidden Content:
http://linux24h.com/threads/configuring-virtual-hosts-apache-centos.11/
Khởi động dịch vụ apache server:
Code:
[root@linux24h ~]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd [root@linux24h ~]# /etc/init.d/httpd start
Code:
[root@linux24h httpd.d]# chkconfig --level 235 httpd on
service httpd does not support chkconfig
vào:
Code:
[root@linux24h httpd.d]# vim /etc/init.d/httpd
Code:
# Startup script for the Apache Web Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve # HTML files and CGI. # processname: httpd # pidfile: /usr/local/apache/logs/httpd.pid # config: /usr/local/apache/conf/httpd.conf
Code:
<?php echo phpinfo(); ?>