Linux+apache+php+mysql Server Environment (CentOS chapter)

Source: Internet
Author: User
Tags create directory gpg mcrypt

1. The preface to CentOS (Community ENTerprise Operating System) is one of the Linux distributions and is compiled from Red Hat Enterprise Linux in accordance with the source code released by the open source rules. CentOS is the ideal operating system for architecture lamp (LINUX+APACHE+PHP+MYSQL) with high stability. This article takes CentOS as an example to introduce the method of installing Apache+php+mysql for Yum under Linux system.  2. Preparation 2.1. Log on to the remote server, and if your server is on-premises and installed with a desktop environment, you can also open the server desktop directly and enter Terminal manager. Under Windows Putty is an excellent liunx remote login tool, open the interface as follows    in the Picture yellow box fill in the Server IP, click Open, then prompt to enter the user name and password, verify the successful completion of the login server.  2.2. Configuring the source and updating system software 2.2.1. Define unofficial Yum Library The official software provided is the current stable version, but not the latest version, in order to better run the dedecms, we need some unofficial Yum source.  rpm--import Http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitkavi/etc/yum.repos.d/utterramblings.repo   Add the following [Utterramblings]name=jason ' s utter ramblings repobaseurl=http://www.jasonlitka.com/media/el$ releasever/$basearch/enabled=1gpgcheck=1gpgkey=http://www.jasonlitka.com/media/rpm-gpg-key-jlitka [Note] Vim Editor to modify the method of the file, please  2.2.2 Baidu. Update the system Yum Updateyum upgrade 2.2.3. Check the system software to check if the current system has Apache and Mysql yum list installed Installed | grep Httpdrpm-qa | grep Httpd yum List Installed | grep Mysqlrpm-qa | grep MYSQL&NBSP; if it already exists, please uninstall  2.3 first. Create Directory here we agree to the following data storage directory   website data  /www/htdocs log directory  /www/log database file/www/mysql   Run the following command to complete the directory creation  mkdir/www/mysqlmkdir/www/htdocsmkdir/www/log/phpmkdir/www/log/mysql  Add Apache and MySQL user useradd-s/sbin/nologin-m apacheuseradd-s/sbin/nologin-m mysql  the directory owner and user groups need to be changed after the directory is created. Apache and MySQL can complete read and write operations Chown-r apache:apache/www/htdocschown-r mysql:mysql/www/mysqlchown-r apache:apache/www/log/ Phpchown-r mysql:mysql/www/log/mysql 3. Installation and Configuration 3.1. Yum Install Apache + PHP + mysql yum-y install gcc gcc-c++ autoconf make aclocal libtool expat-devel libxml2-devel httpd PHP php-devel mysql mysql-server mysql-devel libevent libevent-devel magemagick imagemagick-devel php-mysql mod_ssl mod_p Erl mod_auth_mysql php-mcrypt php-gd php-xml php-mcrypt php-mbstring php-ldap php-pear php-xmlrpc php-pecl-memcache MySQL -connector-odbc libdbi-dbd-mysql php-eaccelerator 3.2. Configuration phpvi/etc/php.ini  Please modify it according to your own circumstances. Here are just a few of the settings you need to be aware of post_max_size = 32mmemory_limit= 256mallow_url_fopen = Onupload_max_filesize = 32mupload_tmp_dir =/var/tmplog_errors = Onerror_reporting = E_ALL & ~ E_notice | E_strictdisplay_errors = Offerror_log =/WWW/LOG/PHP/PHP_ERROR.LOGMAGIC_QUOTES_GPC = On 3.3. Configure Apache to make a backup of the default configuration file Cp/etc/httpd/conf/httpd.conf/etc/httpd/conf/httpd.conf.bak Edit configuration vi/etc/httpd/conf/httpd.conf   Modify according to your own needs DocumentRoot "/www/htdocs"  # modified to the default Web site home directory namevirtualhost *:80  If the installation GBK version dedecms garbled, You may need to comment out this parameter #adddefaultcharset utf-8  start Apache Services service httpd start  Check if Apache is normal, open the browser, enter HTTP//Your IP, If you see the default Apache test page, that means it starts successfully.   3.4. Configuring the mysql  system has been automatically installed MySQL, but we need to do some simple modification and optimization, configuration database files and log storage location, to start. In the/usr/share/mysql/directory there are multiple my-at the beginning of the CNF file, we can choose a use for our own situation, we choose here my-medium.cnf  copy it into the/etc directory cp/usr/share/ MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF Edit VI/ETC/MY.CNF Modify the following configuration, modified on the original basis, without the option to add [client]port = 3306socket =/var/lib/mysql/ Mysql.sockdefault-character-set = Utf8[mysqld]user = Mysqldatadir =/www/mysqllog-error =/www/log/mySql/mysql_error.loglog-bin=/www/log/mysql/mysql-binexpire_logs_days=7character-set-server = utf8--skip-external-locking  startup Mysqlservice mysqld start system will automatically install the initial database and start, if there is an error, please check the/www/log/mysql/mysql_ Error.log error message   Set MySQL root user password mysqlupdate mysql.user set password = password (' Your password ') WHERE user = ' root '; FLUSH privileges;exit; 4. Optimization settings 4.1. Security settings, disable the sensitive function of PHP Vi/etc/php.ini cancel disable_functions before the #, change to Disable_functions = Exec,shell_exec,system,popen,escapeshellcmd,escapeshellarg,gzuncompress,proc_open,proc_get_status,show_source, gzinflate 4.2. Turn on gzip compression gzip compression can reduce server traffic, but also increase CPU resource consumption, whether to open you need to decide according to the situation  vi/etc/httpd/conf/httpd.conf  LoadModule Deflate_module Modules/mod_deflate.so<ifmodule Mod_deflate.c>deflatecompressionlevel 6AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-phpaddoutputfilter DEFLATE js css< /ifmodule> 5. Create a Site Directory Mkdir/www/htdocs/demo change the owner and group of the following site Directory Chown-r apache:apache/www/htdocs/demo  Configuring the virtual Host configuration Vi/etc/httpd/conf/httpd.conf add <virtualhost *:80>servername domain name at the end. Comserveralias www. domain name. Comdocumentroot/www/htdocs/demo </VirtualHost> Restart Apache service httpd restart  CREATE database mysql-u root-pcreate databases demo; #demo为要创建的数据库名exit;  Environment has been completely completed, the following you just need to upload the DEDECMS program to/www/htdocs/demo, and your domain name resolution to your server IP, you can complete the DEDECMS installation, This concludes the tutorial.  

Linux+apache+php+mysql Server Environment (CentOS chapter)

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.