How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7
Install and Configure MySQL/MariaDB
MySQL is replaced with MariaDB in CentOS 7. MariaDB is a popular drop-in replacement for MySQL.
NOTE: If you prefer to use the MySQL branded database in CentOS 7, you will need to add the required repositories by issuing the following command:
sudo yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
- Install the MariaDB-server package:
sudo yum install mariadb-server
- Set MariaDB to start at boot and start the daemon for the first time:
sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service
- Run mysql_secure_installation to secure MariaDB. You will be given the option to change the MariaDB root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases and reload privileges. It is recommended that you answer yes to these options:
mysql_secure_installation
Create a MySQL/MariaDB Database
- Log in to MariaDB:
mysql -u root -p
- Create a new database and user with permissions to use it:
create database webdata;
grant all on webdata.* to 'webuser' identified by 'password';
- Exit MariaDB
quit
Installing and Configuring PHP
- Install PHP:
sudo yum install php php-pear
If you wish to install MySQL support for PHP also install the php-mysql package:
sudo yum install php-mysql
- Edit /etc/php.ini for better error messages and logs, and upgraded performance.
File excerpt: /etc/php.ini
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
error_log = /var/log/php/error.log
max_input_time = 30
Note: Ensure that all lines noted above are uncommented. A commented line begins with a semicolon (;).
- Create the log directory for PHP and give the Apache user ownership:
sudo mkdir /var/log/php
sudo chown apache /var/log/php
-
Reload Apache:
sudo systemctl reload httpd
fonte (https://www.linode.com/docs/websites/lamp/lamp-server-on-centos-7)
Nenhum comentário:
Postar um comentário