centos7.0 Lnmp and Lamp
- 2020-05-13 04:24:33
- OfStack
centos7.0 Lnmp and Lamp
Configure the firewall first
CentOS 7.0 USES firewall as a firewall by default
1. Close firewall:
systemctl stop firewalld.service # stop firewall
systemctl disable firewalld.service # ban firewall Powered up
2. Close SELINUX
vi /etc/selinux/config
#SELINUX=enforcing # Comment out the
SELINUX=disabled # increase
:wq! # Save the exit
setenforce 0 # Enable the configuration to take effect immediately
Lnmp installation
1. Install nginx
yum install yum-priorities -y
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
2. Start nginx
systemctl start nginx.service # Start the nginx
systemctl stop nginx.service # stop
systemctl restart nginx.service # restart
systemctl enable nginx.service # Set boot
3. Change the nginx port number (according to your own needs)
cd /etc/nginx/conf.d/
vim default.conf
the listen 80 to listen 81
And then restart nginx
systemctl restart nginx.service # restart nginx
4. Visit http://ip:81 to see the home page of nginx
5. Next step: install PHP-fpm
yum install php-fpm
After installation
systemctl start php-fpm.service # Start the php-fpm
systemctl enable php-fpm.service # Set boot
6. Change the nginx configuration file identification php vi etc/nginx/conf d/default conf, it is ok to remove # before, conveniently change fastcgi_param under 1
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
7. Visit test. php
in /usr/share/nginx/html In the new 1 a test.php <?php echo 123;?>
access http://ip:81/test.php You can see nginx In the php page
8. Load configuration
Enter vi etc/nginx/conf d/default conf
upstream site{
server 172.16.170.138;
server 172.16.170.139;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://site;
}
9. Domain name modification to change site and localhost above to www.a.com
Lamp installation
1. Install apache
yum install httpd # Follow the prompts and type Y Install to install successfully
systemctl start httpd.service # Start the apache
systemctl stop httpd.service # stop apache
systemctl restart httpd.service # restart apache
systemctl enable httpd.service # Set up the apache Powered up
2. Install mariadb (MySQL)
vi /etc/selinux/config
#SELINUX=enforcing # Comment out the
SELINUX=disabled # increase
:wq! # Save the exit
setenforce 0 # Enable the configuration to take effect immediately
0
3. Change the mysql password to default to null after installation
Change mysql password: set password for '@'localhost'=password('root');
mysql authorized remote connection (navicat, etc.) : grant all on *.* to root identified by by 'root';
4. Install PHP and components so that PHP supports MariaDB
vi /etc/selinux/config
#SELINUX=enforcing # Comment out the
SELINUX=disabled # increase
:wq! # Save the exit
setenforce 0 # Enable the configuration to take effect immediately
1
5. Access tests
vi /etc/selinux/config
#SELINUX=enforcing # Comment out the
SELINUX=disabled # increase
:wq! # Save the exit
setenforce 0 # Enable the configuration to take effect immediately
2
Enter the server IP address in the client browser and you will see the relevant configuration information as shown in the figure below!
Thank you for reading, I hope to help you, thank you for your support of this site!