CentOS install Apache+PHP+MySQL guide

  
 

Before Ubuntu has been used on VPS. If it is not Linode alarm, I can't think of changing the system. Later, I found out that I can use CentOS more. It seems that Tianyuan old man is still out of date. With this article, CentOS Install APACHE+PHP
+MYSQL Process (VPS). Similarly, the reference source of this article is the official document of Linode. Linode's foreigners are really dedicated and dedicated, and the documents are written in such detail. It is difficult to play.

Basic Reading:

Getting Started and Maintaining VPS Servers

Virtual Hosting, Shared Space, VPS Hosting and Rental Hosting

Ubuntu VPS Installing Apache+PHP +MySQL Guide

The first step, the CentOS system selection settings will not be said, all in the Linode background operation.

First, log in to the VPS to modify the host name

1. Log in to the server

Use the terminal tool to log in to the server. Linux and Mac systems can use the terminal tool to log in to the SSH connection. Windows
platform can log in using Putty.

In the case of Putty, just enter the IP address, select the SSH connection, click OPEN, the first login may pop up a security warning, confirm, enter the administrator account name and password on the terminal interface. can.

2, modify the host name

The default host name is localhost, it is recommended to modify it, not only for security, but also easy to remember and identify:

echo "HOSTNAME= Myhostname" >> /etc/sysconfig/networkhostname "myhostname"

3, running updates (including kernels and packages)

yum update

If not updated Kernel, and only update packages, use the command:

yum --exclude=kernel* update

Note:

  • The following assumptions are based on ROOT users If you are logged in, if it is another user, the permissions may be different for the directory (such as the website directory, database directory) after the final installation.
  • The following is an example of installing LAMP SERVER.

    Second, install Apache for CentOS VPS

    1, install APACHE

    yum install httpd

    2, back up httpd.conf configuration file< Br>

    cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup

    3. Create a virtual machine configuration file

    The file path is: /etc/httpd /conf.d/

    File name: vhost.conf

    The content is as follows:

    NameVirtualHost 12.34.56.78:80< VirtualHost 12.34.56.78:80> ServerAdmin abc@ gmail.comServerName metsky.comServerAlias ​​www.metsky.comDocumentRoot /srv/www/metsky.com/public_html/ErrorLog /srv/www/metsky.com/logs/error.log CustomLog /srv/www/metsky.com/logs/access .log combined< /VirtualHost>

    If you have multiple virtual hosts, just add <VirtualHost 12.34.56.78:80> ....</VirtualHost> in turn (assuming site placement above) The directory is /srv/www/metsky.com/public_html/).

    After creation, copy and upload to /etc/httpd/conf.d/. After launching apache, the system will automatically link.

    4. Create a website directory (upload file)

    mkdir -p /srv/www/metsky.com/public_html

    mkdir /srv/www/metsky.com/Logs

    If you already have a directory or website file like metasky.com/public_html and metasky.com/logs, you can upload it directly, and later you need to modify the access rights.

    5, start Apache

    /etc/init.d/httpd start

    After the vhost.conf modification mentioned above, you need:

    /etc/init.d/httpd reload

    6.Set boot Apache

    /sbin/chkconfig --levels 235 httpd on

    Three, install for CentOS VPS MYSQL

    1, install Mysql (password assignment according to the original MYSQL allocation)

    yum install mysql-server

    2.Set boot up

    /sbin/Chkconfig --levels 235 mysqld on

    3. Start mysql

    /etc/init.d/mysqld start

    4. Install mysql security update

    Mysql_secure_installation

    At this time, enter the ROOT password, press Enter, then ask if you want to set the ROOT password, select Y, enter the new ROOT password, and enter it again.

    Next, prompt to delete the anonymous account, select Y.

    Whether to enable ROOT remote login, select N. (This depends on the individual, Tianyuan recommended the best choice N, if you need to remotely create a separate user for remote login.)

    Delete the test database, select Y.

    Reload the permission table and select Y.

    5, login MSYQL

    mysql -u root -p

    If it is the first login, the password is empty, you can directly press

    Modify the ROOT password command as follows: mysql>use mysql;

    mysql>UPDATE user SET password=PASSWORD('mypassword') WHERE user='root';

    mysql>FLUSH PRIVILEGES; Is: mypassword

  • Copyright © Windows knowledge All Rights Reserved