Configure Nginx ( FrontEnd ) and Apache ( Backend ) Why Run Nginx and Apache Together Both nginx and apache are powerful and effective ...
Configure Nginx ( FrontEnd ) and Apache ( Backend )
Why Run Nginx and Apache Together
Both nginx and apache are powerful and effective servers. Apache currently reigns as the #1 server for websites and since its public release in 2006, nginx has taken the world by storm and is now the #2 server for active sites. The reasons for each respective server’s popularity are clear: apache’s power and nginx’s speed are well known. However, both servers do have drawbacks
apache is hard on server memory, while nginx (great at static files) needs the help of php-fpm or similar modules for dynamic content.
However, one can combine the two web servers to great effect, with nginx as static web server front and apache processing the back end.
---------------------------------------------------------------------------------------------------------------------------------
1'st Install Nginx & apache
---------------------------------------------------------------------------------------------------------------------------------
How to install Nginx
How to install Apache
---------------------------------------------------------------------------------------------------------------------------------
2'nd Configure Nginx & Apache Conf
---------------------------------------------------------------------------------------------------------------------------------
== Nginx ==
== Apache ==
---------------------------------------------------------------------------------------------------------------------------------
3'rd Configure nginx & Apache sites-enable ---------------------------------------------------------------------------------------------------------------------------------
== Nginx ==
Change port apache to 81, for avoid same ports with nginx
4'rd Starting nginx & apache service
---------------------------------------------------------------------------------------------------------------------------------
5'rd Test with info.php
---------------------------------------------------------------------------------------------------------------------------------
# vi /var/www/info.php
Why Run Nginx and Apache Together
Both nginx and apache are powerful and effective servers. Apache currently reigns as the #1 server for websites and since its public release in 2006, nginx has taken the world by storm and is now the #2 server for active sites. The reasons for each respective server’s popularity are clear: apache’s power and nginx’s speed are well known. However, both servers do have drawbacks
apache is hard on server memory, while nginx (great at static files) needs the help of php-fpm or similar modules for dynamic content.
However, one can combine the two web servers to great effect, with nginx as static web server front and apache processing the back end.
---------------------------------------------------------------------------------------------------------------------------------
1'st Install Nginx & apache
---------------------------------------------------------------------------------------------------------------------------------
How to install Nginx
How to install Apache
---------------------------------------------------------------------------------------------------------------------------------
2'nd Configure Nginx & Apache Conf
---------------------------------------------------------------------------------------------------------------------------------
== Nginx ==
# vi /etc/nginx/nginx.conf
-------------------------------------------------------------------------------------------------
include /etc/nginx/sites-enabled/*;
-------------------------------------------------------------------------------------------------
== Apache ==
# vi /etc/httpd.conf
-------------------------------------------------------------------------------------------------note : in this case we using case magento installation
# Include generic snippets of statements
Include conf.d/*
# Include the virtual host configurations:
Include sites-enabled/*
-------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
3'rd Configure nginx & Apache sites-enable ---------------------------------------------------------------------------------------------------------------------------------
== Nginx ==
# touch /etc/nginx/sites-enable/magento
# vi /etc/nginx/sites-enable/magento
-------------------------------------------------------------------------------------------------
server {
listen 80;
root /var/www/magento;
index index.php index.html index.htm;
server_name latihan.masih-bodoh.com;
location / {
try_files $uri $uri/ /index.php;
}
root /var/www/magento;
location ~ \.php$ {
index index.html index.htm;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:9000;
}
location /phpmyadmin {
root /usr/share/phpmyadmin;
index index.html index.htm;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://localhost/phpmyadmin;
}
location ~ /\.ht {
deny all;
}
}
-------------------------------------------------------------------------------------------------
# ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled/magento
# rm /etc/nginx/sites-enabled/default== Apache ==
Change port apache to 81, for avoid same ports with nginx
# vi /etc/httpd.conf
-------------------------------------------------------------------------------------------------
NameVirtualHost 127.0.0.1:81
Listen 127.0.0.1:81
-------------------------------------------------------------------------------------------------
# vi /etc/apache2/sites-available/magento
-------------------------------------------------------------------------------------------------
<VirtualHost *:8081>
ServerAdmin wahyubudiprastowo@gmail.com
DocumentRoot /var/www/magento/
<Directory /var/www/magento/>
Options FollowSymLinks
AllowOverride all
</Directory>
ErrorLog /var/log/apache2/magento_error.log
CustomLog /var/log/apache2/magento_access.log combined
LogLevel warn
</VirtualHost>
-------------------------------------------------------------------------------------------------
# cp /etc/apache2/sites-available/magento /etc/apache2/sites-enable/magentoNote : Setting Ssl If you need to configure magento with https
# vi /etc/apache2/conf.d/magento-ssl
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NameVirtualHost *:443
<VirtualHost *:443>
ServerName latihan.masih-bodoh.com
ServerAdmin wahyubudiprastowo@gmail.com
DocumentRoot /var/www/magento/
SSLEngine on
SSLCertificateKeyFile /etc/apache2/ssl/server.cert.key
SSLCertificateFile /etc/apache2/ssl/server.cert.crt
SSLProtocol all
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
<Directory /var/www/magento/>
AllowOverride All
SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128
</Directory>
ErrorLog /var/log/apache2/magento_error.log
CustomLog /var/log/apache2/magento_access.log combined
LogLevel warn
</VirtualHost>
-------------------------------------------------------------------------------------------------
4'rd Starting nginx & apache service
---------------------------------------------------------------------------------------------------------------------------------
# service nginx start
# service httpd start---------------------------------------------------------------------------------------------------------------------------------
5'rd Test with info.php
---------------------------------------------------------------------------------------------------------------------------------
# vi /var/www/info.php
------------------------------------------------------------------------
<?
phpinfo( );
?>
------------------------------------------------------------------------
COMMENTS