V
V
vitaly_742020-07-28 14:26:56
PHP
vitaly_74, 2020-07-28 14:26:56

How to make Apache the main php handler on ubuntu?

good afternoon, now nginx + php-fpm is running on the server, tell me how to switch all processing to apache2? would be grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanes, 2020-07-28
@vitaly_74

Run Apache on 8080 (for example) port, and Nginx to make a proxy.

config

<VirtualHost 127.0.0.1:8080>
    ServerName {{ domain }}
    ServerAlias {{ domain_alias }}

    DocumentRoot /home/{{ username }}/www

    <Directory /home/{{ username }}/www>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    <FilesMatch \.php$>
        # 2.4.10+ can proxy to unix socket
        SetHandler "proxy:unix:/var/run/php/php{{ php }}-fpm-{{ username }}.sock|fcgi://localhost/"

        # Else we can just use a tcp socket:
        # SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>

    ErrorLog ${APACHE_LOG_DIR}/{{ username }}-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    # CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined

</VirtualHost>

server {
    listen 80; # listen for ipv4
    server_name {{ domain }} {{ domain_alias }};
    error_log /home/{{ username }}/logs/nginx-error.log warn;
    gzip on;
    gzip_comp_level 5;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_connect_timeout 60;
        proxy_send_timeout 60;
        proxy_read_timeout 60;
}
    location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js|txt|woff)$ {
        root /home/{{username}}/www;
        expires max;
    }
    client_max_body_size 100M;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question