虚拟机怎么做网站空间,制作网站多少钱,wordpress 单页分类,苏州营销型网站建设LNMP Linux Nginx MySQL PHP 安装Nginx 执行以下命令即可: apt-get install nginx不过源里的版本是0.7.65#xff0c;不喜欢老旧的玩意#xff0c;可以尝试编译安装。 编译安装nginx. 1.准备编译环境 apt-get install libpcre3-dev build-essential libssl-dev在这里 htt…LNMP Linux Nginx MySQL PHP 安装Nginx 执行以下命令即可: apt-get install nginx 不过源里的版本是0.7.65不喜欢老旧的玩意可以尝试编译安装。 编译安装nginx. 1.准备编译环境 apt-get install libpcre3-dev build-essential libssl-dev 在这里 http://nginx.org/en/download.html 能找到nginx的tar球最新的官方稳定版是 1.2.0. 执行 cd /opt/ wget http://nginx.org/download/nginx-1.2.0.tar.gz tar -zxvf nginx-1.2.0.tar.gz cd /opt/nginx-1.2.0/ configure: ./configure --prefix/opt/nginx --usernginx --groupnginx --with-http_ssl_module configure完成后会输出nginx的一些相关信息 nginx path prefix: “/opt/nginx” nginx binary file: “/opt/nginx/sbin/nginx” nginx configuration prefix: “/opt/nginx/conf” nginx configuration file: “/opt/nginx/conf/nginx.conf” nginx pid file: “/opt/nginx/logs/nginx.pid” nginx error log file: “/opt/nginx/logs/error.log” nginx http access log file: “/opt/nginx/logs/access.log” nginx http client request body temporary files: “client_body_temp” nginx http proxy temporary files: “proxy_temp” nginx http fastcgi temporary files: “fastcgi_temp” make,安装,执行 make make install 给nginx进程添加用户nginx: adduser --system --no-create-home --disabled-login --disabled-password --group nginx 下载并安装启动脚本 wget -O init-deb.sh http://library.linode.com/assets/552-init-deb.sh mv init-deb.sh /etc/init.d/nginx chmod x /etc/init.d/nginx /usr/sbin/update-rc.d -f nginx defaults 启动一下试试 /etc/init.d/nginx start 如果输出正常那nginx就安装成功了。 配置虚拟主机: 如果从源里安装的nginx那nginx配置文件位于/etc/nginx/sites-enabled 下面是一个虚拟主机的配置实例 server { listen 80; server_name www.example.com example.com; access_log /srv/www/example.com/logs/access.log; error_log /srv/www/example.com/logs/error.log; location / { root /srv/www/example.com/public_html; index index.html index.htm; } } 注意配置文件中出现的目录必须存在nginx并不会自动创建他们所以还需要执行 mkdir -p /srv/www/example.com/public_html mkdir -p /srv/www/example.com/logs 如果是编译安装的版本相关路径见上文configure部分配置文件位于/opt/nginx/conf可以直接在nginx.conf添加 server段为了便于管理还是把虚拟主机独立出来好修改nginx.conf, 如下在http段添加include部分。 http { # [...] include /opt/etc/nginx/sites-enabled/*; # [...] } 添加完虚拟主机后别忘了重启以下nginx服务。 /etc/init.d/nginx restart 删除虚拟主机只需要删除对应的配置文件并重新启动一下下nginx就好。 安装php with fastcgi 执行 apt-get install php5-cli php5-cgi psmisc spawn-fcgi 执行下面的命令会下载并安装fastcgi的控制脚本: cd /opt/ wget -O php-fastcgi-deb.sh http://library.linode.com/assets/554-php-fastcgi-deb.sh mv /opt/php-fastcgi-deb.sh /usr/bin/php-fastcgi chmod x /usr/bin/php-fastcgi wget -O init-php-fastcgi-deb.sh http://library.linode.com/assets/553-init-php-fastcgi-deb.sh mv /opt/init-php-fastcgi-deb.sh /etc/init.d/php-fastcgi chmod x /etc/init.d/php-fastcgi /etc/init.d/php-fastcgi start update-rc.d php-fastcgi defaults 然后在虚拟主机的配置文件里面添加php支持示例如下 server { server_name www.example.com example.com; access_log /srv/www/example.com/logs/access.log; error_log /srv/www/example.com/logs/error.log; root /srv/www/example.com/public_html; location / { index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public_html$fastcgi_script_name; } } 最后重启一下nginx服务 /etc/init.d/nginx restart 安装MySQL: 执行 apt-get install mysql-server php5-mysql 安装过程中会要求输入数据库的初始密码 还可以执行一下 mysql_secure_installation 禁用root的远程登录即可。 如果需要重新设置MySQL的密码执行 dpkg-reconfigure mysql-server-5.0 最后重启一下fastcgi: /etc/init.d/php-fastcgi restart 至此LNMP安装完成。 本文翻译自Linode的Library文章http://library.linode.com/lemp-guides/ubuntu-10.04-lucid#sph_id7 文中的操作系统是Ubuntu 10.04你可以访问上面的连接获取更多信息。个人更推荐一键傻瓜安装包: