Thứ Hai, 26 tháng 5, 2014

// // Leave a Comment

NGINX

Cài đặt các gói cần thiết:
#apt-get install nginx apache2 memcached libapache2-mod-php5 libapache2-mod-rpaf
Mở file /etc/apache2/ports.conf, thay 80 bằng 8080
root@haiquynh:~# cat /etc/apache2/ports.conf
NameVirtualHost *:8080
Listen 8080
Tạo (edit) file virtual host trên apache, sửa port thành 8080:
root@haiquynh:~# cat /etc/apache2/sites-available/themegiare.com
<VirtualHost *:8080>
    ServerAdmin webmaster@themegiare.com
        ServerName themegiare.com
        ServerAlias www.themegiare.com
        DocumentRoot /home/thehai/themegiare.com/public_html
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
 Kích hoạt domain và khởi động lại apache:
root@haiquynh:~# a2ensite themegiare.com
Site themegiare.com already enabled
root@haiquynh:~# /etc/init.d/apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
=====
Cài đặt xong 2 gói mới thì bị lỗi này:
root@haiquynh:~# service apache2 restart
[FAIL] Restarting web server: apache2 failed!
[warn] The apache2 configtest failed. ... (warning).
Output of config test was:
AH00526: Syntax error on line 89 of /etc/apache2/apache2.conf:
Invalid command 'LockFile', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
Khắc phục:
LockFile /var/lock/apache2/accept.lock
Doi thanh
Mutex file:${APACHE_LOCK_DIR} default
Bật module php5 và rpaf:
# a2enmod php5 rpaf
TẠo file virtual host cho nginx từ file default:
root@haiquynh:~# cp /etc/nginx/sites-available/default /etc/nginx/sites-available/themegiare.com

Nội dung file themegiare.com
server {
       listen 80;
       server_name www.themegiare.com themegiare.com;
       root /home/thehai/themegiare.com/public_html;
       if ($http_host != "www.themegiare.com") {
                 rewrite ^ http://www.themegiare.com$request_uri permanent;
       }
       index index.php index.html;

       location / {
                proxy_pass http://localhost:8000;
                include /etc/nginx/proxy_params;
       }
}
Kích hoạt domain (virtual host) này cho cho nginx
root@haiquynh:~# ln -s /etc/nginx/sites-available/themegiare.com /etc/nginx/sites-enabled/
root@haiquynh:~# service nginx restart
[ ok ] Restarting nginx: nginx.

================================

http://www.howtoforge.com/how-to-set-up-nginx-as-a-reverse-proxy-for-apache2-on-ubuntu-12.04
http://paulgraydon.co.uk/blog/2009/04/30/nginx-memcached-apache-light-and-fast-web-server-setup/
https://www.digitalocean.com/community/articles/how-to-configure-nginx-as-a-front-end-proxy-for-apache
http://www.expressmagazine.net/posts/view/850/su-dung-nginx-va-memcached-de-tang-toc-apache-tren-debian-lenny

0 nhận xét:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.