后端二——Ubuntu安装PHP、MySQL、FTP

一、安装htop

apt install htop


二、安装PHP

apt-get install php7.0 php7.0-dev php7.0-bcmath php7.0-bz2 php7.0-curl php7.0-gd  php7.0-gmp php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-sqlite3 php7.0-xml php7.0-zip php-redis


三、安装MySQL

 apt-get install mysql-server-5.7

四、安装FTP

sudo apt-get install vsftpd

cd /etc/vsftpd.conf

取消如下行的注释(行号为29和33)

write_enable=YES

local_umask=022

>> 取消如下行的注释(行号120)来阻止除了用户文件夹意外的文件夹。

chroot_local_user=YES

在文件最后增加如下一行:

allow_writeable_chroot=YES

>>添加如下行开启消极模式

pasv_enable=Yes

pasv_min_port=40000

pasv_max_port=40100

重启vsftpd

root用户不需要sudo,如非root用户则前置sudo

service vsftpd restart

2、在/var/www目录下创建账号密码

3、修改根目录root /var/www/;

地址:/etc/nginx/sites-enabled default文件中


#user  nobody;
user www-data;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        location / {
            index  index.html index.htm;
        }

    location ~ \.php {
            root           /data/website/lyc520;
            fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info       ^(.+\.php)(/.*)$;
            fastcgi_index  index.php;
            fastcgi_param  PATH_INFO        $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


修改 /usr/local/nginx/nginx.conf配置文件,然后重启

./nginx -s reload

./nginx-s reopen


五、安装redis

wget http://download.redis.io/releases/redis-4.0.6.tar.gz

tar xzf redis-4.0.6.tar.gz

cd redis-4.0.6

make

$ src/redis-server

你可能感兴趣的:(后端二——Ubuntu安装PHP、MySQL、FTP)