Original CentOS 7.0 installation configuration Lamp server (APACHE+PHP+MARIADB)
First, configure the firewall, open 80 port, 3306 port
CentOS 7.0 defaults to using firewall as the firewall, where the iptables firewall is changed. 1. Close Firewall:systemctl Stop firewalld.service #停止firewallsystemctl disable firewalld.service # Disable firewall boot 2, install iptables firewall yum install iptables-services #安装vi/etc/sysconfig/iptables #编辑防火墙配置文件 # Firewall configuration written by system-config-firewall# Manual customization of this file is not RECOMMENDED.*FILTER:INP UT 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 --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -j REJECT--reject-with icmp-host-prohibited-a forward-j REJECT--reject-with icmp-host-prohibitedcommit:wq! # Save exit Systemctl Restart iptables.service #最后重启防火墙使配置生效systemctl enable iptables.service #设置防火墙开机启动二, Close selinuxvi/etc/selinux/config#selinux=enforcing #注释掉 #selinuxtype=targeted #注释掉SELINUX =disabled #增加: wq! # Save Exit Setenforce 0 #使配置立即生效
Installation article: Installation Apache yum Install httpd #根据提示, enter y installation to successfully install SYSTEMCTL start httpd.service #启动apachesystemctl stop httpd.service #停止apachesystemctl Restart httpd.service #重启apachesystemctl enable httpd.service # Set Apache boot to open the server IP address in the client browser, the following interface will appear, indicating that Apache installation success II, installation Mariadbcentos 7.0, has used mariadb replaced MySQL database 1, Installing Mariadbyum install mariadb mariadb-server #询问是否要安装, enter Y to install automatically until the installation is complete Systemctl start mariadb.service # Start Mariadbsystemctl stop mariadb.service #停止MariaDBsystemctl restart mariadb.service #重启MariaDBsystemctl Enable mariadb.service #设置开机启动cp/usr/share/mysql/my-huge.cnf/etc/my.cnf #拷贝配置文件 (Note: if/ Etc directory under the default has a my.cnf, directly overwrite can be) 2, set the password for the root account mysql_secure_installation enter, according to the prompt input y input 2 times password, enter according to the prompt input y last appear: Thanks for Using mysql! MySQL Password Setup Complete, restart Mysql:systemctl restart mariadb.service #重启MariaDB三, install PHP1, install Phpyum installation php # Follow the prompts to enter Y until installation is complete 2, install PHP components, make PHP support Mariadbyum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml PHP-XMLRPC Php-mbstring Php-bcmath php-mhash# Here Select the above installation package to install, according to the prompt input y return systemctl restart mariadb.service # Restart Mariadbsystemctl Restart httpd.service #重启apache
Configuration Article One, Apache configuration vi/etc/httpd/conf/httpd.conf #编辑文件ServerSignature on #添加, the version of Apache is displayed in the error page, off is not display options Indexes followsymlinks #修改为: Options includes execcgi followsymlinks (Allow server to execute CGI and SSI, disallow listing of directories) #AddHandler Cgi-script. CGI #修改为: AddHandler cgi-script. cgi. PL (allows CGI scripts with extension. pl to run) allowoverride None #修改为: allowoverride All (Allow. htaccess) Adddefaultcharset UTF-8 #修改为: Adddefaultcharset GB2312 (add GB2312 as default encoding) #Options Indexes followsymlinks #修改为 Options followsymlinks (does not display the tree structure on the browser) directoryindex index.html #修改为: DirectoryIndex index.html index.htm default.html Default.htmindex.php (set default home file, add index.php) maxkeepaliverequests # Add maxkeepaliverequests 500 (increase number of simultaneous connections):wq! #保存退出systemctl restart httpd.service #重启apacherm-F/etc/httpd/ conf.d/welcome.conf/var/www/error/noindex.html #删除默认测试页二, PHP configuration vi/etc/php.ini #编辑date. TimeZone = PRC #把前面的分号去掉, change to Date.timezone = Prcdisable_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# lists the functions that PHP can disable, and if some programs need to use this function, they can be removed and deactivated. expose_php = off #禁止显示php版本的信息short_open_tag = on #支持php短标签open_basedir =.:/ tmp/ #设置表示允许访问当前目录 (that is, the PHP script files in the directory) and/tmp/directory, you can prevent the PHP Trojan cross-site, if you change the installation program after the problem (such as: Dream Content Management System), you can log off this line, or directly write the program directory/data/ www.111cn.net/:/tmp/:wq! #保存退出systemctl Restart Mariadb.service #重启MariaDBsystemctl Restart httpd.service #重启apache
Test ArticleCd/var/www/htmlvi index.php #输入下面内容 <?phpphpinfo ();? >:wq! #保存退出在客户端浏览器输入服务器IP地址, you can see the relevant configuration information as shown! NOTE: The Apache default program directory is the/var/www/html permission setting: Chown apache.apache-r/var/www/html
At this point, the CentOS 7.0 installation configuration Lamp server (APACHE+PHP+MARIADB) tutorial is complete!
CentOS 7.0 installation Configuration Lamp server (APACHE+PHP+MARIADB)