Installation
Step 1: Configure the firewall (By default, ports 80 and 3306 are denied access, configure them on the firewall):
Then restart the firewall to make the configuration take effect:
Step 2: Install Apache
Install Apache using the following command:
If the following statement appears, it means that Apache has been installed and there is no need to reinstall it:
After installation, restart Apache: /etc/init.d/httpd restart
Then set Apache to start at boot: chkconfig httpd on. (This step eliminates the need to manually start the httpd service every time the server is restarted)
To check the startup status of the httpd service, you can use the command: chkconfig --list httpd (the startup status of httpd at each level will be displayed)
Step 3: Install MySQL
1. Use the following command to install MySQL:
Similarly, if there is a prompt that it has been installed, it means that MySQL is installed on the system. You can skip this step, otherwise, the system will automatically install MySQL.
After the installation is complete, start MySQL: /etc/init.d/mysql start
Set MySQL to start at boot: chkconfig mysqld on
Finally, copy the configuration file: cp /usr/share/mysql/my-medium.cnf /etc/my.cnf (there is my.cnf under /etc. cnf file, just overwrite it directly)
2. Use the following command to set the password for the root account
Enter the password twice according to the prompts and the setting is successful. Note that during the setup process, you will be prompted whether to delete anonymous users, whether to deny root remote access, whether to delete the test database, etc. These all need to be selected according to your actual situation. Finally, it appears: Thanks for using MySQL!, and the password is set successfully.
Restart MySQL: /etc/init.d/mysqld restart
Step 4: Install PHP
1. Use the following command to install PHP:
Just follow the prompts to install. After installation, restart Apache: /etc/init.d/httpd restart
2. Install the PHP component, which is PHP that supports MySQL
You can use the command: yum search php to view PHP components and select the required modules for installation:
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
After installation, restart Apache: /etc/init.d/httpd restart
Restart MySQL: /etc/init.d/mysqld restart
At this step, AMP in LAMP has been installed, but the web server cannot be accessed at this time, because to access the server, Apache and PHP need to be configured accordingly.
Configuration
Step 1: Configure Apache
Modify the Apache configuration file: vi /etc/httpd/conf/httpd.conf, and find the following line in the file and modify it (to search, you can enter "/the character to be searched for" in the general mode of vi to search ):
ServerTokens OS Modified to: ServerTokens (Do not display the name of the server operating system when an error page appears) (Do not display the Apache version in the error page)
Options Indexes FollowSymLinks Modified to: Options Includes ExecCGI FollowSymLinks (Allow the server to execute CGI and SSI, prohibit directory listing)
#AddHandler cgi-script .cgi Modified to: AddHandler cgi-script .cgi .pl to CGI script running)
AllowOverride None Modify to: AllowOverride All (Allow .htaccess) AddDefaultCharset GB2312 (Add GB2312 as the default encoding)
Options Indexes MultiViews FollowSymLinks Modified to Options MultiViews FollowSymLinks (Do not display the tree directory structure on the browser)
Keepalive OFF modification: Keepalive On (allowed programmed online) 100 Modified to: MaxkeepaliveRequests 1000 ( Increase the number of simultaneous connections)
It is recommended to delete the default test page: rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html
Step 2: Configure PHP
Modify the PHP configuration file: vi /etc/php.ini. The location of the following lines that need to be modified can be found through the vi search command:
date.timezone = PRC #Remove the semicolon in front and change it 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,escape shellcmd,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 can be disabled in PHP. If some programs need to use this function, it can be deleted and undisabled.
expose_php=Off
display_errors = OFF #Turn on magic_quotes_gpc to prevent SQL injection
log_errors = On #Record error logs
error_log = / var/log/php/error_log.log #Set the error log storage directory. The file must allow the apache user and group to have write permissions (note that the file /var/log/php/error_log.log must be created before modification. Then modify its properties so that it belongs to the apache user and user group chown apache /var/log/php/error_log.log and chgrp apache /var/log/php/error_log.log)
open_basedir = .:/tmp/
After installation and configuration, the web server has basically been set up and can be accessed.
Test Chapter
Under the directory /var/www/html: cd /var/www/html
Create php file: vi index.phpphpinfo();?>
Then, when you enter the local address in the browser, you can access the index.php web page file you just created.
Note:
The default program directory of apache is: /var/www/html, and webpage files can be accessed here. You need to ensure that this directory belongs to user apache and user group apache.The database directory of MySQL is: /var/lib/mysql
Writing this, LAMP is installed and configured. As long as the browser enters the IP address or domain name of the server, it will be able to access the web page files on the server.
If there are any errors or omissions, you are welcome to point out your comments for revision at any time. Thank you for your support.
Commonly used commands in Linux systems:
1. Common Linux commands
1.1. Permission allocation chmod command
chmod 777 dir/file1.2. Reference link
1. http://blog.sina.com.cn/s /blog_3fe048830100gp0e.html
2. Common operating commands for mysql database
2.1. Modify the MySQL character set
1. Modify my.cnf
vi /etc/my.cnf
in [client] Add
default-character-set=utf8
under [mysqld]. Add
default-character-set=utf8
2. Restart MySQL
service mysqld restart
3. View character set settings
show variables like 'character_set_%';
2.2. Some other setting methods
1. Modify the character set of the database
mysql>use mydb
mysql>alter database mydb character set utf-8;
2. Create a database and specify the character set of the database
mysql>create database mydb character set utf-8;
3. Modify through the MySQL command line
set character_set_client=utf8;
set character_set_connection=utf8;
set character_set_database=utf8;
set character_set_results=utf8;
set character_set_server=utf8;
set character_set_system=utf8;
set collation_connection=utf8;
set collation_database=utf8;
set collation_server=utf8;
2.3. Back up and restore database
1. Back up
mysqldump -u root -p voice>voice.sql;
2. Restore
source voice.sql;
mysql -u root -p voice
1.http://blog.chinaunix.net/uid-26727991-id-4742248 .html