How to Install LAMP on CentOS 7:
- Install / Start Apache
# install yum install httpd # start apache systemctl start httpd.service # enable apache to start on boot systemctl enable httpd.service - Install MariaDB
# install yum install mariadb-server mariadb # start mariadb systemctl start mariadb # run simple security installation script mysql_secure_installation # enable mariadb on boot systemctl enable mariadb.service - Install PHP
# install yum install php php-mysql # spot-check the phpinfo() function echo "<?php phpinfo(); ?>" >> /var/www/html/info.php # restart webserver systemctl restart httpd.service # verify the page loads the phpinfo() function at http://server/info.php- NOTE: The official CENTOS 7 repos have PHP 5.4 which is EOL. To install the latest php version, perform the following
# enable EPEL and Remi repositories yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm # install yum-utils yum install yum-utils # enable remi repo for installing different php versions yum-config-manager --enable remi-php72 yum-config-manager --enable remi-php71 yum-config-manager --enable remi-php56 # Now install php with all necessary modules yum install php php-common php-cli php-mysql php-xml php-xcache php-gd php-mbstring # double check new version php -v
- NOTE: The official CENTOS 7 repos have PHP 5.4 which is EOL. To install the latest php version, perform the following
- Configure Firewall
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
How to create MySQL USER and DB via CLI
- Connect to the MySQL engine:
mysql -u root -p - Create DATABASE
CREATE DATABASE new_database_name - Create user and grant privileges
GRANT ALL PRIVILEGES ON new_database_name.* TO "newuser"@"localhost" IDENTIFIED BY "password123" FLUSH PRIVILEGES
How to Install VSFTPD, FTP
- Install VSFTPD and FTP
yum install vsftpd ftpd - Modify the vsftpd.conf
vi /etc/vsftpd/vsftpd.conf- Disable anonymous login
- uncomment
ascii_upload_enable=YESandascii_download_enable=YES
- Start the vsftpd service
systemctl start vsftpd systemctl enable vsftpd -
Configure firewall firewall-cmd –permanent –add-port=21/tcp firewall-cmd –permanent –add-service=ftp firewall-cmd –reload
- Update the SELinux boolean values for FTP service
setsebool -P ftp_home_dir on - Create FTP user
useradd webftp passwd webftp chown -R webftp /var/www/html