# How to set up Tor hidden service ## 建置環境 - 安装php7.2 ```shell= apt -y install php7.3 php7.3-common php7.3-cli php7.3-cgi php7.3-fpm php7.3-gd php7.3-mysql php7.3-sqlite3 php7.3-pgsql php7.3-opcache php7.3-mbstring php7.3-curl php7.3-xml php7.3-xmlrpc php7.3-zip php7.3-intl php7.3-json php7.3-bz2 ``` - 安装 tor 、 mariadb、nginx ``` shell= apt -y update && apt -y install tor nginx mariadb-server ``` ## 創見tor實例 ```shell= tor-instance-create wordpress ``` - 编辑配置文件 ```shell= nano /etc/tor/instances/wordpress/torrc ``` - 寫入設定配置 ```shell= HiddenServiceDir /var/lib/tor-instances/wordpress/hidden_service/ HiddenServicePort 80 127.0.0.1:ls http://vapyggmfbos3zfo7hfmxwjdvt63tkmkcpskfmgye3e6ll62sp5p74yad.onion/ ``` - 重啟tor ```shell= systemctl start tor@wordpress systemctl enable tor@wordpress ``` - 查看onion域名 ```shell= cat /var/lib/tor-instances/DFWeb/hidden-service/hostname ``` ## nginx 設定 ```shell= vi /etc/nginx/nginx.conf server_names_hash_bucket_size 128; ``` ![](https://i.imgur.com/oVCrDrf.png) - 配置conf文件 ```shell= cd /etc/nginx/conf.d/ && nano wordpress.conf ``` - 寫入如下配置: ```shell= server { listen 127.0.0.1:58163; server_name pf73h6t33mvp7lsbr2solnfquubswqu65tirjffpty5tmnj46erbo3qd.onion; root /var/www/wordpress; index index.html index.php; client_max_body_size 100M; allow 127.0.0.1; deny all; server_tokens off; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/run/php/php7.3-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ## 注:server_name 后填写你自己的onion域名 ``` - 啟動Nginx ```shell= systemctl restart nginx systemctl enable nginx ``` 1. [How to set up Tor hidden service in Debian (Kali Linux, Linux Mint, Ubuntu) - Ethical hacking and penetration testing](https://miloserdov.org/?p=5835) 2. [ubuntu-暗网部署网站](https://44i.im/index.php/2020/07/02/torweb/) 2. [PHP Install](https://www.rosehosting.com/blog/how-to-install-php-7-4-with-nginx-on-ubuntu-20-04/) ###### tags: `IT`,`Hidden Server`