1、创建用户:
useradd -m -s /bin/bash yangyan
修改用户的密码
passwd yangyan
2、安装nginx:
sudo apt-get install nginx;
3、在用户下面建立存放网页的目录,名称为wwwroot
mkdir /home/yangyan/wwwroot
4、配置nginx和域名
vim /etc/nginx/sites-avaliable/default
修改root值为 /home/yangyan/wwwroot;
修改server_name的值为使用的域名;
修改index的值为 index.php; 表示我们默认的首页名字叫index.php;
5、安装php运行环境
apt-get install php5-cli php5-cgi php5-fpm php5-curl php5-gd php5-mcrypt php5-mysql php5-memcache php5-memcached php5-dev php-apc
配置nginx解析php的使用fastcgi处理,编辑/etc/nginx/sites-avaliable/default 文件,在server块中php处理写为:
location ~ \.php$ { include snippets/fastcgi-php.conf; # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; }
其中fastcgi-php.conf文件内容为:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path fastcgi_split_path_info ^(.+\.php)(/.+)$; # Check that the PHP script exists before passing it try_files $fastcgi_script_name =404; # Bypass the fact that try_files resets $fastcgi_path_info # see: http://trac.nginx.org/nginx/ticket/321 set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info; fastcgi_index index.php; include fastcgi.conf;
其中fastcgi.conf文件的内容为:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200;
6、安装mysql数据库
apt-get install mysql-server
7、安装wordpress
我可以先给wwwroot目录下面放一个php文件,只有一行代码,测试一下php的运行环境是否已经建立完成了;
建立一个文件1.php 放置到wwwroot目录下,内容为<?php phpinfo()?>,然后访问看能否将php的信息输出出来。
下载和安装wordpress具体细节就省略了,就是在wordpress网站下载好压缩包,解压到wwwroot目录中去;然后打开地址根据页面的向导填写数据库的连接参数,一路下一步就好了。
了解 工作生活心情记忆 的更多信息
订阅后即可通过电子邮件收到最新文章。