很长时间没有在 Ubuntu 安装实际操作安装web服务器了,今天想练练手,在虚拟机上做个试验,我不该保证你也一定会成功,做参考吧! 现象我介绍一下基本系统情况:
1.首先为了安装方便,我切换到root账户,输入命令:
2 安装 MySQL 5
系统会提示你设置密码,输入两次密码: New password for the MySQL “root” user: (输入密码) 3 安装 Nginx
启动Nginx服务:
浏览器输入网址看看是否正常:http://192.168.1.208(修改成你设置的静态IP) 网页显示”Welcome to nginx!”说明已经安装成功并运行。 4 安装 PHP5
5 设置 nginx ,修改文件: worker_processes 4; keepalive_timeout 2; 虚拟主机配置文件修改: server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } 重新加载nginx: 创建一个探针文件,测试:
写入内容 <?php phpinfo(); ?> 然后再打开浏览器输入:http://192.168.1.208/info.php 会显示一下支持的模块,增加模块支持,输入下面的命令查询PHP模块: 安装完毕之后重启php5-fpm |