Install NGINX on Apache LAMP Server with SSL

Опубликовано: 11 Октябрь 2024
на канале: optikalefx
7,456
34

NginX is 20x faster than apache. Lets take our ubuntu 10.10 rackspace server that is already running LAMP, and install NginX on it. Lets also make sure our SSL still works.

NOTES:
If you already have apache and mysql. You DO NOT NEED THE MYSQL PART.
You also don't have to do the www2 www thing. You can just leave that lone.



aptitude install mysql-server mysql-client
aptitude install nginx
/etc/init.d/nginx start
aptitude install php5-fpm
aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json
/etc/init.d/php5-fpm restart
vi /etc/nginx/sites-available/default



server {
listen 80; ## listen for ipv4
listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name _;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www;
index index.php index.html index.htm;
if (!-f $request_filename) {
rewrite ^(.+)$ /index.php last;
break;
}
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
root /var/www;
}
location /images {
root /usr/share;
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}