[FreeBSD] Nginx Setup - BSD
Users browsing this thread: 1 Guest(s)
|
|||
Web Server
¯¯¯¯¯¯¯¯¯¯¯¯¯ Now that you've got your jail configured, let's install the Web Server ! You can achieve that either by the ports or the precompiled packages. Personally, I prefer using the ports, so in /usr: PHP Code: -> portsnap fetch extract When it's finished, install nginx: PHP Code: -> /usr/ports/www/nginx or: pkg_add -r -v nginx Select the options you need. You can add this in the jail's /etc/rc.conf: nginx_enable="YES" Or, run it directly with: /usr/local/etc/rc.d/nginx start. Test the nginx is running by going on 192.168.1.10 in your browser. It should say: "Welcome to nginx !" Nginx's default root directory is in /usr/local/www/nginx and Nginx's configuration is /usr/local/etc/nginx/nginx.conf Install PHP5, the extensions, spawn-fcgi and mysql PHP Code: -> /usr/ports/lang/php5 Again, you can use pkg_add if you need this to be done quickly. Now add these lines in te jail's rc.conf: PHP Code: -> mysql_enable="YES" Nginx's config file needs to be edited, you can use mine: PHP Code: user www; Once everything is done, restart the jail and test that Nginx works. Let's test if PHP works ! Write a little php file in Nginx's root directory. /usr/local/www/nginx/phpinfo.php the php code: PHP Code: <?php Run 192.168.1.10/phpinfo.php in your browser, if it shows something, you have php working. This might also be a good time to test that you have the options you need with php. If it doesn't work, try running this in the jail: PHP Code: -> /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 4 -f /usr/local/bin/php-cgi Now that PHP works, let's take care of mysql. I like to install phpmyadmin to manage sql databases. But you need to create a mysql account first. -> make a user account in your jail by running adduser. -> run mysql as root in your jail. To make a mysql user with all privileges, run this: ( my username is beastie, replace some_pass with the password you want ) PHP Code: mysql> GRANT ALL PRIVILEGES ON *.* TO 'beastie'@'localhost' The user is created. Now let's install phpmyadmin, you need to fetch it first. You can also install it by ports. Install wget or curl before, it can be useful: ( copy paste, heh :P ) PHP Code: -> /usr/ports/ftp/wget Access 192.168.1.10/pma is a browser and use your new user and pass from mysql. If everything works you should be logged in and able to make new databases and tables... You might get a few warnings from phpmyadmin, just recompile php5-extensions with the appropriate options. If you want, you may now allow incoming port 80 from your router and forward port 80 to 192.168.1.10 ;), register a hostname and bam, you have a home server \o/. |
|||