Contents
LAMP Versions
* Linux:
# cat /etc/redhat-release CentOS release 6.8 (Final)
* Apache:
# apachectl -v Server version: Apache/2.2.15 (Unix) Server built: Nov 18 2016 23:48:55
* MySQL:
# mysqladmin -u root -p version Enter password: mysqladmin Ver 8.42 Distrib 5.1.73, for redhat-linux-gnu on x86_64 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.1.73 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 17 hours 9 min 17 sec Threads: 1 Questions: 29 Slow queries: 0 Opens: 16 Flush tables: 1 Open tables: 9 Queries per second avg: 0.0
* Php:
# php -v PHP 5.3.3 (cli) (built: Aug 11 2016 20:33:53) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Update CentOS
yum update
Setup Hostname
* See this post
# hostname
lamp
Install Apache
* Install Apache
yum install httpd
* Auto start Apache
/sbin/chkconfig --levels 235 httpd on
* Start Apache
service httpd start
Open Port 80
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
* Restart iptables
service iptables restart
Install MySQL
* Install MySQL
yum install mysql-server
* Secure MySQL MySQL
mysql_secure_installation
* Auto start MySQL
/sbin/chkconfig --levels 235 mysqld on
* Start MySQL
service mysqld start
Create Test DB
* Create a database named wpdb:
mysql -u root -p create database wpdb; GRANT ALL ON wpdb.* TO 'wpuser'@'localhost' identified by 'wppass1';
Install PHP
* Install php and php-mysql:
yum install php php-pear php-mysql
* Config php log:
# Make php log directory mkdir /var/log/php chown apache /var/log/php # Set php log directory vi /etc/php.ini
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR error_log = /var/log/php/error.log max_input_time = 30
* Restart Apache
service httpd restart
Test
Create a Sample Site
* Create directory for sample site:
mkdir -p /var/www/my.com/public_html mkdir /var/www/my.com/logs chown -R apache:apache /var/www/my.com
* Create a sample php page:
cd /var/www/my.com/public_html vi index.php
<?php phpinfo(); ?>
Configure Sample Site
vi /etc/httpd/conf.d/vhost.conf
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin jm@my.com ServerName my.com ServerAlias www.my.com DocumentRoot /var/www/my.com/public_html/ ErrorLog /var/www/my.com/logs/error.log CustomLog /var/www/my.com/logs/access.log combined </VirtualHost>
* Reload httpd config
service httpd reload
Test Sample Site
* Point browser to http://lamp.my.com/