How to set up a linux server

清浅
Release: 2020-10-13 12:01:05
Original
29600 people have browsed it

How to build a Linux server: first install apache, modify the firewall configuration file, and open port 80; then install mysql, modify the firewall configuration file, and open port 3306; and finally install PHP.

How to set up a linux server

First log in to the server to install Apache and configure it; then restart and install MySQL and set the root password; finally download the one-click installation script and grant permissions and execute the script That’s it.

[Recommended tutorial: Linux tutorial]

LAMP is an open source software commonly used to build dynamic websites or servers. It refers to Linux (operating system) and Apache HTTP server. The first letters of MySQL (sometimes also referred to as MariaDB, database software) and PHP (sometimes also referred to as Perl or Python) are generally used to build web application platforms. Currently, about 70% of access traffic is provided through LAMP.

Steps to build a Linux server:

(1) Use putty or similar SSH tool to log in to the server (skip local installation)

How to set up a linux server

How to set up a linux server

(2) Install Apache

yum install httpd
Copy after login

Modify the firewall configuration and open port 80

vi /etc/sysconfig/iptables
Copy after login
Copy after login

Add record

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Copy after login

(3) Configure Apache

vi /etc/httpd/conf/httpd.conf
Copy after login

Find ServerName and set it to your own domain name. If there is no domain name, you can set it to localhost:80

How to set up a linux server

(4) Restart and test Apache

service httpd restart
Copy after login

Open the browser, enter http://ip, you can see the Apache test page

How to set up a linux server

(5) Install MySQL

yum install mysql mysql-server
Copy after login

Modify the firewall configuration and open port 3306

vi /etc/sysconfig/iptables
Copy after login
Copy after login

Add record

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Copy after login

Set MySQL to start automatically at boot

chkconfig mysqld on
Copy after login

(6) Set the root password

mysql_secure_installation
Copy after login

After pressing Enter, enter y to set the password. After setting the password, press Enter until it appears: Thanks for using MySQL!

Restart MySQL

service mysqld restart
Copy after login

(7) Installation PHP

yum install php
Copy after login

Install PHP components

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
Copy after login

(8) Restart Apache and MySQL

Create info.php

vi /var/www/html/info.php
Copy after login

Content:

Open http://ip/info.php in the browser for testing.

How to set up a linux server

(9) Download the one-click installation script and grant permissions

wget -O lamp.zip https://github.com/teddysun/lamp/archive/master.zipunzip lamp.zipcd lamp-master/chmod +x *.sh
Copy after login

Execute the script

./lamp.sh
Copy after login

Install httpd, MYSQL, and PHP version, press any key to install automatically after setting up

How to set up a linux server

How to set up a linux server

(10) Installation completed. We can see the PHPMYADMIN directory, MYSQL path and other information, including the set database password.

How to set up a linux server

The above is the detailed content of How to set up a linux server. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template