Linux 离线安装php+nginx+ftp

一、资源上传到离线服务器:

二、安装:

rpm -ivh *.rpm

三、配置:

1、nginx配置:

主配置文件:/etc/nginx/nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       8089;
        listen       [::]:80;
        server_name  192.168.1.17;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
	    location ~ \.php$ {
		    include fastcgi_params;
		    fastcgi_pass unix:/var/run/php-fpm/www.sock; # 或者 127.0.0.1:9000,取决于你的 php-fpm 配置
		    fastcgi_index index.php;
		    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		    include fastcgi_params;
		}
    }

}
设置nginx开机自启:
sudo systemctl enable nginx.service

2、ftp配置:

配置文件:/etc/vsftpd/vsftpd.conf

anonymous_enable=YES:启用匿名登录权限。
write_enable=YES:全局设置,允许登录用户有写权限(如果希望匿名用户能够上传文件,则需要设置此参数)。
no_anon_password=YES:匿名登录免密。
anon_upload_enable=YES:允许匿名用户上传文件(需要write_enable=YES)。
anon_mkdir_write_enable=YES:允许匿名用户创建目录和写入权限(需要write_enable=YES)。
anon_other_write_enable=YES:允许匿名用户的其他权限,如删除、重命名等(需要write_enable=YES)。
anon_root=/var/ftp/pub(可选):设置匿名用户的家目录为/var/ftp/pub(或其他您希望的目录)
vsftp 命令
#开机启动
systemctl enable vsftpd
#启动:
systemctl start vsftpd
#状态:
systemctl status vsftpd
#重启:
systemctl restart vsftpd
添加ftp用户:
sudo adduser ftpuser
sudo passwd ftpuser

输入ftpuser的用户密码。

添加ftp目录就目录权限
sudo mkdir -p /home/ftpuser/ftp
sudo chown ftpuser:ftpuser /home/ftpuser/ftp
sudo chmod 755 /home/ftpuser/ftp
#设置网站目录给ftp用户软连接
sudo ln -s /usr/share/nginx/html /home/ftpuser/ftp/html
3、php配置:

php-fpm开机自启:

sudo systemctl enable php-fpm.service

注意

如果nginx或者ftp启动不了,查看防火墙和 SELinux 状态:

#关闭防火墙:
systemctl stop firewalld
#禁止自动重启:
systemctl disable firewalld
sudo systemctl disable iptables

#临时关闭SELinux策略:
setenforce 0
#禁止重启:
sudo vi /etc/selinux/config
SELINUX=disabled

安装包里面有mysql的,但是我没有安装mysql,如果需要的话可以自己尝试安装并配置下。

你可能感兴趣的:(linux,php,nginx)