over 5 years ago

Linux, Apache, MySQL, and PHP (LAMP) on Archlinux

  1. Install Apache
    pacman -Syy apache 
    vim /etc/httpd/conf/httpd.conf
    systemctl enable httpd
    systemctl start httpd
    
    Example httpd.conf
    ServerAdmin XXXXXX@gmail.com
    ServerName 127.0.0.1:80
    ...
    LoadModule rewrite_module modules/mod_rewrite.so
    ...
    DocumentRoot "/srv/http" //the default path of web file 
    <Directory "/srv/http">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    
  2. Install php
    pacman -Syy php php-apache
    vim /etc/httpd/conf/httpd.conf
    systemctl restart httpd
    
    Example httpd.conf
    ...
    #LoadModule mpm_event_module modules/mod_mpm_event.so
    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    ...
    LoadModule dir_module modules/mod_dir.so
    LoadModule php7_module modules/libphp7.so
    ...
    Include conf/extra/php7_module.conf
    
  3. Testing
    sudo echo "<?php phpinfo(); ?>" > /srv/http/phpinfo.php
    //Open the web
    http://127.0.0.1/phpinfo.php
    
  4. *Install MariaDB (MySQL) *
    pacman -Syy mariadb
    mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
    systemctl enable mysqld.service
    systemctl start mysqld.service
    mysql_secure_installation
    vim /etc/php/php.ini
    
    
    



    Example /etc/php/php.ini
    extension=pdo_mysql.so
    extension=mysqli.so
    
    1. *Install phpmyadmin *
      pacman -Syy phpmyadmin php-mcrypt
      vim /etc/php/php.ini
      vim /etc/httpd/conf/extra/phpmyadmin.conf
      vim /etc/httpd/conf/httpd.conf
      sudo systemctl restart httpd
      
      Example php.ini
      extension=mysqli.so
      extension=mcrypt.so
      ...
      open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/
      
      Example phpmyadmin.conf
      Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
      <Directory "/usr/share/webapps/phpMyAdmin">
      DirectoryIndex index.php
      AllowOverride All
      Options FollowSymlinks
      Require all granted
      </Directory>
      
      Example httpd.conf
      # phpMyAdmin configuration
      Include conf/extra/phpmyadmin.conf
      
    2. Reference
← Node.js installation with nvm