Skip to content

Instantly share code, notes, and snippets.

@shengchiliu
Last active April 20, 2018 18:41
Show Gist options
  • Save shengchiliu/ee38cc490ead51d7213ecb2ae74e8fb0 to your computer and use it in GitHub Desktop.
Save shengchiliu/ee38cc490ead51d7213ecb2ae74e8fb0 to your computer and use it in GitHub Desktop.
Install LAMP (Linux, Apache, MySQL, PHP)

Install LAMP (Linux, Apache, MySQL, PHP)

1. Install Apache

$ sudo apt-get update
$ sudo apt-get install apache2
# Check Apache
# Open Browser with address http://localhost

2. Install PHP

$ sudo apt-get install php
$ sudo /etc/init.d/apache2 restart
# Check PHP
$ sudo vim /var/www/html/hello.php
# Type something in hello.php
# Open Browser with address http://localhost/hello.php

3. Install MySQL

$ sudo apt-get install mysql-server
# Check MySQL
$ mysql -u root -p  # login MySQL
$ \q                # logout MySQL

4. Install phpMyAdmin

$ sudo apt-get install phpmyadmin
# Check phpMyAdmin
$ sudo vim /etc/php/7.1/apache2/php.ini   # you might need to revise the PHP version
# uncomment extension=msql.so
# Add the following in the php.ini file
# Include /etc/phpmyadmin/apache.conf

$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
$ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
$ sudo service apache2 restart
$ sudo /etc/init.d/apache2 restart
# Open Browser with address http://localhost/phpmyadmin/

* Apache2 Commands (Ubuntu)

$ sudo systemctl stop apache2.service
$ sudo systemctl start apache2.service
$ sudo systemctl enable apache2.service
$ sudo systemctl disable apache2.service

* Apache2 Folders (Ubuntu)

/etc/apache2/                   # apache2 default configuration directory
/etc/apache2/apache2.conf       # directory of apache configuration file
/etc/apache2/sites-available/   # websites configuration files are stored here
/etc/apache2/sites-enable/      # websites configurations are enabled here
/var/www/html/                  # default DocumentRoot for Apache2

* Apache2 Folders (MacOS)

/etc/apache2/httpd.conf         # directory of apache configuration file
/Library/WebServer/Documents/   # apache web root by default

* Settings for Files Served to the Client

# Setting File Permissions
$ sudo chown USER_NAME FILE_NAME
$ sudo chmod 777 DIRECTORY          # sudo chmod  o+w  DIRECTORY

# Apache Error Logs
/var/log/apache2/error.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment