Configure PHP, Nginx, and Apache under ArchLinux

Source: Internet
Author: User
Tags apache php

1. First install nginx apache PHP php-apache php-fpm php-cgi php-gd php-mcrypt php-pgsql php-sqlite packages.

2. Edit the Apache configuration file/etc/httpd/conf/httpd.conf,     loadmodule mpm_event_module modules/mod_mpm_ event.so    Line replaced with      loadmodule Mpm_prefork_module modules/mod_mpm_prefork.so, Otherwise Apache startup will report the following error:     apache is running a threaded MPM, but your the PHP Module is isn't compiled to be threa Dsafe.  you need to recompile php.     then join   on any line after LoadModule Dir_module modules/mod_dir.so    loadmodule Php5_module modules/libphp5.so, if necessary is used php-fpm do not do this step;     Finally, add the include conf/extra/php5_module.conf to the last side of the include. 3. Edit/etc/php/php.ini, first set up date.timezone=asia/chongqing, then set open_basedir= line, add your desired directory (such as my Apache root directory/srv/ HTTP and nginx root directory/srv/nginx, and finally some of the required extension in front of the semicolon removed. 4. Edit/etc/httpd/conf/extra/php5_module.conf, add index.phtml to the DirectoryIndex line, for example:     DirectoryIndex index.php index.phtml index.html 5.  According to the above settings can let Apache parse PHP, if you want to use PHP-FPM, delete just joinedLoadModule php5_module modules/libphp5.so, add at the end of the/etc/httpd/conf/httpd.conf:
<filesmatch \.php$>    SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/" </FilesMatch ><ifmodule dir_module>    directoryindex index.php index.html</ifmodule>

Then systemctl restart Httpd.service php-fpm.service Restart the service.

6. Edit/etc/nginx/nginx.conf, first change the user line to user HTTP HTTP, and then modify the server column as follows:

server {    listen       ;    server_name  localhost;    Root/srv/nginx;    Location/{        index  index.html index.htm index.php;    }    Error_page   502 503 504  /50x.html;    Location =/50x.html {        root   /usr/share/nginx/html;    }    Location ~ \.php$ {        Fastcgi_pass unix:/run/php-fpm/php-fpm.sock;        Fastcgi_index index.php;        Include fastcgi.conf;    }}    

Then systemctl restart Nginx.service php-fpm.service Restart the service.

Configuring PHP, Nginx, and Apache under ArchLinux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.