草 稿

配置 Debian VPS

  1. 设定 Hostname

    echo "主机名" > /etc/hostname

    hostname -F /etc/hostname

     

    之后 nano /etc/hosts,看到

     

    127.0.0.1 localhost

    127.0.0.1 debian

     

    改为

     

    127.0.0.1 localhost 主机名

    公网IP地址 farm.abc.com farm

  2. 设定时区

    dpkg-reconfigure tzdata

  3. 更新软件

    apt-get update

    apt-get upgrade --show-upgraded

  4. 添加新用户

    adduser qiwen

    删除用户的指令是:userdel username,之后运行 sudo rm -r /home/username

  5. 为用户添加管理员权限

    usermod -a -G sudo username

  6. 配置防火墙

    https://www.linode.com/docs/security/securing-your-server/

     

    (千万记得开 10000 端口!)

     

    File2ban 可以在 Webmin 里面安,只要配置 iptables 即可

  7. 安装 Apache 并配置

    1. 安装 Apache:apt-get install apache2

    2. 优化 Apache 配置(https://www.linode.com/docs/websites/hosting-a-website/):

    先备份:cp /etc/apache2/apache2.conf /etc/apache2/apache2.backup.conf

    再编辑:nano /etc/apache2/apache2.conf

  8. 安装 MySQL

    1、装 MySQL:apt-get install mysql-server,中途弹出提示,为 SQL 的 root 账户创建密码。

    2、配置 MySQL 安全设置: mysql_secure_installation,除了修改密码,其他都为 yes。

  9. 安装 PHP

    sudo apt-get install php5 php-pear

    sudo apt-get install php5-mysql

  10. 安装 phpmyadmin

    1、安装 phpmyadmin:apt-get install phpmyadmin,中途选择 apache2;设置 phpmyadmin 默认数据库:Yes,键入密码;

    2、键入:nano /etc/phpmyadmin/apache.conf,修改

     

    # phpMyAdmin default Apache configuration

    Alias /phpmyadmin /usr/share/phpmyadmin

     

    为:

     

    # phpMyAdmin default Apache configuration

    Alias /希望的目录(可包括子目录) /usr/share/phpmyadmin

     

    4、重启下 Apache:service apache2 restart

    5、使用 nano /etc/apache2/apache2.conf 配置 apache,在文末加入:Include /etc/phpmyadmin/apache.conf

    6、重启下 Apache:service apache2 restart

  11. 安装 Webmin

    1. 安装支持:apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

     

    2. 下载安装 Webmin:wget http://prdownloads.sourceforge.net/webadmin/webmin_1.730_all.deb

     

    dpkg --install webmin_1.730_all.deb

    (最新版本参见:http://www.webmin.com/deb.html)

     

    3. 修改登录端口:进入 webmin,选择 Webmin Configuration,在 Ports and Addresses中将port 改为期望的

  12. 安装 ProFTPD

    进入 Webmin 搜索

     

    安装完 Proftpd 后需要做的事

     

    1. 授权用户上传文件权限:

     

    chown -R (FTPUSER) /(path)/(to_your_ftp)/

     

    例如:

     

    chown -R wordpress /home/wordpress/public_html

     

    2. 限制用户只能访问自己的目录

     

    修改 proftpd配置文件

     

    nano /etc/proftpd/proftpd.conf

     

    // 去掉如下行前的注释 #

     

    # DefaultRoot ~

     

    // 重启 proftpd 即可

     

    /etc/init.d/proftpd restart

     

    注: 可参考 http://blog.csdn.net/ID19870510/article/details/8395339

  13. 安装几个 Apache 模块

    a2enmod rewrite

    a2enmod headers

    a2enmod expires

     

     

    service apache2 restart

  14. 授权 WP 在线升级

    chown -R www-data /var/www/tufo.me/public_html(博客目录)

  15. 绑定域名

    # Admin email, Server Name (domain name), and any aliases

    ServerAdmin chikchunyu@gmail.com

    ServerName tufo.me

    ServerAlias www.tufo.me

     

    # Index file and Document Root (where the public files are located)

    DirectoryIndex index.html index.php

    DocumentRoot /var/www/tufo.me/public_html

    # Log file locations

    LogLevel warn

    ErrorLog /var/www/tufo.me/log/error.log

    CustomLog /var/www/tufo.me/log/access.log combined

  16. 目录权限配置

    http://askubuntu.com/questions/162866/correct-permissions-for-var-www-and-wordpress

  17. 安装 PHP APC

    Using apt-get:

    apt-get install php-apc

     

    Edit configuration (optional)

    nano /etc/php5/conf.d/20-apc.ini

    After extension=apc.so, add the following (modify them according to your needs)

    extension=apc.so

    apc.enabled=1

    apc.shm_size=128M

    apc.ttl=3600

    apc.user_ttl=7200

    apc.gc_ttl=3600

    apc.max_file_size=1M

    Restart Apache

     

    systemctl restart apache2.service

赞了此轻单

评论(0