1c7 / VideoList

:us: -> :cn: @糖醋陈皮 翻译的视频列表
https://weibo.com/2004104451
57 stars 11 forks source link

Ubuntu 14.04 安装 LNMP #52

Open 1c7 opened 9 years ago

1c7 commented 9 years ago

LNMP = Linux Nginx MySQL PHP

1. 安装 Nginx

sudo apt-get update
sudo apt-get install nginx

2. 安装 MySQL

sudo apt-get install mysql-server

3. 安装 PHP

sudo apt-get install php5-fpm php5-mysql



1.1 检查 Nginx 是否正在运行

service nginx status

1.2 检查 Nginx 是否已经安装

which nginx 命令应该管用



安装

askubuntu.com/questions/134666/what-is-the-easiest-way-to-enable-php-on-nginx https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04



Nginx 和 PHP 整合:

1. 先安装 Nginx 和 php 
2. /etc/nginx/sites-available/default  改这个配置文件
3. 

location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; }

  1. sudo service nginx restart 重启下服务器即可。
/etc/nginx/sites-available/default 是配置文件

/usr/share/nginx/html 是那个欢迎页面的地址
没有权限在那个目录新建文件
解决方法:
cd /usr/share/nginx
sudo chmod 777 html
改下模式,这样就行了。

nginx -s signal

Where signal may be one of the following:

stop — fast shutdown
quit — graceful shutdown
reload — reloading the configuration file
reopen — reopening the log files



Nginx 官方文档 https://www.nginx.com/resources/wiki/start/topics/tutorials/install/

Nginx 官网: http://nginx.org/en/download.html 2015-8月 1.9.4是最新版本



参考资料

http://stackoverflow.com/questions/14045720/nginx-configure-error-ubuntu-12-04 https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-14-04-lts https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 https://www.digitalocean.com/community/tutorials/how-to-install-the-latest-version-of-nginx-on-ubuntu-12-10

1c7 commented 8 years ago

/usr/share/nginx/www

文件目录

1c7 commented 8 years ago

Nginx 默认不允许列出目录,想列出目录需要配置

配置文件路径在 /etc/nginx/sites-available/default

server {
        listen   80;

        root /usr/share/nginx/www;
        index index.php index.html index.htm;

        server_name example.com;

        location / {
                try_files $uri $uri/ /index.html;
                autoindex on;
        }

重点是加上 autoindex on;


参考资料:

http://nginxlibrary.com/enable-directory-listing/