1.设置静态id
sudo nano /etc/network/interfaces
#The primary network interface
auto ens33
iface ens33 inet dhcp
#iface ens33 inet static
#address 192.168.1.200
#netmask 255.255.255.0
#gateway 192.168.1.1
#dns-nameservers 114.114.114.114
重启ubuntu
sudo reboot
2.安装nginx
获取最新安装包
sudo apt-get update
下载nginx
sudo apt-get install nginx
3.安装 php7 :(不要尝试直接apt-get install php7,这样会默认安装apache,ubuntu 16默认不能安装php5)
sudo apt-get install php7.0-cli php7.0-cgi php7.0-fpm php7.0-mcrypt php7.0-mysql curl libcurl3 libcurl3-dev php7.0-curl
4.安装MySQL数据库
sudo apt-get install mysql-server
5.nginx管理操作
移动文件
sudo mv /var/www /var/nginx
sudo mv /var/nginx/html /var/nginx/www
修改nginx文件权限
sudo chown -R ubuntu:ubuntu /var/nginx
建立软链接
sudo ln -s /var/nginx /nginx
sudo ln -s /var/nginx ~/nginx
备份此文件
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.backup
更改文档
sudo nano /etc/nginx/sites-available/default
配置文件样式
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/nginx/www;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm;
server_name www.test.com test.com *.test.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
重启nginx
sudo service nginx restart
6.安装phpMyAdmin
打开文件
cd ~/nginx/www
下载phpMyAdmin压缩包
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.6/phpMyAdmin-4.7.6-all-languages.zip
解压<若系统未下载unzip。则先下载unzip>
<sudo apt install unzip>
unzip ./phpMyAdmin-4.7.6-all-languages.zip
删除压缩包
rm phpMyAdmin-4.7.6-all-languages.zip
修改文件名称
mv ./phpMyAdmin-4.7.6-all-languages ./pma
7.判断nginx是否下载成功
确认在/var/nginx/www 文件下是否有index.nginx-debian.html网页,修改文档名称
mv ./index.nginx-debian.html ./index.php
在网址中输入自己的ip确认是否有welcom to nginx
8.PHP探针判断php环境是否配置好
cd /var/nginx/www
sudo nano index.php
删除原有代码,将下方代码复制入index.php文档
<?php
phpinfo();
?>
再次访问ip
9.安装wordpress
下载、解压
cd ~
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
修改权限
sudo chown -R ubuntu:www-data wordpress
删除压缩包
rm /home/ubuntu/latest.tar.gz
mv /var/nginx/wordpress/ /var/nginx/www
网友评论