nndocs:lamp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
nndocs:lamp [2014/05/19 19:44] – [PHP] update naptastic | nndocs:lamp [2024/09/17 13:51] (current) – [First, create the Universe...] We're on Debian 12 now, lol naptastic | ||
---|---|---|---|
Line 3: | Line 3: | ||
In this guide, I'm just gonna do everything as root unless otherwise specified. | In this guide, I'm just gonna do everything as root unless otherwise specified. | ||
- | Install Debian | + | Install Debian, following the [[nndocs: |
* De-select Graphical Desktop Environment and Laptop. | * De-select Graphical Desktop Environment and Laptop. | ||
Line 19: | Line 19: | ||
* '' | * '' | ||
- | ==== FastCGI | + | ==== Enable mod_proxy_fcgi ==== |
- | Download, build, and install libapache-mod-fastcgi. (At some point I need to put an explanation here of why we're using this module instead of one of the bazillions of other available FastCGI implementations.) | + | |
- | * '' | + | * '' |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Create ''/ | + | |
- | + | ||
- | LoadModule fastcgi_module / | + | |
- | + | ||
- | Now create ''/ | + | |
- | + | ||
- | < | + | |
- | AddHandler fastcgi-script .fcgi | + | |
- | FastCgiIpcDir / | + | |
- | + | ||
- | # Add a pair of these for every user who will run PHP processes. | + | |
- | FastCGIExternalServer / | + | |
- | FastCGIExternalServer / | + | |
- | </ | + | |
- | + | ||
- | Replace ' | + | |
- | + | ||
- | Now create the IPC (Inter-Process Communication) directory that the configuration file references, and give it proper ownership: | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Enable mod_fastcgi, | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
==== Tune Apache ==== | ==== Tune Apache ==== | ||
- | Find this section in / | + | Find this section in / |
< | < | ||
Line 71: | Line 40: | ||
< | < | ||
- | StartServers | + | StartServers |
ServerLimit | ServerLimit | ||
MaxClients | MaxClients | ||
Line 83: | Line 52: | ||
What we're doing here is tuning Apache to handle the largest possible number of simultaneous connections while consuming the least resources and producing the fewest errors. | What we're doing here is tuning Apache to handle the largest possible number of simultaneous connections while consuming the least resources and producing the fewest errors. | ||
- | '' | + | '' |
+ | |||
+ | # apache2ctl status | ||
+ | | ||
+ | |||
+ | | ||
+ | mod_perl/ | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Total accesses: 8 - Total Traffic: 85 kB - Total Duration: 816 | ||
+ | CPU Usage: u.07 s.03 cu0 cs0 - .0952% CPU load | ||
+ | .0762 requests/ | ||
+ | 1 requests currently being processed, 0 workers gracefully restarting, | ||
+ | 63 idle workers | ||
+ | |||
+ | Slot PID Stopping | ||
+ | total accepting busy graceful idle writing keep-alive closing | ||
+ | 1 1343 no | ||
+ | Sum 1 0 0 | ||
+ | |||
+ | ................................................................ | ||
+ | ______________W_________________________________________________ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | ................................................................ | ||
+ | |||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
'' | '' | ||
Line 91: | Line 110: | ||
== Timeout == | == Timeout == | ||
- | Then find the '' | + | Then find the '' |
== KeepAlive == | == KeepAlive == | ||
Line 101: | Line 120: | ||
* '' | * '' | ||
- | As part of this, you will create a MySQL root password. This doesn' | + | Since Debian Buster, I haven' |
- | + | ||
- | === Create /root/.my.cnf | + | |
- | + | ||
- | If you ever want to do anything from the command line you will either | + | |
[client] | [client] | ||
Line 111: | Line 126: | ||
password=" | password=" | ||
- | You can create a .my.cnf file in any user's home directory so they can do mysql stuff from the shell without having to constantly supply their MySQL username and password. | + | You can create a .my.cnf file in any user's home directory so they can do mysql stuff from the shell without having to constantly supply their MySQL username and password. |
- | ==== PHP ==== | + | |
- | You'll need these: | + | |
- | + | * chmod 600 | |
- | | + | |
- | + | ||
- | Download and build PHP to include everything we'll need: | + | |
- | + | ||
- | * '' | + | |
- | * ''< | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Install '' | + | |
- | + | ||
- | * '' | + | |
- | + | ||
- | Install | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Install the FPM-specific configuration files. | + | |
- | + | ||
- | * '' | + | |
- | + | ||
- | Edit the file ''/ | + | |
- | + | ||
- | include=/ | + | |
- | [global] | + | |
- | pid = / | + | |
- | error_log = / | + | |
- | + | ||
- | In ''/ | + | |
- | + | ||
- | I'm debating whether it makes more sense to create a separate pool per-virtualhost instead of per-user. Whatever. Here's what you put in each pool definition file: | + | |
- | + | ||
- | [david] | + | |
- | user = david | + | |
- | group = david | + | |
- | + | ||
- | listen = / | + | |
- | listen.owner = www-data | + | |
- | listen.group = www-data | + | |
- | listen.mode = 0660 | + | |
- | + | ||
- | pm = dynamic | + | |
- | pm.max_children = 24 | + | |
- | pm.start_servers = 1 | + | |
- | pm.min_spare_servers = 1 | + | |
- | pm.max_spare_servers = 2 | + | |
- | pm.max_requests = 32768 | + | |
- | ; | + | |
- | + | ||
- | Of course, change ' | + | |
- | + | ||
- | ==== PHP-APC === | + | |
- | + | ||
- | | + | |
- | | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Add this to the end of ''/ | + | |
- | + | ||
- | extension=' | + | |
- | apc.enable=1 | + | |
- | apc.shm_size=256m | + | |
- | + | ||
- | At this point, PHP-FPM is ready to start if you want. | + | |
- | + | ||
- | * '' | + | |
- | + | ||
- | ==== LAMP stack done. ==== | + | |
- | + | ||
- | Time to create some sites. By Debian convention, virtualhost definition files go in / | + | |
- | + | ||
- | Here's the format for virtualhost files: | + | |
- | + | ||
- | < | + | |
- | ServerName blog.naptastic.com | + | |
- | ServerAdmin naptastic@gmail.com | + | |
- | + | ||
- | DocumentRoot / | + | |
- | < | + | |
- | Options -FollowSymLinks -Indexes -MultiViews | + | |
- | AllowOverride all | + | |
- | </ | + | |
- | < | + | |
- | DirectoryIndex index.php | + | |
- | Options -Indexes -FollowSymLinks -MultiViews | + | |
- | AllowOverride all | + | |
- | </ | + | |
- | + | ||
- | ErrorLog ${APACHE_LOG_DIR}/ | + | |
- | LogLevel warn | + | |
- | CustomLog ${APACHE_LOG_DIR}/ | + | |
- | + | ||
- | < | + | |
- | AddType application/ | + | |
- | Action application/ | + | |
- | Alias /php.fcgi / | + | |
- | </ | + | |
- | + | ||
- | ProxyPassMatch ^/ | + | |
- | + | ||
- | </ | + | |
- | FIXME - This is specific to one site. Needs to be generalized. |
nndocs/lamp.1400528667.txt.gz · Last modified: 2014/05/19 19:44 by naptastic