Differences
This shows you the differences between two versions of the page.
howto:web:lamp-development-on-ubuntu-running-as-your-own-user [2018-08-05 04:25] |
howto:web:lamp-development-on-ubuntu-running-as-your-own-user [2020-08-13 06:17] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~META: | ||
+ | creator = Brendan Kidwell | ||
+ | &date created = 2014-09-25 | ||
+ | ~~ | ||
+ | {{tag> | ||
+ | ~~DISCUSSION~~ | ||
+ | ====== LAMP Development on Ubuntu Running As Your Own User ====== | ||
+ | |||
+ | There are a lot of guides for setting up Apache, MySQL and PHP on an Ubuntu desktop or server but all the guides I've seen assume you're going to run PHP scripts inside Apache as the user <wrap file> | ||
+ | |||
+ | This guide will show you another way to setup a host for LAMP development, | ||
+ | |||
+ | All you need is Ubuntu Linux or Linux Mint running on your desktop or server. (Debian might work, but I'm not familiar with how different the Ubuntu packages mentioned here are from Debian.) If your desktop is running Windows or OS X or another OS, this guide should work just fine if you run Ubuntu in a virtual machine; in that case I recomment Linux Mint MATE edition on VirtualBox. | ||
+ | |||
+ | You must be using an OS based on or equivalent to Ubuntu 14.04 (released in April 2014) because of recent changes/ | ||
+ | |||
+ | ===== Setup Apache ===== | ||
+ | |||
+ | <code bash> | ||
+ | # Install Apache | ||
+ | sudo apt-get install apache2 | ||
+ | # Enable proxy_fcgi module | ||
+ | sudo a2enmod proxy_fcgi | ||
+ | # Enable rewrite module, needed by many PHP applications | ||
+ | sudo a2enmod rewrite | ||
+ | # Fix " | ||
+ | echo " | ||
+ | # Restart Apache | ||
+ | sudo service apache2 restart | ||
+ | </ | ||
+ | **Check:** Go to <wrap file> | ||
+ | |||
+ | ===== Configure Hostname ===== | ||
+ | |||
+ | It helps to configure a custom hostname in your <wrap file> | ||
+ | |||
+ | Add the following to the end of <wrap file>/ | ||
+ | |||
+ | < | ||
+ | 127.0.0.1 www.local | ||
+ | </ | ||
+ | |||
+ | For any additional virtual hosts you will need, add more lines with the same IP address and some other '' | ||
+ | |||
+ | **Check:** Go to <wrap file> | ||
+ | |||
+ | ===== Install PHP ===== | ||
+ | |||
+ | <code bash> | ||
+ | # Install PHP's FastCGI daemon | ||
+ | sudo apt-get install php5-fpm | ||
+ | </ | ||
+ | Edit the daemon' | ||
+ | |||
+ | <file ini / | ||
+ | # (Search for and edit these three lines.) | ||
+ | user = *** your desktop username *** | ||
+ | group = *** your desktop username *** | ||
+ | listen = 9000 | ||
+ | </ | ||
+ | |||
+ | The first two values tell the PHP FastCGI daemon to run as //you// instead of <wrap file> | ||
+ | |||
+ | You have to change <wrap sym> | ||
+ | |||
+ | If you are setting up a production server, you might want to have a separate username and separate PHP FastCGI daemon for each application. To setup additional usernames and ports, copy <wrap file> | ||
+ | |||
+ | <code bash> | ||
+ | # Restart PHP FastCGI daemon(s) | ||
+ | sudo service php5-fpm restart | ||
+ | </ | ||
+ | |||
+ | ===== Setup Apache Virtual Host ===== | ||
+ | |||
+ | Create a folder <wrap file> | ||
+ | |||
+ | Create an Apache virtual host configuration file: | ||
+ | |||
+ | <file text / | ||
+ | < | ||
+ | ServerName www.local | ||
+ | ServerAdmin webmaster@localhost | ||
+ | DocumentRoot / | ||
+ | ErrorLog ${APACHE_LOG_DIR}/ | ||
+ | CustomLog ${APACHE_LOG_DIR}/ | ||
+ | ProxyPassMatch ^/ | ||
+ | < | ||
+ | Order allow,deny | ||
+ | Allow from all | ||
+ | AllowOverride FileInfo All | ||
+ | Require all granted | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Note the three <wrap sym> | ||
+ | |||
+ | <code bash> | ||
+ | # Enable the new site | ||
+ | sudo a2ensite www.local | ||
+ | sudo service apache2 reload | ||
+ | </ | ||
+ | |||
+ | As in the previous section, create additional <wrap file> | ||
+ | |||
+ | **Check:** Create this file | ||
+ | |||
+ | <file php ~/ | ||
+ | <?php phpinfo(); | ||
+ | </ | ||
+ | |||
+ | and view <wrap file> | ||
+ | |||
+ | ===== More PHP Stuff ===== | ||
+ | |||
+ | You're probably going to need these additional packages to get work done in PHP: | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get install php5-apcu php5-cli php5-curl \ | ||
+ | php5-gd php5-imagick php5-imap php5-mcrypt php5-sqlite | ||
+ | </ | ||
+ | |||
+ | Also, change the maximum upload and post size from the default 8MB or so to something more sane: | ||
+ | |||
+ | <file ini / | ||
+ | # (Search for and edit these two lines.) | ||
+ | post_max_size = 200M | ||
+ | upload_max_filesize = 200M | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | # Restart PHP | ||
+ | sudo service php5-fpm restart | ||
+ | </ | ||
+ | |||
+ | **Check:** View <wrap file> | ||
+ | |||
+ | ===== Install MySQL ===== | ||
+ | |||
+ | <code bash> | ||
+ | # Install MySQL | ||
+ | sudo apt-get install mysql-server php5-mysql | ||
+ | </ | ||
+ | |||
+ | During installation, | ||
+ | |||
+ | ===== Install phpMyAdmin ===== | ||
+ | |||
+ | You'll probably want to use everyone' | ||
+ | |||
+ | phpMyAdmin has a wizard for creating a config file. Do this: | ||
+ | |||
+ | <code bash> | ||
+ | mkdir ~/ | ||
+ | chmod o+rw ~/ | ||
+ | # Access http:// | ||
+ | # Click 'New Server' | ||
+ | # Browse through the settings and change any defaults if you need to. | ||
+ | # Click ' | ||
+ | # Click ' | ||
+ | # Close your browser. | ||
+ | cp ~/ | ||
+ | rm -rf ~/ | ||
+ | </ | ||
+ | |||
+ | **Check:** Access <wrap file> | ||
+ | |||
+ | ===== Disable Automatic Service Startup ===== | ||
+ | |||
+ | This last section is optional. If you want to save memory and only run Apache, PHP, and MySQL when you are doing development, | ||
+ | |||
+ | <code bash> | ||
+ | echo manual | sudo tee / | ||
+ | echo manual | sudo tee / | ||
+ | echo manual | sudo tee / | ||
+ | </ | ||
+ | |||
+ | Now create two Bash scripts to start and stop the services: | ||
+ | |||
+ | <file bash ~/ | ||
+ | #!/bin/bash | ||
+ | sudo service apache2 start | ||
+ | sudo service mysql start | ||
+ | sudo service php5-fpm start | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | chmod +x ~/ | ||
+ | </ | ||
+ | |||
+ | <file bash ~/ | ||
+ | #!/bin/bash | ||
+ | sudo service apache2 stop | ||
+ | sudo service mysql stop | ||
+ | sudo service php5-fpm stop | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | chmod +x ~/ | ||
+ | </ | ||
+ | |||
+ | **Check:** Run the two scripts from the command prompt and check in your process list utility that the servers are started and stopped. | ||
+ | |||
+ | ===== Conclusion ===== | ||
+ | |||
+ | You now are serving <wrap file> | ||