Clone the Repository Open a terminal and clone the Xray-core repository:
git clone <https://github.com/XTLS/Xray-core.git>
cd Xray-core
Download Dependencies
In the Xray-core directory, download the necessary dependencies:
go mod download
Build the Xray Binary Run the following commands to build the Xray binary:
On macOS/Linux:
CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
Create a Configuration File
Xray requires a JSON configuration file to run. Create one named config.json (or use an existing one if you have it). Here’s a simple example configuration:
json
Copy code
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"port": 1080,
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
Run the Xray Binary Now you can run Xray with the configuration file:
./xray -c config.json