\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82
| Path : /var/www/html/ofisbulutta.com/OfisTeknoloji-old/ |
|
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
| Current File : /var/www/html/ofisbulutta.com/OfisTeknoloji-old/KURULUM.md |
# Proje Kurulum Talimatları
## 1. PostgreSQL Kurulumu
Ubuntu/Debian için:
```bash
sudo apt update
sudo apt install postgresql postgresql-contrib
```
PostgreSQL servisini başlatma:
```bash
sudo systemctl start postgresql
sudo systemctl enable postgresql
```
## 2. PostgreSQL Veritabanı Oluşturma
PostgreSQL'e root olarak bağlanın:
```bash
sudo -u postgres psql
```
PostgreSQL komut satırında:
```sql
CREATE DATABASE ofisbulutta;
CREATE USER ofisbulutta_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE ofisbulutta TO ofisbulutta_user;
\c ofisbulutta
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ofisbulutta_user;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO ofisbulutta_user;
ALTER USER ofisbulutta_user WITH SUPERUSER;
```
## 3. Python Paketleri
Gerekli Python paketlerini kurmak için:
```bash
pip install -r requirements.txt
```
Gerekli paketler:
- flask
- flask-babel
- flask-login
- flask-mail
- flask-sqlalchemy
- flask-wtf
- email-validator
- geoip2
- gunicorn
- psycopg2-binary
- requests
- routes
- sendgrid
- sqlalchemy
- user-agents
- werkzeug
- wtforms
## 4. Veritabanı Yapılandırması
1. `database.ini` dosyasını düzenleyin:
```ini
[postgresql]
host = localhost
database = ofisbulutta
user = ofisbulutta_user
password = your_password
port = 5432
```
2. Veritabanı şemasını yükleyin:
```bash
psql -U ofisbulutta_user -d ofisbulutta -f database_backup.sql
```
## 5. Çevre Değişkenleri
Aşağıdaki çevre değişkenlerini ayarlayın:
1. Direkt DATABASE_URL kullanarak:
```bash
export DATABASE_URL="postgresql://ofisbulutta_user:your_password@localhost:5432/ofisbulutta"
```
VEYA
2. Ayrı ayrı PostgreSQL değişkenleri:
```bash
export PGHOST=localhost
export PGDATABASE=ofisbulutta
export PGUSER=ofisbulutta_user
export PGPASSWORD=your_password
export PGPORT=5432
```
Diğer gerekli çevre değişkenleri:
```bash
# Güvenli ve karmaşık bir anahtar oluşturun (en az 32 karakter)
export SESSION_SECRET="zx8Hjk2P9m5vN3$qR7#wY4nB6cX1@aL0"
export RECAPTCHA_PUBLIC_KEY="your_recaptcha_public_key"
export RECAPTCHA_PRIVATE_KEY="your_recaptcha_private_key"
```
## 6. Uygulamayı Çalıştırma
Geliştirme sunucusu için:
```bash
python main.py
```
Prodüksiyon için (Gunicorn ile):
```bash
gunicorn --bind 0.0.0.0:5000 --workers 4 main:app
```
Uygulama http://localhost:5000 adresinde çalışacaktır.
## 7. Apache/Nginx Sunucu Yapılandırması
### Apache ile Deployment
1. Apache ve WSGI modülünü yükleyin:
```bash
sudo apt install apache2 libapache2-mod-wsgi-py3
```
2. Apache site yapılandırması oluşturun:
```bash
sudo nano /etc/apache2/sites-available/ofisbulutta.conf
```
Aşağıdaki içeriği ekleyin:
```apache
<VirtualHost *:80>
ServerName your_domain.com
ServerAdmin webmaster@your_domain.com
DocumentRoot /var/www/html/ofisbulutta
WSGIDaemonProcess ofisbulutta python-path=/var/www/html/ofisbulutta:/var/www/html/ofisbulutta/venv/lib/python3.8/site-packages
WSGIProcessGroup ofisbulutta
WSGIScriptAlias / /var/www/html/ofisbulutta/wsgi.py
<Directory /var/www/html/ofisbulutta>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```
3. Site yapılandırmasını etkinleştirin:
```bash
sudo a2ensite ofisbulutta.conf
sudo systemctl reload apache2
```
### Nginx ile Deployment
1. Nginx yükleyin:
```bash
sudo apt install nginx
```
2. Nginx site yapılandırması oluşturun:
```bash
sudo nano /etc/nginx/sites-available/ofisbulutta
```
Aşağıdaki içeriği ekleyin:
```nginx
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static {
alias /var/www/html/ofisbulutta/static;
}
location /attached_assets {
alias /var/www/html/ofisbulutta/attached_assets;
}
}
```
3. Site yapılandırmasını etkinleştirin:
```bash
sudo ln -s /etc/nginx/sites-available/ofisbulutta /etc/nginx/sites-enabled/
sudo systemctl reload nginx
```
## 8. Gunicorn Yapılandırması
1. Gunicorn servis dosyası oluşturun:
```bash
sudo nano /etc/systemd/system/ofisbulutta.service
```
Aşağıdaki içeriği ekleyin:
```ini
[Unit]
Description=Ofisbulutta Gunicorn Daemon
After=network.target postgresql.service
[Service]
User=www-data
Group=www-data
WorkingDirectory=/var/www/html/ofisbulutta
Environment="PATH=/var/www/html/ofisbulutta/venv/bin"
Environment="PYTHONPATH=/var/www/html/ofisbulutta"
Environment="DATABASE_URL=postgresql://ofisbulutta_user:your_password@localhost:5432/ofisbulutta"
# Alternatif olarak ayrı ayrı PostgreSQL değişkenleri:
Environment="PGHOST=localhost"
Environment="PGPORT=5432"
Environment="PGDATABASE=ofisbulutta"
Environment="PGUSER=ofisbulutta_user"
Environment="PGPASSWORD=your_password"
Environment="SESSION_SECRET=your_secure_session_key"
Environment="RECAPTCHA_PUBLIC_KEY=your_recaptcha_public_key"
Environment="RECAPTCHA_PRIVATE_KEY=your_recaptcha_private_key"
ExecStart=/var/www/html/ofisbulutta/venv/bin/gunicorn --workers 4 --bind unix:/tmp/ofisbulutta.sock main:app
[Install]
WantedBy=multi-user.target
```
2. Servisi etkinleştirin ve başlatın:
```bash
sudo systemctl daemon-reload
sudo systemctl enable ofisbulutta
sudo systemctl start ofisbulutta
```
3. Servis durumunu kontrol edin:
```bash
sudo systemctl status ofisbulutta
```
4. Hata ayıklama için logları kontrol edin:
```bash
sudo journalctl -u ofisbulutta -f
```
## 9. Sorun Giderme
1. PostgreSQL bağlantı hatası:
- PostgreSQL servisinin çalıştığından emin olun
```bash
sudo systemctl status postgresql
```
- Database.ini dosyasındaki bilgileri kontrol edin
- Veritabanı kullanıcısının yetkilerini kontrol edin
```bash
sudo -u postgres psql
\du ofisbulutta_user
```
- Çevre değişkenlerinin doğru ayarlandığını kontrol edin
```bash
echo $DATABASE_URL
# veya
echo $PGUSER
echo $PGPASSWORD
```
2. Paket kurulum hataları:
- Python sürümünün 3.8 veya üstü olduğundan emin olun
- pip'i güncelleyin: `pip install --upgrade pip`
- Gerekirse sanal ortam oluşturun: `python -m venv venv`
3. Port çakışması:
- 5000 portu kullanımdaysa farklı bir port belirtin:
```bash
gunicorn --bind 0.0.0.0:8000 --workers 4 main:app
```
4. SQLALCHEMY_DATABASE_URI hatası:
- DATABASE_URL çevre değişkeninin doğru ayarlandığından emin olun
- Database.ini dosyasındaki bilgilerin doğru olduğunu kontrol edin
- PostgreSQL servisinin çalıştığını ve erişilebilir olduğunu kontrol edin
- Veritabanı kullanıcısının yeterli yetkiye sahip olduğunu kontrol edin
5. Sunucu Loglarını Kontrol Etme:
- Apache logları: `tail -f /var/log/apache2/error.log`
- Nginx logları: `tail -f /var/log/nginx/error.log`
- Gunicorn logları: `sudo journalctl -u ofisbulutta`
6. Dosya İzinleri:
```bash
sudo chown -R www-data:www-data /var/www/html/ofisbulutta
sudo chmod -R 755 /var/www/html/ofisbulutta
```
7. Statik Dosya Hataları:
- Statik dosya yollarının doğru olduğunu kontrol edin
- Dizin izinlerini kontrol edin
- Apache/Nginx yapılandırmasını kontrol edin
8. 404 Hataları:
- URL yönlendirmelerini kontrol edin
- routes.py dosyasındaki rotaları kontrol edin
- Sunucu yapılandırmasını kontrol edin
9. 500 Hataları:
- Uygulama loglarını kontrol edin
- Veritabanı bağlantısını kontrol edin
- Çevre değişkenlerini kontrol edin
10. Sunucu Yeniden Başlatma:
```bash
sudo systemctl restart ofisbulutta
sudo systemctl restart apache2 # veya nginx