Close Menu
    Facebook X (Twitter) Instagram
    • Download Cisco Packet Tracer
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Server
    • WordPress
    IT Beginner
    Home»CentOS»How to install LAMP server with Apache 2.2, MySQL 5.5.37, PHP 5.5.11 on Centos Linux
    CentOS

    How to install LAMP server with Apache 2.2, MySQL 5.5.37, PHP 5.5.11 on Centos Linux

    26/07/2017Updated:26/07/2017No Comments6 Mins Read

    I have shown you how to setup a LAMP server Linux, Apache, MySQL, PHP on Centos 6 before with default CentOS Provided Repositories CentOS-Base.repo. Hate it or love it, Apache web server has 55% market share which nginx or IIS (Microsoft) can’t beat it yet. By default Centos 6.5 will install:

    • Apache 2.2.15 http HyperText Transfer Protocol web server
    • MySQL 5.1.73 database management server
    • PHP 5.3.3 server-side scripting language

    To show your httpd web server version

    # httpd -v

    Sample output

    Server version: Apache/2.2.15 (Unix)
    Server built:   Apr  3 2014 23:56:16
    To show your mysql database management server
    # mysql -u root -p
    You will be asked for root password, type in your root password and you will see the output
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 13
    Server version: 5.1.73 Source distribution
    To show your PHP scripting languages version
    # yum list installed | grep "php"
    output:
    php.x86_64            5.3.3-27.el6_5    @updates
    php-cli.x86_64        5.3.3-27.el6_5    @updates
    php-common.x86_64     5.3.3-27.el6_5    @updates
    php-gd.x86_64         5.3.3-27.el6_5    @updates
    php-mbstring.x86_64   5.3.3-27.el6_5    @updates
    php-mysql.x86_64      5.3.3-27.el6_5    @updates
    php-pdo.x86_64        5.3.3-27.el6_5    @updates

    If you want to use bleeding edge technology, the current newest stable PHP 5.5.11, MySQL Community Server 5.5.37 with Apache 2.2 on Centos, you will have to add some third party repositories EPEL (Extra Packages for Enterprise Linux) and REMI (Les RPM de Remi).

    REMI repository was created and is maintained by Remi, remi repository has the lastest versions of Apache, PHP, MySQL (LAMP stack) and many other software packages for Redhat, Centos, Fedora,…

    Extra Packages for Enterprise Linux (EPEL) repository was created and maintains by a group of Fedora Special Interest. Packages from EPEL repository will never conflict with packages with packages from other redhat based distributions.

    Installing EPEL and REMI Repository for Centos 32 bit

    # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
    Installing EPEL and REMI Repository for Centos 64 bit
    # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
    Installing EPEL and REMI Repository for Fedora 17 / 18 / 19 / 20
    # rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
    # rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
    Backup your data, remove old Apache/httpd, MySQL, PHP packages

    You don’t have to do this step if you on a fresh installed Centos or Fedora system. Note: if you are using some sort of virtualization environment like openvz, kvm, or xen, most of the time your hosting/vps providers use openvz/kvm/xen precreated templates. Those templates may have apache/http and/or php/mysql pre-installed. You want to remove old Apache/http, MySQL, and PHP packages from your system to prevent any error or conflict later, trust me removing old packages and install newer one is better doing upgrading packages. I spent hours to troubleshoot errors when I upgrade from PHP 5.3.3 and MySQL 5.1.73 to PHP 5.5.11 and MySQL 5.5.37. At the end I removed all old php/mysql and install newer versions, the process went smoothly without any error.

    To backup Apache config file

    # cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bk

    To backup PHP config file

    # cp /etc/php.ini /etc/php.ini.bk

    To backup MySQL config file

    # cp /etc/my.cnf /etc/my.cnf.bk

    Your Apache/PHP/MySQL configure files will be at the same directory as the original file with .bk file extension at the end.

    Remove old Apache/PHP/MySQL packages

    # yum remove httpd* php* mysql* -y
    Install Apache 2.2 server

    Centos 5.10 / Centos 6.5

    # yum --enablerepo=remi,remi-php55 install httpd

    Fedora 20 Heisenbug / 19 Schrödinger’s Cat

    # yum --enablerepo=remi install httpd

    Fedora 18 Spherical Cow / 17 Beefy Miracle

    # yum --enablerepo=remi,remi-test install httpd

    To start Apache

    # service httpd start

    To start Apache at Startup

    # chkconfig httpd on

    or

    # chkconfig --level 235 httpd on
    Install MySQL 5.5 server

    MySQL 5.5 support multi-core CPUs better than older versions. Instead of waiting for CPUs get faster, you can take advantages today multi’cores CPU technology. There are many new features from Diagnostic improvements, Unicode, IPv6, and MySQL Cluster. The biggest change in MySQL 5.5 is default storage engine, older MySQL use MyISAM but 5.5 version use InnoDB as default storage engine.

    Centos 5.10 / Centos 6.5

    # yum --enablerepo=remi,remi-php55 install mysql-server

    Fedora 20 Heisenbug / 19 Schrödinger’s Cat

    # yum --enablerepo=remi install mysql-server

    Fedora 18 Spherical Cow / 17 Beefy Miracle

    # yum --enablerepo=remi,remi-test install mysql-server

    To start MySQL database server

    # service mysqld start

    To start MySQL server at Startup

    # chkconfig mysqld on

    or

    # chkconfig --level 235 mysqld on
    Hardening MySQL with mysql_secure_installation command

    Default MySQL installation isn’t safe since there is no default root password nor any user’s privilege. By using mysql_secure_installation the command will help to improve MySQL server more secure. With mysql_secure_installation, you can:

    • Set MySQL’s root password
    • Remove root’s remote access
    • Remove anonymous users
    • Disallow root login remotely
    • Reload privilege tables
    # mysql_secure_installation
    Install PHP 5.5.11

    PHP 5.5.x provides many new features like finally keyword, password hashing API, Apache 2.4 handler, and more… The thing I like the most is OPcache extension (Zend Optimiser plus opcode cache) is added which improve PHP performance by caching precompiled script bytecode in ram.

    Centos 5.10 / Centos 6.5

    # yum --enablerepo=remi,remi-php55 install php php-common

    Fedora 20 Heisenbug / 19 Schrödinger’s Cat

    # yum --enablerepo=remi install php php-common

    Fedora 18 Spherical Cow / 17 Beefy Miracle

    # yum --enablerepo=remi,remi-test install php php-common

    Restart Apache after install PHP

    # service httpd restart
    Install PHP 5.5 modules

    Depends on your need, there are some typical php’s modules which are required for general php’s scripts like PhpMyAdmin, phpbb, WordPress.

    Centos 5.10 / Centos 6.5

    # yum --enablerepo=remi,remi-php55 install php-mysql php-cli php-pear php-xml php-tidy php-pecl-apc php-pdo php-mysqlnd php-gd php-mbstring php-mcrypt

    Fedora 20 Heisenbug / 19 Schrödinger’s Cat

    # yum --enablerepo=remi install php-mysql php-cli php-pear php-xml php-tidy php-pecl-apc php-pdo php-mysqlnd php-gd php-mbstring php-mcrypt

    Fedora 18 Spherical Cow / 17 Beefy Miracle

    # yum --enablerepo=remi,remi-test install php-mysql php-cli php-pear php-xml php-tidy php-pecl-apc php-pdo php-mysqlnd php-gd php-mbstring php-mcrypt

    Restart Apache after install PHP modules

    # service httpd restart

    For full list of php packages from remi repository

    # yum --enablerepo=remi search php-
    Check your LAMP server if it’s working properly

    The simplest way to check your LAMP server (Linux Apache MySQL PHP) is working right, create a phpinfo file to see php version, and if you can view phpinfo file on your web browser means apache is working also. Creating phpinfo file

    # nano /var/www/html/info.php

    with the content for info.php file

     <?php
    phpinfo();
    ?>
    The default DocumentRoot from apache httpd.conf file is /var/www/html/ You should place phpinfo file according to your apache’s configure.
    ———————–
    Note:
    To start/restart/stop Apache web server
    # service httpd start
    # service httpd restart
    # service httpd stop
    To start/restart/stop MySQL server
    # service mysqld start
    # service mysqld restart
    # service mysqld stop
    REMI repository is not enabled by default, every time you want to install/update packages via remi repository you will have to include enablerepo=remi option in yum command.
    # yum --enablerepo=remi
    PHP 6 beta packages are available at the time I’m writing this article via remo repo. If you want to try out PHP 6 (not recommended for production servers) you can try enablerepo=remi,remi-php65 option with yum command.
    # yum --enablerepo=remi,remi-php65 install httpd mysql-server php php-common php-cli php-mysql
    apache lamp server web server
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to install LEMP server with Linux, Nginx, PHP-FPM, and MySQL on Centos
    Next Article How to install LEMP web server with Nginx, PHP-FPM 5.5, MySQL 5.5 on Centos Linux

    Related Posts

    CentOS

    How to install vsftpd on centos 6

    03/08/2017
    CentOS

    How To Install WordPress with nginx on Centos 6

    02/08/2017
    Security

    How to secure Nginx web server

    02/08/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    Tags
    apache centos Centos 6 cuda Desktop Environment dual boot environment featured gnome GUI hostname hosts intel kernel kill lamp server lemp server life MariaDB netflix nginx nvidia password php-fpm phpmyadmin pids processes s.m.a.r.t Security session solid state drive ssd ssh ssh server tag 1 tag 2 Ubuntu upgrade varnish VirtualBox VNC Server web server window manager wordpress xfce
    Facebook X (Twitter) Instagram Pinterest

    Type above and press Enter to search. Press Esc to cancel.

    wpDiscuz