ubuntu安装nginx服务器

sudo apt-get install nginx;
sudo apt-get install php5-cgi;
sudo apt-get install spawn-fcgi;
sudo sed -i '$ i fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' /etc/nginx/fastcgi_params
sudo sed -i '/cgi.fix_pathinfo=/ c cgi.fix_pathinfo=1;' /etc/php5/cgi/php.ini
#启动
sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
#设置开机启动
sudo sed -i '/^exit/ i /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid' /etc/rc.local

设置虚拟主机/etc/nginx/sites-enabled

新增blog.ziki.cn文件内容如下

server {
root /www/blog.ziki.cn/htdocs;
index index.html index.htm;
server_name blog.ziki.cn;
location / {
try_files $uri $uri/ /index.html;
index index.html index.htm index.php;
}
 
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
 
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
location /images {
root /usr/share;
autoindex off;
}
}
sudo apt-get install build-essential nginx php5-cgi php5-mysql spawn-fcgi p7zip-rar unzip;
 
 
sudo apt-get install libxml2-dev libxslt1-dev libmysqlclient-dev;
sudo apt-get install python-dev;
sudo apt-get install python-setuptools;
 
sudo easy_install -U distribute;
sudo easy_install mysql_python;
sudo easy_install SQLAlchemy;
sudo easy_install Scrapy;
sudo easy_install redis;
sudo easy_install redis;
sudo easy_install BeautifulSoup;
 
sudo sed -i '$ i fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' /etc/nginx/fastcgi_params;
sudo sed -i '/cgi.fix_pathinfo=/ c cgi.fix_pathinfo=1;' /etc/php5/cgi/php.ini;
sudo sed -i '/^exit/ i /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid' /etc/rc.local;
 
 
sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid;
sudo /etc/init.d/nginx restart;

sudo /etc/init.d/nginx restart 重启

原创文章,转载请注明: 转载自海波无痕

本文链接地址: ubuntu安装nginx服务器

文章的脚注信息由WordPress的wp-posturl插件自动生成

此条目发表在server分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论链接可以 移除 nofollow.