Installing Nginx With PHP5 And MySQL Support On Fedora 11 - Page 2
5 Configuring nginxThe nginx configuration is in /etc/nginx/nginx.conf which we open now: vi /etc/nginx/nginx.conf The configuration is easy to understand (you can learn more about it here: http://wiki.codemongers.com/NginxFullExample and here: http://wiki.codemongers.com/NginxFullExample2) First (this is optional) you can increase the number of worker processes and set the keepalive_timeout to a reasonable value:
The virtual hosts are defined in server {} containers. Let's modify the default vhost as follows:
server_name _; makes this a default catchall vhost (of course, you can as well specify a hostname here like www.example.com). In the location / part, I've added index.php to the index line. root /usr/share/nginx/html; means that the document root is the directory /usr/share/nginx/html. The important part for PHP is the location ~ \.php$ {} stanza. Uncomment it to enable it. Change the root line to the web site's dosument root (e.g. root /usr/share/nginx/html;). Please make sure that you change the fastcgi_param line to fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; because otherwise the PHP interpreter won't find the PHP script that you call in your browser. Now save the file and restart nginx: /etc/init.d/nginx stop (I couldn't use /etc/init.d/nginx restart because this stopped nginx, but failed to start it - don't know why...) Now create the following PHP file in the document root /usr/share/nginx/html... vi /usr/share/nginx/html/info.php
Now we call that file in a browser (e.g. http://192.168.0.100/info.php): As you see, PHP5 is working, and it's working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5, including the MySQL module:
6 Links
|





Recent comments
20 hours 40 min ago
20 hours 46 min ago
1 day 1 hour ago
1 day 8 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 14 hours ago
1 day 21 hours ago
2 days 1 hour ago
2 days 2 hours ago