CentOS 6.4 Installation Configuration Lamp server (APACHE+PHP5+MYSQL)

Source: Internet
Author: User
Tags install php

CentOS 6.4 Installing the Configuration Lamp Server (apache+php5+mysql)

This article mainly describes the CentOS 6.4 installation configuration Lamp server (Apache+php5+mysql) method, the need for friends can refer to the following

Prepare the article:

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 #允许80端口通过防火墙
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许3306端口通过防火墙

Note: Many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start.

The correct one should be added to the default port 22 below this rule

As shown below:
############################## after adding the firewall rules as follows ##############################
# Firewall configuration written by System-config-firewall
# Manual Customization of this file are not recommended.
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m state--state established,related-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport80-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport3306-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT
##################################################################################################

/etc/init.d/iptablesrestart #最后重启防火墙使配置生效

2. Turn off SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq #保存, close
Shutdown-r now #重启系统

Installation article:

First, install Apache
Yum Install httpd #根据提示, enter Y to install successfully
/ETC/INIT.D/HTTPD Start #启动Apache

Note: Apache will prompt for errors after booting:
Starting httpd:httpd:Could not reliably determine the server's fully qualifdomain name, using:: 1 for ServerName
Workaround:
Vi/etc/httpd/conf/httpd.conf #编辑
Found #ServerName www.example.com:80
Modified to ServerName www.osyunwei.com:80 #这里设置为你自己的域名, if no domain name, can be set to localhost
: wq! #保存退出
Chkconfig httpd on #设为开机启动
/ETC/INIT.D/HTTPD Restart #重启Apache

Second, install MySQL

1. Install MySQL
Yum install MySQL mysql-server #询问是否要安装, enter y for automatic installation until 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, you can directly overwrite it)

2. Set the password for the root account
Mysql_secure_installation
Enter, follow the prompts for Y
Enter Password 2 times, enter
Enter Y as prompted
Last appearance: Thanks for using mysql!
MySQL password setup is complete, restart MySQL:
/etc/init.d/mysqld Restart #重启
/etc/init.d/mysqld Stop #停止
/etc/init.d/mysqld Start #启动

Third, installation PHP5

1, installation PHP5
Yum Install PHP
Enter Y as prompted until the installation is complete

2, install PHP components, so that PHP5 support MySQL
Yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xmlphp-xmlrpc php-mbstring php-mcrypt PHP-BC Math Php-mhash Libmcrypt
Select the above installation package here for installation
Enter Y return as prompted
/etc/init.d/mysqld Restart #重启MySql
/ETC/INIT.D/HTTPD Restart #重启Apche

Configuration Chapter

One, Apache configuration
vi/etc/httpd/conf/httpd.conf #编辑文件
Servertokens OS in 44 rows modified to: Servertokens Prod (The name of the server operating system is not displayed when the error page appears)
Serversignature on line 536 is modified to: Serversignature Off (the version of Apache is not shown in the error page)
Options Indexes FollowSymLinks in line 331 is modified to: Options includes Execcgifollowsymlinks (allow the server to execute CGI and SSI, disallow listing of directories)
#AddHandler cgi-script. The CGI is modified in line 796 to: AddHandler cgi-script. cgi. PL (allows CGI scripts with extension. pl to run)
AllowOverride None in 338 rows modified to: allowoverride all (Allow. htaccess)
Adddefaultcharset UTF-8 in 759 rows modified to: Adddefaultcharset GB2312 (add GB2312 as default encoding)
Options Indexes MultiViews FollowSymLinks in line 554 is modified to Optionsmultiviews followsymlinks (does not display the tree directory structure on the browser)
DirectoryIndex index.html Index.html.var in line 402 is modified to: DirectoryIndex index.html index.htmDefault.html default.htm

index.phpDefault.php Index.html.var (set default home file, add index.php)
KeepAlive Off on line 76 modified to: KeepAlive on (Allow program online)
Maxkeepaliverequests 100 in 83 rows modified to: Maxkeepaliverequests 1000 (increase number of simultaneous connections)
: wq! #保存退出
/etc/init.d/httpd Restart #重启
Rm-f/etc/httpd/conf.d/welcome.conf/var/www/error/noindex.html #删除默认测试页

Two, 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,chroot,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行 lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled.
expose_php = Off #在432行 Suppress the 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 to allow access to the current directory (that is, the php script file directory) and/tmp/directory, you can prevent the PHP Trojan cross-site, if you change the installation program after the problem (for example: Dream Content Management System), you can log off this line, or directly write the program directory/data/ 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! #保存退出
In the client browser enter the server IP address, you can see the configuration information as shown in the relevant!

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

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

At this point, the CentOS6.4 installation configuration Lamp server (apache+php5+mysql) tutorial is complete!

CentOS 6.4 Installation Configuration Lamp server (APACHE+PHP5+MYSQL)

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.