Home > Article > Operation and Maintenance > How to set up a linux server
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.
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)
(2) Install Apache
yum install httpd
Modify the firewall configuration and open port 80
vi /etc/sysconfig/iptables
Add record
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
(3) Configure Apache
vi /etc/httpd/conf/httpd.conf
Find ServerName and set it to your own domain name. If there is no domain name, you can set it to localhost:80
(4) Restart and test Apache
service httpd restart
Open the browser, enter http://ip, you can see the Apache test page
(5) Install MySQL
yum install mysql mysql-server
Modify the firewall configuration and open port 3306
vi /etc/sysconfig/iptables
Add record
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Set MySQL to start automatically at boot
chkconfig mysqld on
(6) Set the root password
mysql_secure_installation
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
(7) Installation PHP
yum install php
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
(8) Restart Apache and MySQL
Create info.php
vi /var/www/html/info.php
Content:
Open http://ip/info.php in the browser for testing.
(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
Execute the script
./lamp.sh
Install httpd, MYSQL, and PHP version, press any key to install automatically after setting up
(10) Installation completed. We can see the PHPMYADMIN directory, MYSQL path and other information, including the set database password.
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!