CentOS 6.6 Installation Configuration Lamp server (apache+php5+mysql) _linux

Source: Internet
Author: User
Tags install php php script sql injection centos iptables yum repolist

Prepare the article:

CentOS 6.6 System Installation Configuration Diagram tutorial
Http://www.jb51.net/os/239738.html

1, configure the firewall, open 80 ports, 3306 ports

Vi/etc/sysconfig/iptables
-a input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-a input-m state--st Ate new-m tcp-p TCP--dport 3306-j ACCEPT

: wq! #保存退出

The firewall configuration file after adding the rules is shown in the following illustration:

/etc/init.d/iptables restart#重启防火墙使配置生效

2. Close SELinux

Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
selinux=disabled #增加

: wq! #保存退出

The SELinux configuration file is shown in the following illustration:

3. Add third party yum source

CentOS default yum source software version is too low, to install the latest version of Lamp, where the use of Third-party yum source

wget http://www.atomicorp.com/installers/atomic#下载

First install the wget command using the default Yum source

yum install wget

sh ./atomic #安装

Yum Clean all #清除当前yum缓存
Yum Makecache #缓存yum源中的软件包信息
Yum Repolist #列出yum源中可用的软件包

Installation article:

First, install Apache

Yum Install httpd #根据提示, enter y installation to install successfully

/ETC/INIT.D/HTTPD Start #启动Apache

Note: Apache prompts for errors after startup:

Httpd:httpd:Could not reliably determine the server's fully Qualif domain name using:: 1 for ServerName

Solution:

Vi/etc/httpd/conf/httpd.conf #编辑
ServerName www.example.com:80 #去掉前面的注释

: wq! #保存退出

Chkconfig httpd on #设为开机启动

/ETC/INIT.D/HTTPD Restart #重启Apache

Second, the installation of MySQL

1, install MySQL

Yum install MySQL mysql-server #询问是否要安装, enter Y to install automatically until the installation is complete

/etc/init.d/mysqld Start #启动MySQL
Chkconfig mysqld on #设为开机启动
CP/USR/SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, direct coverage can be)

2. Set password for root account

Mysql_secure_installation

Carriage return, enter y according to the prompt

Enter 2 times password, return

Follow the prompts to enter Y

Last seen: the for using mysql!

MySQL password settings complete, restart MySQL:

/etc/init.d/mysqld Restart #重启
/etc/init.d/mysqld Stop #停止
/etc/init.d/mysqld Start #启动

Third, the installation of PHP

1. Install PHP

Yum Install PHP #根据提示输入Y直到安装完成

2, the installation of PHP components, so that PHP support MySQL

Yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-b Cmath Php-mhash Libmcrypt

Here Select the above installation package for installation

Enter Y return according to the prompts

/etc/init.d/mysqld restart#重启MySql
/etc/init.d/httpd restart#重启Apche

Configuration Chapter

First, Apache configuration

vi/etc/httpd/conf/httpd.conf #编辑文件
servertokens OS is modified to: Servertokens Prod on 44 lines (does not display the name of the server's operating system when the error page appears)
Serversignature on 536 lines modified to: Serversignature off (not showing Apache version on error page)
Options Indexes followsymlinks on 331 lines modified to: Optio NS Includes execcgi followsymlinks (allows the server to execute CGI and SSI, disable listing of directories)
#AddHandler cgi-script. CGI is modified on line 796: AddHandler Cgi-script. cgi. PL (a CGI script that allows the extension. pl)
allowoverride None on line 338 is modified to: allowoverride all (Allow. htaccess)
Adddefaultcharset UTF-8 on line 759 to: Adddefaultcharset GB2312 (add GB2312 to default encoding)
Options Indexes multiviews FollowSymLinks is modified on line 554 to Options MultiViews followsymlinks (does not display the tree directory structure on the browser)
DirectoryIndex index.html Index.html.var in line 402 to: DirectoryIndex index.html index.htm default.html default.htm index.php
Index.html.var (Set the default first file, add index.php)
KeepAlive off in line 76 to: KeepAlive on (Allow program online)
maxkeepaliverequests 100 on 83 lines modified to: Maxkeepaliverequests 1000 (Increase simultaneous connection number)

: wq! #保存退出

/etc/init.d/httpd restart #重启

rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html#删除默认测试页

Second, PHP configuration

Vi/etc/php.ini #编辑 date.timezone = PRC #在946行 Remove the preceding semicolon and change it to Date.timezone = PRC Disable_functions = passthru,exec,system,ch Root,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog, SYSLOG,READLINK,SYMLINK,POPEPASSTHRU,STREAM_SOCKET_SERVER,ESCAPESHELLCMD,DLL,POPEN,DISK_FREE_SPACE,CHECKDNSRR, CHECKDNSRR,GETSERVBYNAME,GETSERVBYPORT,DISK_TOTAL_SPACE,POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_ Getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid, Posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam,posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_ Getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, Posix_setpgid,posix_ Setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname #在386行 list The functions that PHP can disable, and if some programs need to use this function, you can delete
, cancel disabling. expose_php = off #在432行 suppresses the display of PHP version information MAGIC_QUOTES_GPC = on #在745行 open MAGIC_QUOTES_GPC to prevent SQL injection SHORT_OPEN_TAg = on #在229行支持php短标签 Open_basedir =.:/ tmp/#在380行 settings that allow access to the current directory (that is, the directory where the php script files) and the/tmp/directory, you can prevent the PHP trojan across the station, if there is a problem with the installer (for example, a Dream Content management system), you can log off this line, or directly write the directory of the www.osyunwei.com/:/tmp/

: wq! #保存退出

/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart#重启Apche


Test Article

Cd/var/www/html

VI index.php #输入下面内容

<?php
phpinfo ();
? >

: wq! #保存退出

Enter the server IP address in the client browser and see the relevant configuration information as shown in the following figure!

NOTE: The Apache default program directory is/var/www/html

Permission settings: Chown apache.apache-r/var/www/html

At this point, the CentOS 6.6 installation configuration Lamp server (apache+php5+mysql) tutorial is complete!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.