Laboratorium Komputerowe Progmar
Marcin Załęczny

We are using cookies in the page. If you use the page you agree for the cookies.      Close

LAMP (Linux+Apache+Mysql+PHP) installation in Ubuntu

In Ubuntu 16.04 and above first install following packages: sudo apt-get install apache2 mysql-server php libapache2-mod-php php-mcrypt php-mysql php-mbstring
sudo apt-get install libcurl3-dev php-curl php-gd php-sqlite3

In Ubuntu 15.10 and below first install following packages: sudo apt-get install apache2 php5-mysql php5-sqlite libapache2-mod-php5 mysql-server
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt php5-gd

Configure Apache2, file name: /etc/php5/apache2/php.ini Set display_errors=On
Add following extensions or make sure they are there already:
extension=mysql.so
extension=mysqli.so
extension=curl.so

Enable modrewrite in apache: sudo a2enmod rewrite
Check that it is loaded: apache2ctl -M
ADodać obsługę htaccess: Edytować /etc/apache2/sites-available/default i zmienić wszystkie wystąpienia:
AllowOverride None na AllowOverride All
Zrestartować apacha: sudo service apache2 restart

How to add a new site to Apache and serve it under customized local url

First create directory where your site will be available from, ex: sudo mkdir /var/www/mysite

Create mysite config file in /etc/apache2/sites-available directory:

<VirtualHost *:80>
    DocumentRoot /var/www/mysite
    ServerName local.mysite

    DocumentRoot /var/www/mysite
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/mysite>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride All
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Add following line to the end of /etc/hosts file: ::1 local.mysite

Enable new site in Apache server: sudo a2ensite mysite

Restart Apache to load and serve your new site: sudo service apache2 restart

Since now your site will be available at local.mysite url in any webbrowser.